Derby
  1. Derby
  2. DERBY-2066

DisconnectException: The DDM object 0x1232 is not supported following shutdown of embedded engine while network server is running

    Details

    • Urgency:
      Normal
    • Issue & fix info:
      Repro attached
    • Bug behavior facts:
      Crash

      Description

      Running all within the same JVM.
      start network server using api
      connect to database using client
      close connection
      shutdown engine (not network server) using jdbc:derby:;shutdown=true
      connect to database using client - FAILS

      Caused by: org.apache.derby.client.am.DisconnectException: The DDM object 0x1232 is not supported. The connection has been terminated.
      at org.apache.derby.client.net.NetConnectionReply.doObjnsprmSemantics(Unknown Source)
      at org.apache.derby.client.net.NetConnectionReply.parseCommonError(Unknown Source)
      at org.apache.derby.client.net.NetConnectionReply.parseSecurityCheckError(Unknown Source)
      at org.apache.derby.client.net.NetConnectionReply.parseSECCHKreply(Unknown Source)
      at org.apache.derby.client.net.NetConnectionReply.readSecurityCheck(Unknown Source)
      at org.apache.derby.client.net.NetConnection.readSecurityCheckAndAccessRdb(Unknown Source)
      at org.apache.derby.client.net.NetConnection.flowSecurityCheckAndAccessRdb(Unknown Source)
      at org.apache.derby.client.net.NetConnection.flowUSRIDPWDconnect(Unknown Source)
      at org.apache.derby.client.net.NetConnection.flowConnect(Unknown Source)
      at org.apache.derby.client.net.NetConnection.<init>(Unknown Source)
      at org.apache.derby.client.net.ClientJDBCObjectFactoryImpl.newNetConnection(Unknown Source)
      ... 33 more

      1. derby-2066-01-aa-makeMessageIDaSQLState.diff
        5 kB
        Rick Hillegas
      2. derby-2066-01-ab-makeMessageIDaSQLState.diff
        6 kB
        Rick Hillegas
      3. derby-2066-01-ac-makeMessageIDaSQLState.diff
        36 kB
        Rick Hillegas
      4. Test_2066.java
        1 kB
        Rick Hillegas

        Issue Links

          Activity

          Hide
          Daniel John Debrunner added a comment -

          Will try to add reproducible case to ShutDownDBWhenNSShutsDownTest since it is based upon the scenario there.

          Show
          Daniel John Debrunner added a comment - Will try to add reproducible case to ShutDownDBWhenNSShutsDownTest since it is based upon the scenario there.
          Hide
          Knut Anders Hatlen added a comment -

          Triaged for 10.5.2.

          Show
          Knut Anders Hatlen added a comment - Triaged for 10.5.2.
          Hide
          Rick Hillegas added a comment -

          Attaching Test_2066.java, a repro for this problem.

          Show
          Rick Hillegas added a comment - Attaching Test_2066.java, a repro for this problem.
          Hide
          Rick Hillegas added a comment -

          The underlying problem seems to be that the EmbeddedDriver is not registered. According to the "Shutting down the system" section of the Developer's Guide, you have to re-register the EmbeddedDriver before re-connecting after an orderly shutdown. The problem goes away if you insert this statement before the second attempt to get a connection:

          Class.forName(org.apache.derby.jdbc.EmbeddedDriver).newInstance();

          The error message of course is utterly worthless.

          Show
          Rick Hillegas added a comment - The underlying problem seems to be that the EmbeddedDriver is not registered. According to the "Shutting down the system" section of the Developer's Guide, you have to re-register the EmbeddedDriver before re-connecting after an orderly shutdown. The problem goes away if you insert this statement before the second attempt to get a connection: Class.forName(org.apache.derby.jdbc.EmbeddedDriver).newInstance(); The error message of course is utterly worthless.
          Hide
          Rick Hillegas added a comment -

          Attaching derby-2066-01-aa-makeMessageIDaSQLState.diff. This results in a reasonable error message for this situation. I will run regression tests.

          I don't propose to commit this patch before creating the 10.8 branch. I would like to give people time to consider whether there are any problems with this solution:

          The worthless error message arises because the error condition creates a SQLException with no SQLState. In various places the network driver assumes that all SQLExceptions have SQLStates. In one place the network driver assumes that a SQLState will have exactly 5 characters. If these assumptions aren't true, then the protocol trips over NPEs and array bounds exceptions and coughs up the worthless error message seen in this bug report.

          Although I can fault the driver's graceless handling of violated assumptions, I think that it is reasonable to insist that all SQLExceptions have 5 character SQLStates.

          The "unregistered driver" error is raised twice in Derby code. In both cases it surfaces as a SQLException without a SQLState. The actual message handle for this error lives in MessageId.java. Comments in that class indicate that it is only for messages which DON'T appear in SQLExceptions.

          I fixed the problem as follows:

          1) Moved the "unregistered driver" message from MessageId into SQLState. Along the way I gave it a new message handle and placed it in a block with other connection errors.

          2) Adjusted messages.xml accordingly.

          3) Changed the two places which raise this SQLException to also include the SQLState.

          If this seems like a reasonable way to ungarble this problem, then I think it would be worthwhile to examine MessageId to see if it contains other errors which are really surfacing as SQLExceptions. Those errors should get valid SQLStates and should move to SQLState.java too.

          Touches the following files:

          ----------

          M java/engine/org/apache/derby/loc/messages.xml
          M java/shared/org/apache/derby/shared/common/reference/SQLState.java
          M java/shared/org/apache/derby/shared/common/reference/MessageId.java

          Make the "unregistered driver" error a SQLState rather than a MessageId.

          ----------

          M java/engine/org/apache/derby/jdbc/EmbeddedSimpleDataSource.java
          M java/engine/org/apache/derby/jdbc/AutoloadedDriver.java

          Include a SQLState in the "unregistered driver" SQLException.

          Show
          Rick Hillegas added a comment - Attaching derby-2066-01-aa-makeMessageIDaSQLState.diff. This results in a reasonable error message for this situation. I will run regression tests. I don't propose to commit this patch before creating the 10.8 branch. I would like to give people time to consider whether there are any problems with this solution: The worthless error message arises because the error condition creates a SQLException with no SQLState. In various places the network driver assumes that all SQLExceptions have SQLStates. In one place the network driver assumes that a SQLState will have exactly 5 characters. If these assumptions aren't true, then the protocol trips over NPEs and array bounds exceptions and coughs up the worthless error message seen in this bug report. Although I can fault the driver's graceless handling of violated assumptions, I think that it is reasonable to insist that all SQLExceptions have 5 character SQLStates. The "unregistered driver" error is raised twice in Derby code. In both cases it surfaces as a SQLException without a SQLState. The actual message handle for this error lives in MessageId.java. Comments in that class indicate that it is only for messages which DON'T appear in SQLExceptions. I fixed the problem as follows: 1) Moved the "unregistered driver" message from MessageId into SQLState. Along the way I gave it a new message handle and placed it in a block with other connection errors. 2) Adjusted messages.xml accordingly. 3) Changed the two places which raise this SQLException to also include the SQLState. If this seems like a reasonable way to ungarble this problem, then I think it would be worthwhile to examine MessageId to see if it contains other errors which are really surfacing as SQLExceptions. Those errors should get valid SQLStates and should move to SQLState.java too. Touches the following files: ---------- M java/engine/org/apache/derby/loc/messages.xml M java/shared/org/apache/derby/shared/common/reference/SQLState.java M java/shared/org/apache/derby/shared/common/reference/MessageId.java Make the "unregistered driver" error a SQLState rather than a MessageId. ---------- M java/engine/org/apache/derby/jdbc/EmbeddedSimpleDataSource.java M java/engine/org/apache/derby/jdbc/AutoloadedDriver.java Include a SQLState in the "unregistered driver" SQLException.
          Hide
          Rick Hillegas added a comment -

          The first rev of the patch showed a need to update ErrorCodeTest. Attaching a second rev of the patch which updates that test: derby-2066-01-ab-makeMessageIDaSQLState

          Show
          Rick Hillegas added a comment - The first rev of the patch showed a need to update ErrorCodeTest. Attaching a second rev of the patch which updates that test: derby-2066-01-ab-makeMessageIDaSQLState
          Hide
          Knut Anders Hatlen added a comment -

          Hi Rick,

          It sounds reasonable to me to change this code so that the SQLExceptions have an SQLState. Perhaps not 08002, though, as that's reserved for "connection name in use", if I read my copy of SQL:2003 correctly.

          Would it make sense to use Util.generateCsSQLException() instead of constructing a new SQLException directly? Then we'd go through the exception factory and get the correct sub-class of SQLException.

          Show
          Knut Anders Hatlen added a comment - Hi Rick, It sounds reasonable to me to change this code so that the SQLExceptions have an SQLState. Perhaps not 08002, though, as that's reserved for "connection name in use", if I read my copy of SQL:2003 correctly. Would it make sense to use Util.generateCsSQLException() instead of constructing a new SQLException directly? Then we'd go through the exception factory and get the correct sub-class of SQLException.
          Hide
          Rick Hillegas added a comment -

          Thanks, Knut. Those are good suggestions. Attaching a revised version of the patch, derby-2066-01-ac-makeMessageIDaSQLState.diff. I will run regression tests.

          This version makes the following changes:

          1) Uses Util.generateCsSQLException() to build the SQLException.

          2) Changes the SQLState to a form of 08006, the SQL Standard SQLState for connection failures.

          3) Updates the localizations to reflect the message id change.

          Touches the following files:

          M java/engine/org/apache/derby/jdbc/EmbeddedSimpleDataSource.java
          M java/engine/org/apache/derby/jdbc/AutoloadedDriver.java
          M java/engine/org/apache/derby/loc/messages_de_DE.properties
          M java/engine/org/apache/derby/loc/messages_zh_CN.properties
          M java/engine/org/apache/derby/loc/messages_cs.properties
          M java/engine/org/apache/derby/loc/messages_ko_KR.properties
          M java/engine/org/apache/derby/loc/messages_pt_BR.properties
          M java/engine/org/apache/derby/loc/messages_es.properties
          M java/engine/org/apache/derby/loc/messages_fr.properties
          M java/engine/org/apache/derby/loc/messages_pl.properties
          M java/engine/org/apache/derby/loc/messages_hu.properties
          M java/engine/org/apache/derby/loc/messages_it.properties
          M java/engine/org/apache/derby/loc/messages_ja_JP.properties
          M java/engine/org/apache/derby/loc/messages.xml
          M java/engine/org/apache/derby/loc/messages_ru.properties
          M java/engine/org/apache/derby/loc/messages_zh_TW.properties
          M java/shared/org/apache/derby/shared/common/reference/SQLState.java
          M java/shared/org/apache/derby/shared/common/reference/MessageId.java
          M java/testing/org/apache/derbyTesting/functionTests/tests/lang/ErrorCodeTest.java

          Show
          Rick Hillegas added a comment - Thanks, Knut. Those are good suggestions. Attaching a revised version of the patch, derby-2066-01-ac-makeMessageIDaSQLState.diff. I will run regression tests. This version makes the following changes: 1) Uses Util.generateCsSQLException() to build the SQLException. 2) Changes the SQLState to a form of 08006, the SQL Standard SQLState for connection failures. 3) Updates the localizations to reflect the message id change. Touches the following files: M java/engine/org/apache/derby/jdbc/EmbeddedSimpleDataSource.java M java/engine/org/apache/derby/jdbc/AutoloadedDriver.java M java/engine/org/apache/derby/loc/messages_de_DE.properties M java/engine/org/apache/derby/loc/messages_zh_CN.properties M java/engine/org/apache/derby/loc/messages_cs.properties M java/engine/org/apache/derby/loc/messages_ko_KR.properties M java/engine/org/apache/derby/loc/messages_pt_BR.properties M java/engine/org/apache/derby/loc/messages_es.properties M java/engine/org/apache/derby/loc/messages_fr.properties M java/engine/org/apache/derby/loc/messages_pl.properties M java/engine/org/apache/derby/loc/messages_hu.properties M java/engine/org/apache/derby/loc/messages_it.properties M java/engine/org/apache/derby/loc/messages_ja_JP.properties M java/engine/org/apache/derby/loc/messages.xml M java/engine/org/apache/derby/loc/messages_ru.properties M java/engine/org/apache/derby/loc/messages_zh_TW.properties M java/shared/org/apache/derby/shared/common/reference/SQLState.java M java/shared/org/apache/derby/shared/common/reference/MessageId.java M java/testing/org/apache/derbyTesting/functionTests/tests/lang/ErrorCodeTest.java
          Hide
          Rick Hillegas added a comment -

          Tests passed cleanly. Committed derby-2066-01-ac-makeMessageIDaSQLState.diff at subversion revision 1089156.

          Show
          Rick Hillegas added a comment - Tests passed cleanly. Committed derby-2066-01-ac-makeMessageIDaSQLState.diff at subversion revision 1089156.
          Hide
          Kathey Marsden added a comment -

          marked derby_backport_reject_10_8 because of message changes,

          Show
          Kathey Marsden added a comment - marked derby_backport_reject_10_8 because of message changes,
          Hide
          Knut Anders Hatlen added a comment -

          [bulk update] Close all resolved issues that haven't been updated for more than one year.

          Show
          Knut Anders Hatlen added a comment - [bulk update] Close all resolved issues that haven't been updated for more than one year.

            People

            • Assignee:
              Rick Hillegas
              Reporter:
              Daniel John Debrunner
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development