Derby
  1. Derby
  2. DERBY-4911

restoreIntrFlagIfSeen may throw ShutdownException causing confusing console stack trace at server shutdown

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 10.7.1.1, 10.8.1.2
    • Fix Version/s: 10.7.1.1, 10.8.1.2
    • Component/s: Network Server, Store
    • Labels:
      None

      Description

      Exception in thread "DRDAConnThread_508"
      org.apache.derby.iapi.error.ShutdownException:
      at org.apache.derby.iapi.services.context.ContextManager.checkInterrupt(ContextManager.java:437)
      at org.apache.derby.iapi.services.context.ContextManager.getContext(ContextManager.java:155)
      at org.apache.derby.iapi.services.context.ContextService.getContextOrNull(ContextService.java:249)
      at org.apache.derby.iapi.util.InterruptStatus.restoreIntrFlagIfSeen(InterruptStatus.java:158)
      at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:356)
      at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2284)
      at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:82)
      at org.apache.derby.impl.jdbc.EmbedPreparedStatement.closeActions(EmbedPreparedStatement.java:261)
      at org.apache.derby.impl.jdbc.EmbedStatement.close(EmbedStatement.java:307)
      at org.apache.derby.impl.drda.DRDAStatement.close(DRDAStatement.java:1027)
      at org.apache.derby.impl.drda.Database.close(Database.java:364)
      at org.apache.derby.impl.drda.Session.close(Session.java:115)
      at org.apache.derby.impl.drda.DRDAConnThread.closeSession(DRDAConnThread.java:8289)
      at org.apache.derby.impl.drda.DRDAConnThread.run(DRDAConnThread.java:315)

      1. derby-4911-a.diff
        1 kB
        Dag H. Wanvik

        Issue Links

          Activity

          Hide
          Dag H. Wanvik added a comment -

          I have studied this one for a bit; Rick saw this on trunk, Knut has
          also seen it running a JRockit VM on 10.7 RC1, although on a different
          test. The test doesn't really fail in either observation, but a stack
          dump appears on the console.

          Derby is shutting down for some reason, either due to a database level
          error or a normal shutdown connect. Probably a server shutdown.

          Another (I think) thread is closing down because DRDAConnThread has lost
          contact with the client, cf the stack evidence. During closing the
          session the thread calls activation.close from
          EmbedPreparedStatement#closeActions but since the db is shut down, this
          fails, causing a call to handleException. Since I have now inserted code
          in handleException to restore interrupt flags (for the normal case, not
          for this use case , we go looking for the lcc:

          restoreIntrFlagIfSeen calls getContextOrNull

          But the shutdown has already called notifyAllActiveThreads, which
          interrupts session threads, and also marks the context manager for the
          thread with "shutdown = true" (by calling CM#setInterrupted). This
          trips up restoreIntrFlagIfSeen's call to getContextOrNull and you see
          this exception being thrown on the console,
          cf. DRDACinnThread#handleException which calls
          server.consoleExceptionPrintTrace(e);

          Show
          Dag H. Wanvik added a comment - I have studied this one for a bit; Rick saw this on trunk, Knut has also seen it running a JRockit VM on 10.7 RC1, although on a different test. The test doesn't really fail in either observation, but a stack dump appears on the console. Derby is shutting down for some reason, either due to a database level error or a normal shutdown connect. Probably a server shutdown. Another (I think) thread is closing down because DRDAConnThread has lost contact with the client, cf the stack evidence. During closing the session the thread calls activation.close from EmbedPreparedStatement#closeActions but since the db is shut down, this fails, causing a call to handleException. Since I have now inserted code in handleException to restore interrupt flags (for the normal case, not for this use case , we go looking for the lcc: restoreIntrFlagIfSeen calls getContextOrNull But the shutdown has already called notifyAllActiveThreads, which interrupts session threads, and also marks the context manager for the thread with "shutdown = true" (by calling CM#setInterrupted). This trips up restoreIntrFlagIfSeen's call to getContextOrNull and you see this exception being thrown on the console, cf. DRDACinnThread#handleException which calls server.consoleExceptionPrintTrace(e);
          Hide
          Dag H. Wanvik added a comment -

          Uploading a patch which makes restoreIntrFlagIfSeen ignore ShutdownException.
          Running regressions. Knut or Rick, if you could test drive this on the environment on which you saw the error I would appreciate it!

          Show
          Dag H. Wanvik added a comment - Uploading a patch which makes restoreIntrFlagIfSeen ignore ShutdownException. Running regressions. Knut or Rick, if you could test drive this on the environment on which you saw the error I would appreciate it!
          Hide
          Rick Hillegas added a comment -

          Thanks, Dag. I'll run the tests and let you know what I see.

          Show
          Rick Hillegas added a comment - Thanks, Dag. I'll run the tests and let you know what I see.
          Hide
          Rick Hillegas added a comment -

          Tests ran cleanly for me (except for the ping test, which regularly fails on my machine). I did not see the exception on the console this time.

          Show
          Rick Hillegas added a comment - Tests ran cleanly for me (except for the ping test, which regularly fails on my machine). I did not see the exception on the console this time.
          Hide
          Dag H. Wanvik added a comment -

          Thanks, Rick.
          suitesAll ran cleanly for me too, but then, it also did earlier. I'll wait for Knut's tests as well, then commit it.

          Show
          Dag H. Wanvik added a comment - Thanks, Rick. suitesAll ran cleanly for me too, but then, it also did earlier. I'll wait for Knut's tests as well, then commit it.
          Hide
          Knut Anders Hatlen added a comment -

          I haven't been able to reproduce the issue with the patch either.

          Show
          Knut Anders Hatlen added a comment - I haven't been able to reproduce the issue with the patch either.
          Hide
          Lily Wei added a comment -

          I just run it on Windows with the patch. I did not see it either. Thanks so much for fixing this issue.

          Show
          Lily Wei added a comment - I just run it on Windows with the patch. I did not see it either. Thanks so much for fixing this issue.
          Hide
          Dag H. Wanvik added a comment -

          Thanks for the help with testing this!

          Committed to trunk as svn 1038813. Backported to 10.7 branch as svn 1038816, closing.

          Show
          Dag H. Wanvik added a comment - Thanks for the help with testing this! Committed to trunk as svn 1038813. Backported to 10.7 branch as svn 1038816, closing.

            People

            • Assignee:
              Dag H. Wanvik
              Reporter:
              Dag H. Wanvik
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development