Uploaded image for project: 'Jackrabbit Oak'
  1. Jackrabbit Oak
  2. OAK-1266 DocumentStore implementation for relational databases
  3. OAK-6237

Tomcat JDBC pool's StatementCache interceptor may cache borked PreparedStatements with DB2

    XMLWordPrintableJSON

    Details

      Description

      (cd oak-store-document; mvn clean install -Prdb-db2 -Dtest=RDBBlobStoreTest)
      

      fails with:

      [ERROR] testDeleteChunks[MyFixture: RDB-DB2](org.apache.jackrabbit.oak.plugins.document.blob.RDBBlobStoreTest)  Time elapsed: 0.069 s  <<< ERROR!
      com.ibm.db2.jcc.am.SqlSyntaxErrorException: [jcc][10145][10844][4.16.53] Invalid parameter 1: Parameter index is out of range. ERRORCODE=-4461, SQLSTATE=42815
              at org.apache.jackrabbit.oak.plugins.document.blob.RDBBlobStoreTest.testDeleteChunks(RDBBlobStoreTest.java:219)
      

      Stack trace:

      com.ibm.db2.jcc.am.SqlSyntaxErrorException: [jcc][10145][10844][4.16.53] Invalid parameter 1: Parameter index is out of range. ERRORCODE=-4461, SQLSTATE=42815
      	at com.ibm.db2.jcc.am.fd.a(fd.java:739)
      	at com.ibm.db2.jcc.am.fd.a(fd.java:60)
      	at com.ibm.db2.jcc.am.fd.a(fd.java:103)
      	at com.ibm.db2.jcc.am.uo.l(uo.java:5982)
      	at com.ibm.db2.jcc.am.uo.j(uo.java:5937)
      	at com.ibm.db2.jcc.am.uo.a(uo.java:1606)
      	at com.ibm.db2.jcc.am.uo.setString(uo.java:1595)
      	at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at org.apache.tomcat.jdbc.pool.interceptor.StatementDecoratorInterceptor$StatementProxy.invoke(StatementDecoratorInterceptor.java:261)
      	at com.sun.proxy.$Proxy12.setString(Unknown Source)
      	at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at org.apache.tomcat.jdbc.pool.interceptor.AbstractQueryReport$StatementProxy.invoke(AbstractQueryReport.java:235)
      	at com.sun.proxy.$Proxy12.setString(Unknown Source)
      	at org.apache.jackrabbit.oak.plugins.document.rdb.RDBPreparedStatementWrapper.setString(RDBPreparedStatementWrapper.java:552)
      	at org.apache.jackrabbit.oak.plugins.document.rdb.RDBBlobStoreFriend.isDataEntryPresent(RDBBlobStoreFriend.java:62)
      	at org.apache.jackrabbit.oak.plugins.document.blob.RDBBlobStoreTest.testDeleteChunks(RDBBlobStoreTest.java:219)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      	at org.junit.runners.Suite.runChild(Suite.java:128)
      	at org.junit.runners.Suite.runChild(Suite.java:27)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
      	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
      
      

      The test case is:

          public static boolean isDataEntryPresent(RDBBlobStore ds, byte[] digest) throws Exception {
              String id = StringUtils.convertBytesToHex(digest);
              Connection con = ds.ch.getROConnection();
              PreparedStatement prep = null;
              ResultSet rs = null;
              try {
                  prep = con.prepareStatement("select ID from " + ds.tnData + " where ID = ?");
                  prep.setString(1, id);
                  rs = prep.executeQuery();
                  return rs.next();
              } finally {
                  closeResultSet(rs);
                  closeStatement(prep);
                  con.commit();
                  ds.ch.closeConnection(con);
              }
          }
      

      so clearly there is a parameter 1.

      Disabling the tomcat JDBC statement cache fixes the issue:

      (cd oak-store-document; mvn clean install -Prdb-db2 -Dtest=RDBBlobStoreTest -Dorg.apache.jackrabbit.oak.plugins.document.rdb.RDBDataSourceFactory.jdbcInterceptors=)
      

      Upgrading to the latest 7.x connection pool (7.0.77) doesn't seem to fix the problem.

        Attachments

        1. OAK-6237.diff
          2 kB
          Julian Reschke

          Issue Links

            Activity

              People

              • Assignee:
                reschke Julian Reschke
                Reporter:
                reschke Julian Reschke
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: