[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Paging bug from 2.2.5 still present in 2.2.11



You might want to an attach this additional information
to a currently open ITS (if you believe your problem
is the same as it reports) or open a new ITS (if you
think your problem is different).  To attach information
to an existing ITS, send it to openldap-its@openldap.org
with the proper ITS#nnn string in the subject, e.g.,
        Additional info (ITS#3089)

Don't expect developers investigating an ITS to find
information not attached to the ITS...

Kurt

At 01:57 AM 6/4/2004, Jon Poulton wrote:
>The Paged Results Control bug that I mentioned for OpenLdap 2.2.5 still
>appears to be present IN 2.2.11. I recently upgraded from 2.2.5 to 2.2.11
>and ran an old test I had to see if the paged results control stuff now
>worked (java code attached). The test failed in the same manner as it had
>with 2.2.5.
>
>I wouldnt have posted to the list, except some time ago I seem to remember
>someone mentioning that it had been fixed (in 2.2.7 I think). I just thought
>I'd let you know the bug is still there, lurking in the shadows and waiting
>to strike ;-)
>
>Links that may be relevant:
>
>http://www.openldap.org/its/index.cgi/Contrib?id=2189;expression=paging;usea
>rchives=1;statetype=-1
>Looks curiously like what I've been experiencing; beyond getting the first
>page of results I get errors (LDAP code 2 or 53) stating that the cookie is
>invalid or old. LDAP error code 2 always seems to be the error I get the
>first time my test method runs (wrapped by a CommunicationException) and
>LDAP error code 53 always seems to be generated for all subsequent runs of
>the method until the calling program exits.
>
>This looks similar to the problem I've been having:
>http://www.openldap.org/its/index.cgi/Incoming?id=3089;selectid=3089;usearch
>ives=1;statetype=-1
>
>---
>Content-Type: text/plain; name="testmethod.txt"
>
>        /* Do not remove this test method or these comments until we get OpenLdap working with paging.
>
>           Currently this method will fail at a random point when retreiving a number of pages one after
>           the other. The failure is reported in the form of an OperationNotSupportedException wrapped around
>           the following Ldap error code:
>           
>           [LDAP: error code 53 - paged results cookie is invalid or old]
>           
>           A brief search using Google gave me a peice of C source code for OpenLdap, which is ultimately
>           the source of the error:
>           
>           http://www.opensource.apple.com/darwinsource/10.3/OpenLDAP-37/OpenLDAP/servers/slapd/controls.c
>           
>           A copy of the controls.c is available locally. On occasion the start of the error message says 
>           [LDAP: error code 2..] but the remainder of the message is the same.
>        */   
>        public void testLdapPaging() throws Exception
>        {
>                try {
>                
>                        //#1 create a naming enumeration to hold the results
>                        NamingEnumeration naming = null;
>                
>                        //#2 set or retreive the size of the page
>                        int pageSize = 2;
>                
>                        //#3 determine what the search base is
>                        String searchBase = "ou=People, dc=jon, dc=illumining, dc=com";
>                
>                        //#4 get the context object
>                        Hashtable hashtable = new Hashtable();
>                        String initCtxFactory = "com.sun.jndi.ldap.LdapCtxFactory";
>                        String host = "ldap://localhost:389";;
>                        String security = "simple";
>                        String dn = "cn=Manager, dc=illumining, dc=com";
>                        String pwd = "secret";          
>                        hashtable.put(Context.INITIAL_CONTEXT_FACTORY, initCtxFactory);
>                        hashtable.put(Context.PROVIDER_URL, host);
>                        hashtable.put(Context.SECURITY_AUTHENTICATION, security);
>                        hashtable.put(Context.SECURITY_PRINCIPAL, dn);
>                        hashtable.put(Context.SECURITY_CREDENTIALS, pwd);
>                        hashtable.put("java.naming.ldap.version", "3");
>                        InitialLdapContext ctx = new InitialLdapContext(hashtable, null);
>                
>                        //#5 create the search controls object
>                        SearchControls controls = new SearchControls();
>                        controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
>                
>                        //#6 create the paged results control object
>                        PagedResultsControl prc = new PagedResultsControl(pageSize);
>                
>                        //#7 create the request controls array
>                        Control reqCtls[] = new Control[]{prc};
>                
>                        //#8 set the request controls array on the context
>                        ctx.setRequestControls(reqCtls);
>                
>                        //#9 set what the return attributes will be
>                        String[] returnAttributes = {"uid"};
>                        controls.setReturningAttributes(returnAttributes);
>                
>                        //#10 create an ldap search filter
>                        String ldapSearchFilter = "(&(objectClass=inetOrgPerson)(cn=*hick*))";
>                
>                        //#11 create do while loop variables
>                        int count = 0;
>                        byte[] b = null;
>                
>                        //#12 enter do while loop
>                        do
>                        {
>                                //#13 perform search using search base- search filter and search
>                                naming = ctx.search(searchBase, ldapSearchFilter, controls);
>                        
>                                //#14 test if NamingEnumeration does not equal null
>                                if(naming != null)
>                                {
>                                        int subcounter = 0;
>                                        // You must iterate through the NamingEnumeration, even if its not the one you want-
>                                        // and you want a subsequent page. For some reason if you dont iterate through the 
>                                        // NamingEnumeration a server-side cookie is NOT created, which means you cant access
>                                        // the subsequent pages by obtaining a PagedResultsResponseControl and getting a cookie
>                                        // from it.
>                                        while(naming.hasMoreElements())
>                                        {
>                                                subcounter++;
>                                                SearchResult si = (SearchResult)naming.nextElement();
>                                                count++;
>                                                System.out.println(si.getName());
>                                        }
>                                        System.out.println(ldapSearchFilter + " returned " + subcounter );
>                                }
>                                else                    
>                                {
>                                        System.out.println(ldapSearchFilter + " did not return any entries.");
>                                }
>                        
>                                //#15 check if the response controls are null
>                                Control[] response = ctx.getResponseControls();
>                                if(response != null)
>                                {
>                                        b =((PagedResultsResponseControl)response[0]).getCookie();
>                                }
>                                else
>                                {
>                                        b = null;
>                                }
>                                if(b != null)
>                                {
>                                        //print out cookie info
>                                        System.out.println("Got cookie: ");
>                                        for(int i = 0; i < b.length; i++)
>                                        {
>                                                System.out.println("Byte "+i+" = "+ b[i]);
>                                        }
>                                
>                                        //create new PagedResultsControl
>                                        prc = new PagedResultsControl(pageSize, b, Control.CRITICAL);
>                                        ctx.setRequestControls(new Control[] {prc});
>                                }
>                        
>                        }while(b != null);
>                        //added this to see if it made any difference
>                        naming.close();
>                        ctx.close();
>                } catch (NamingException e) {
>                        e.printStackTrace();
>                        throw new Exception();
>                } catch (IOException e) {
>                        e.printStackTrace();
>                        throw new Exception();
>                }
>        }
>---
>Content-Type: text/plain; name="STACK.txt"
>
>FIRST EXAMPLE STACK TRACE AND STDOUT- FAILURE ON AN ATTEMPT TO GET THE SECOND PAGE
>
>uid=Ahab12345678
>uid=Abraham12345678
>(&(objectClass=inetOrgPerson)(cn=*hick*)) returned 2
>Got cookie:
>Byte 0 = 22
>Byte 1 = -4
>Byte 2 = 0
>Byte 3 = 0
>javax.naming.CommunicationException: [LDAP: error code 2 - paged results cookie is invalid]; remaining name 'ou=People, dc=jon, dc=illumining, dc=com'
>        at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3036)
>        at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2934)
>        at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2740)
>        at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1811)
>        at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1734)
>        at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:368)
>        at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:328)
>        at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:313)
>        at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:238)
>        at com.illumining.server.persistence.ldap.LdapUserDAO.testLdapPaging(LdapUserDAO.java:1002)
>        at com.illumining.server.UserService.test(UserService.java:885)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:324)
>        at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
>        at sun.rmi.transport.Transport$1.run(Transport.java:148)
>        at java.security.AccessController.doPrivileged(Native Method)
>        at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
>        at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
>        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
>        at java.lang.Thread.run(Thread.java:534)
>
>
>
>SECOND EXAMPLE STDOUT AND STACK TRACE BELOW- FAILURE ON AN ATTEMPT TO GET THE THIRD PAGE OF RESULTS
>
>uid=Ahab12345678
>uid=Abraham12345678
>(&(objectClass=inetOrgPerson)(cn=*hick*)) returned 2
>Got cookie:
>Byte 0 = 99
>Byte 1 = -4
>Byte 2 = 0
>Byte 3 = 0
>uid=Alice12345678
>uid=Billy-Bob12345678
>(&(objectClass=inetOrgPerson)(cn=*hick*)) returned 2
>Got cookie:
>Byte 0 = 105
>Byte 1 = -4
>Byte 2 = 0
>Byte 3 = 0
>javax.naming.OperationNotSupportedException: [LDAP: error code 53 - paged results cookie is invalid or old]; remaining name 'ou=People, dc=jon, dc=illumining, dc=com'
>        at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3061)
>        at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2934)
>        at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2740)
>        at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1811)
>        at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1734)
>        at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:368)
>        at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:328)
>        at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:313)
>        at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:238)
>        at com.illumining.server.persistence.ldap.LdapUserDAO.testLdapPaging(LdapUserDAO.java:1002)
>        at com.illumining.server.UserService.test(UserService.java:885)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:324)
>        at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
>        at sun.rmi.transport.Transport$1.run(Transport.java:148)
>        at java.security.AccessController.doPrivileged(Native Method)
>        at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
>        at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
>        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
>        at java.lang.Thread.run(Thread.java:534)
>------=_NextPart_000_0006_01C44A1A.4F0A80B0--