Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-7015

DatabaseMetaData.getTables gives exception when called from two threads and the statement is stale

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 10.14.2.0
    • None
    • JDBC
    • None
    • Linux amd64
    • Normal
    • Repro attached
    • Deviation from standard, Seen in production

    Description

      In certain circumstances, when two threads both call DatabaseMetaData.getTables at the same time, one fails with the exception "A lock could not be obtained within the time requested".

      This seems to be when the statement has been executed 100 times (I think as per derby.language.stalePlanCheckInterval) and the number of rows returned by the query is different compared to the first time getTables was called.

      I attach a test case which reproduces the problem on my workstation most times I execute it.

      Output from java org.apache.derby.tools.sysinfo:

      ------------------ Java Information ------------------
      Java Version:    1.8.0_66
      Java Vendor:     Oracle Corporation
      Java home:       /home/myuser/bin/local/jdk1.8.0_66/jre
      Java classpath:  /home/myuser/workspace/DerbyDemo/bin:/home/myuser/workspace/DerbyDemo/lib/derby.jar:/home/myuser/workspace/DerbyDemo/lib/junit-4.11.jar:/home/myuser/workspace/DerbyDemo/lib/hamcrest-core-1.3.jar
      OS name:         Linux
      OS architecture: amd64
      OS version:      4.4.0-134-generic
      Java user name:  myuser
      Java user home:  /home/myuser
      Java user dir:   /home/myuser/workspace/DerbyDemo
      java.specification.name: Java Platform API Specification
      java.specification.version: 1.8
      java.runtime.version: 1.8.0_66-b17
      --------- Derby Information --------
      [/home/myuser/workspace/DerbyDemo/lib/derby.jar] 10.14.2.0 - (1828579)
      ------------------------------------------------------
      ----------------- Locale Information -----------------
      ------------------------------------------------------
      ------------------------------------------------------

      Also attached is the exception that it produces, and also a jstack of the two threads when everything is hung but before the exception is thrown.

       

      Attachments

        1. DerbyGetTablesDeadlockTest.java
          3 kB
          Alex
        2. exception-reported.txt
          4 kB
          Alex
        3. threads-during-hang.txt
          5 kB
          Alex

        Activity

          People

            Unassigned Unassigned
            alex24 Alex
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: