Derby
  1. Derby
  2. DERBY-5618

On Windows, orderly engine shutdown does not release the file handle on a jar file containing a database which was booted using the classpath subprotocol

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 10.9.1.0
    • Fix Version/s: None
    • Component/s: Services, Store
    • Environment:
      xp professional 5.1, oracle java 6, derby 10.9 trunk
    • Urgency:
      Normal
    • Issue & fix info:
      High Value Fix, Repro attached

      Description

      Boot a database in a jar file, using the classpath subprotocol, then shutdown the engine. This leaves the jar file still open on Windows. However, orderly engine shutdown correctly releases the file if you boot it using the jar subprotocol instead. I will attach a repro.

      1. 5618.sql
        1 kB
        Rick Hillegas
      2. FileUtils.java
        5 kB
        Rick Hillegas

        Issue Links

          Activity

          Hide
          Rick Hillegas added a comment -

          Attaching a repro for this problem:

          1) FileUtils.java - A set of routines to perform file operations. These operations are used by the following script.

          2) 5618.sql - A script that shows the problem.

          Just compile FileUtils and put it on your classpath. Then run the script through ij.

          Show
          Rick Hillegas added a comment - Attaching a repro for this problem: 1) FileUtils.java - A set of routines to perform file operations. These operations are used by the following script. 2) 5618.sql - A script that shows the problem. Just compile FileUtils and put it on your classpath. Then run the script through ij.
          Hide
          Rick Hillegas added a comment -

          Linking this issue to DERBY-866. This problem was discovered while writing tests for DERBY-866. A test case will have to be disabled on Windows until this bug is fixed. At that point, we should revisit the disabled test.

          Show
          Rick Hillegas added a comment - Linking this issue to DERBY-866 . This problem was discovered while writing tests for DERBY-866 . A test case will have to be disabled on Windows until this bug is fixed. At that point, we should revisit the disabled test.
          Hide
          Kristian Waagan added a comment -

          For clarity only, I assume the jar file is left open on other platforms than Windows too, but that on those other platforms you can write to the file even if another process has a file handle to it?

          Show
          Kristian Waagan added a comment - For clarity only, I assume the jar file is left open on other platforms than Windows too, but that on those other platforms you can write to the file even if another process has a file handle to it?
          Hide
          Rick Hillegas added a comment -

          Hi Kristian,

          That is a good point. The file handle is probably still open on *nix platforms too. It's just that we notice the orphaned file handle on Windows. Note that in the repro, the same process runs the engine, shuts it down, and then tries to delete the jar file. Thanks.

          Show
          Rick Hillegas added a comment - Hi Kristian, That is a good point. The file handle is probably still open on *nix platforms too. It's just that we notice the orphaned file handle on Windows. Note that in the repro, the same process runs the engine, shuts it down, and then tries to delete the jar file. Thanks.
          Hide
          Mike Matrigali added a comment -

          10.9 triage
          has a repro and is tests are disabled because of it, so would be nice to fix.

          I don't know much about jar file databases. Is derby meant to support booting from a jar file using
          using the classpath subprotocol, or should one always use the jar subprotocol.

          Show
          Mike Matrigali added a comment - 10.9 triage has a repro and is tests are disabled because of it, so would be nice to fix. I don't know much about jar file databases. Is derby meant to support booting from a jar file using using the classpath subprotocol, or should one always use the jar subprotocol.
          Hide
          Rick Hillegas added a comment -

          Hi Mike,

          I also am not an expert on accessing databases via the classpath subprotocol. However, the Developer's Guide says this in the section titled "Accessing databases from the classpath":

          "In most cases, you access databases from the file system. However, it is also possible to access databases from the classpath. The databases can be archived into a jar or zip file or left as is.

          All such databases are read-only.

          To access an unarchived database from the classpath, specify the name of the database relative to the directory in the classpath. You can use the classpath subprotocol if such a database is ambiguous within the directory system."

          Show
          Rick Hillegas added a comment - Hi Mike, I also am not an expert on accessing databases via the classpath subprotocol. However, the Developer's Guide says this in the section titled "Accessing databases from the classpath": "In most cases, you access databases from the file system. However, it is also possible to access databases from the classpath. The databases can be archived into a jar or zip file or left as is. All such databases are read-only. To access an unarchived database from the classpath, specify the name of the database relative to the directory in the classpath. You can use the classpath subprotocol if such a database is ambiguous within the directory system."
          Hide
          Knut Anders Hatlen added a comment -

          This might be a duplicate of DERBY-2162.

          Show
          Knut Anders Hatlen added a comment - This might be a duplicate of DERBY-2162 .
          Hide
          ASF subversion and git services added a comment -

          Commit 1582220 from Knut Anders Hatlen in branch 'code/trunk'
          [ https://svn.apache.org/r1582220 ]

          DERBY-2162/DERBY-5618: Close the URLClassLoader when tests are done
          with it so that file handles are freed and the jar files can be
          deleted.

          Show
          ASF subversion and git services added a comment - Commit 1582220 from Knut Anders Hatlen in branch 'code/trunk' [ https://svn.apache.org/r1582220 ] DERBY-2162 / DERBY-5618 : Close the URLClassLoader when tests are done with it so that file handles are freed and the jar files can be deleted.
          Hide
          Knut Anders Hatlen added a comment -

          The test cases that previously were disabled because of this bug, have now been enabled by the fix for DERBY-2162, so I'm resolving this issue as a duplicate.

          The repro attached to this issue still fails, but I believe that's expected since the URLClassLoader that references the jar file is still the context class loader of the main thread and open after the engine shutdown. As noted in DERBY-2162, Derby cannot close the application's class loaders at shutdown, since it cannot tell if the application will need them again, so it has to be the application's responsibility to close them down when they are no longer needed.

          Show
          Knut Anders Hatlen added a comment - The test cases that previously were disabled because of this bug, have now been enabled by the fix for DERBY-2162 , so I'm resolving this issue as a duplicate. The repro attached to this issue still fails, but I believe that's expected since the URLClassLoader that references the jar file is still the context class loader of the main thread and open after the engine shutdown. As noted in DERBY-2162 , Derby cannot close the application's class loaders at shutdown, since it cannot tell if the application will need them again, so it has to be the application's responsibility to close them down when they are no longer needed.

            People

            • Assignee:
              Unassigned
              Reporter:
              Rick Hillegas
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development