Return-Path: X-Original-To: apmail-jackrabbit-dev-archive@www.apache.org Delivered-To: apmail-jackrabbit-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AD3069A7A for ; Sat, 17 Mar 2012 19:06:03 +0000 (UTC) Received: (qmail 96632 invoked by uid 500); 17 Mar 2012 19:06:03 -0000 Delivered-To: apmail-jackrabbit-dev-archive@jackrabbit.apache.org Received: (qmail 96580 invoked by uid 500); 17 Mar 2012 19:06:03 -0000 Mailing-List: contact dev-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list dev@jackrabbit.apache.org Received: (qmail 96572 invoked by uid 99); 17 Mar 2012 19:06:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 17 Mar 2012 19:06:03 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 17 Mar 2012 19:05:59 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 82476256B9 for ; Sat, 17 Mar 2012 19:05:38 +0000 (UTC) Date: Sat, 17 Mar 2012 19:05:38 +0000 (UTC) From: "Unico Hommes (Updated) (JIRA)" To: dev@jackrabbit.apache.org Message-ID: <1088860873.28416.1332011138535.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <545382418.24649.1331907944787.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (JCR-3261) Problems with BundleDbPersistenceManager getAllNodeIds MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/JCR-3261?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Unico Hommes updated JCR-3261: ------------------------------ Description: When using MySQL: The problem arises when the method parameter maxcount is less than the total amount of records in the bundle table. First of all I found out that mysql orders the nodeid objects different than jackrabbit does. The following test describes this idea: public void testMySQLOrderByNodeId() throws Exception { NodeId nodeId1 = new NodeId("7ff9e87c-f87f-4d35-9d61-2e298e56ac37"); NodeId nodeId2 = new NodeId("9fd0d452-b5d0-426b-8a0f-bef830ba0495"); PreparedStatement stmt = connection.prepareStatement("SELECT NODE_ID FROM DEFAULT_BUNDLE WHERE NODE_ID = ? OR NODE_ID = ? ORDER BY NODE_ID"); Object[] params = new Object[] { nodeId1.getRawBytes(), nodeId2.getRawBytes() }; stmt.setObject(1, params[0]); stmt.setObject(2, params[1]); ArrayList nodeIds = new ArrayList(); ResultSet resultSet = stmt.executeQuery(); while(resultSet.next()) { NodeId nodeId = new NodeId(resultSet.getBytes(1)); System.out.println(nodeId); nodeIds.add(nodeId); } Collections.sort(nodeIds); for (NodeId nodeId : nodeIds) { System.out.println(nodeId); } } Which results in the following output: 7ff9e87c-f87f-4d35-9d61-2e298e56ac37 9fd0d452-b5d0-426b-8a0f-bef830ba0495 9fd0d452-b5d0-426b-8a0f-bef830ba0495 7ff9e87c-f87f-4d35-9d61-2e298e56ac37 Now the problem with the getAllNodeIds method is that it fetches an extra 10 records on top of maxcount (to avoid a problem where the first key is not the one you that is wanted). Afterwards it skips a number of records again, this time using nodeid.compareto. This compareto statement returns true unexpectedly for mysql because the code doesn't expect the mysql ordering. I had the situation where I had about 17000 records in the bundle table but consecutively getting the ids a thousand records at a time returned only about 8000 records in all. was: When using MySQL: The problem arises when the method parameter maxcount is less than the total amount of records in the bundle table. First of all I found out that mysql orders the nodeid objects different than jackrabbit does. The following test describes this idea: public void testMySQLOrderByNodeId() throws Exception { NodeId nodeId1 = new NodeId("7ff9e87c-f87f-4d35-9d61-2e298e56ac37"); NodeId nodeId2 = new NodeId("9fd0d452-b5d0-426b-8a0f-bef830ba0495"); PreparedStatement stmt = connection.prepareStatement("SELECT NODE_ID FROM DEFAULT_BUNDLE WHERE NODE_ID = ? OR NODE_ID = ? ORDER BY NODE_ID"); Object[] params = new Object[] { nodeId1.getRawBytes(), nodeId2.getRawBytes() }; stmt.setObject(1, params[0]); stmt.setObject(2, params[1]); ArrayList nodeIds = new ArrayList(); ResultSet resultSet = stmt.executeQuery(); while(resultSet.next()) { NodeId nodeId = new NodeId(resultSet.getBytes(1)); System.out.println(nodeId); nodeIds.add(nodeId); } Collections.sort(nodeIds); for (NodeId nodeId : nodeIds) { System.out.println(nodeId); } } Which results in the following output: 7ff9e87c-f87f-4d35-9d61-2e298e56ac37 9fd0d452-b5d0-426b-8a0f-bef830ba0495 9fd0d452-b5d0-426b-8a0f-bef830ba0495 7ff9e87c-f87f-4d35-9d61-2e298e56ac37 Now the problem with the getAllNodeIds method is that it fetches an extra 10 records on top of maxcount (to avoid a problem where the first key is not the one you that is wanted). Afterwards it skips a number of records again, this time using nodeid.compareto. This compareto statement returns true unexpectedly for mysql because the code doesn't expect the mysql ordering. I had the situation where I had about 17000 records in the bundle table but consecutively getting the ids a thousand records at a time returned only about 8000 records in all. With Derby DB there is an infinite loop when it is used as it is for instance by ConsistencyCheckerImpl. This is because of the bundleSelectAllIdsFromSQL sql query that is done in the case of SM_LONGLONG_KEYS which is used in the case of Derby. Compare for instance that statement with the corresponding statement for SM_BINARY_KEYS. You will see that the former uses >= while the latter only >. The latter is correct. We want only records that are bigger than the passed in parameter, not bigger or equal. Problem was at my end apparently. No problem with Derby DB after all. > Problems with BundleDbPersistenceManager getAllNodeIds > ------------------------------------------------------ > > Key: JCR-3261 > URL: https://issues.apache.org/jira/browse/JCR-3261 > Project: Jackrabbit Content Repository > Issue Type: Bug > Affects Versions: 2.4 > Reporter: Unico Hommes > Fix For: 2.4.1 > > Attachments: bdbpm_allids.patch > > > When using MySQL: > The problem arises when the method parameter maxcount is less than the total amount of records in the bundle table. > First of all I found out that mysql orders the nodeid objects different than jackrabbit does. The following test describes this idea: > public void testMySQLOrderByNodeId() throws Exception { > NodeId nodeId1 = new NodeId("7ff9e87c-f87f-4d35-9d61-2e298e56ac37"); > NodeId nodeId2 = new NodeId("9fd0d452-b5d0-426b-8a0f-bef830ba0495"); > PreparedStatement stmt = connection.prepareStatement("SELECT NODE_ID FROM DEFAULT_BUNDLE WHERE NODE_ID = ? OR NODE_ID = ? ORDER BY NODE_ID"); > Object[] params = new Object[] { nodeId1.getRawBytes(), nodeId2.getRawBytes() }; > stmt.setObject(1, params[0]); > stmt.setObject(2, params[1]); > ArrayList nodeIds = new ArrayList(); > ResultSet resultSet = stmt.executeQuery(); > while(resultSet.next()) { > NodeId nodeId = new NodeId(resultSet.getBytes(1)); > System.out.println(nodeId); > nodeIds.add(nodeId); > } > Collections.sort(nodeIds); > for (NodeId nodeId : nodeIds) { > System.out.println(nodeId); > } > } > Which results in the following output: > 7ff9e87c-f87f-4d35-9d61-2e298e56ac37 > 9fd0d452-b5d0-426b-8a0f-bef830ba0495 > 9fd0d452-b5d0-426b-8a0f-bef830ba0495 > 7ff9e87c-f87f-4d35-9d61-2e298e56ac37 > Now the problem with the getAllNodeIds method is that it fetches an extra 10 records on top of maxcount (to avoid a problem where the first key is not the one you that is wanted). Afterwards it skips a number of records again, this time using nodeid.compareto. This compareto statement returns true unexpectedly for mysql because the code doesn't expect the mysql ordering. > I had the situation where I had about 17000 records in the bundle table but consecutively getting the ids a thousand records at a time returned only about 8000 records in all. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira