Derby
  1. Derby
  2. DERBY-4072

shutdown with incorrect permission on log files shows java.lang.NullPointerException at org.apache.derby.impl.store.raw.log.LogToFile.flush(LogToFile.java:3964). Should give bettter message.

    Details

    • Issue & fix info:
      Patch Available

      Description

      I recently saw case where a user was seeing the following error in the derby.log when trying to shutdown their database.
      New exception raised during cleanup null
      java.lang.NullPointerException
      at org.apache.derby.impl.store.raw.log.LogToFile.flush(LogToFile.java:3964)
      at org.apache.derby.impl.store.raw.log.LogToFile.flush(LogToFile.java:1781)
      at org.apache.derby.impl.store.raw.data.BaseDataFileFactory.flush(BaseDataFileFa
      at org.apache.derby.impl.store.raw.data.CachedPage.writePage(CachedPage.java:761
      at org.apache.derby.impl.store.raw.data.CachedPage.clean(CachedPage.java:610)
      at org.apache.derby.impl.services.cache.ConcurrentCache.cleanAndUnkeepEntry(Conc
      at org.apache.derby.impl.services.cache.ConcurrentCache.cleanCache(ConcurrentCac
      at org.apache.derby.impl.services.cache.ConcurrentCache.cleanAll(ConcurrentCache
      at org.apache.derby.impl.services.cache.ConcurrentCache.shutdown(ConcurrentCache
      at org.apache.derby.impl.store.raw.data.BaseDataFileFactory.stop(BaseDataFileFac
      at org.apache.derby.impl.services.monitor.TopService.stop(TopService.java:405)
      at org.apache.derby.impl.services.monitor.TopService.shutdown(TopService.java:34
      at org.apache.derby.impl.services.monitor.BaseMonitor.shutdown(BaseMonitor.java:
      at org.apache.derby.impl.db.DatabaseContextImpl.cleanupOnError(DatabaseContextIm
      at org.apache.derby.iapi.services.context.ContextManager.cleanupOnError(ContextM
      at org.apache.derby.impl.jdbc.TransactionResourceImpl.cleanupOnError(Transaction
      at org.apache.derby.impl.jdbc.EmbedConnection.<init>(EmbedConnection.java:584)
      at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Driver40.java:68)
      at org.apache.derby.jdbc.InternalDriver.connect(InternalDriver.java:238)
      at org.apache.derby.jdbc.AutoloadedDriver.connect(AutoloadedDriver.java:119)
      at java.sql.DriverManager.getConnection(DriverManager.java:316)
      at java.sql.DriverManager.getConnection(DriverManager.java:273)

      It ended up that some of the log files did not have proper write permissions because some operation on the database had been performed by root. They had subsequently deleted their db.lck file so the database did not boot READ ONLY as it would if the root owned db.lck file still existed and the symptom was that they got this error on shutdown.

      Clearly this was user error, but it would have been good if we gave a better error message. To reproduce on Linux:
      As a user with umask 0022, run the program
      java MakeDB
      this will make the databases wombat and create a table.
      su root
      with umask 0022, run the program to insert data and remove the db.lck file:
      java InsertALot
      rm wombat/db.lck
      go back to the original user
      run the program:
      java ConnectAndShutdown

      The application gets the normal shutdown exception but if you look in derby.log you will see the exception.
      java.lang.NullPointerException
      at org.apache.derby.impl.store.raw.log.LogToFile.flush(LogToFile.java:3964)
      ...
      I will attach the files.

      1. MakeDB.java
        0.7 kB
        Kathey Marsden
      2. InsertALot.java
        1 kB
        Kathey Marsden
      3. ConnectAndShutdown.java
        0.6 kB
        Kathey Marsden
      4. sample.derby.log
        6 kB
        Kathey Marsden
      5. derby-4072_diff.txt
        3 kB
        Kathey Marsden

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Kathey Marsden
            Reporter:
            Kathey Marsden
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development