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

Network Server should check for current open and active connections before shutting down a database

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 10.0.2.0
    • None
    • Network Server
    • None
    • Any
    • Normal

    Description

      When a database shutdown is issued using the 'shutdown=true' by a client, the network server does not check for any active
      connections and shuts down the respective database. As a result queries on the active connection start failing.

      I would expect the right behaviour should be to throw an error mentioning shutdown was not performed since there are open connections
      to the database.

      Here is a sample output:

      ij version 10.2
      ij> connect 'jdbc:derby://localhost:1527/testdb;create=true' as connA;
      ij> drop table t;
      0 rows inserted/updated/deleted
      ij> create table t (id int);
      0 rows inserted/updated/deleted
      ij> insert into t values (1);
      1 row inserted/updated/deleted
      ij> insert into t values (2);
      1 row inserted/updated/deleted
      ij> select * from t;
      ID
      -----------
      1
      2

      2 rows selected

      --Connection A is still open

      ij> connect 'jdbc:derby://localhost:1527/testdb' as connB;
      ij(CONNB)> insert into t values (3);
      1 row inserted/updated/deleted
      ij(CONNB)> select * from t;
      ID
      -----------
      1
      2
      3

      3 rows selected

      -- Should error out saying there are open connections to the database

      ij(CONNB)> connect 'jdbc:derby://localhost:1527/testdb;shutdown=true';
      ERROR 08006: DERBY SQL error: SQLCODE: -1, SQLSTATE: 08006, SQLERRMC: Database 'testdb' shutdown.
      ij(CONNB)> disconnect;

      --Connection A is still open

      ij> show connections;
      CONNA - jdbc:derby://localhost:1527/testdb;create=true
      No current connection

      --Set connection to connection A

      ij> set connection connA;

      --Try a sql

      ij> select * from t;
      ERROR 58009: A network protocol error was encountered and the connection has been terminated: the requested command encountered an unarchitected and implementation-specific condition for which there was no architected message
      ij>

      This issue kind of exists in embeddded also but since the database was booted in the same JVM, one can argue there is more control on the connections made to the database from the current JVM. In embedded the ''shutdown=true' closes all active connections to the database.

      ij(CONNB)> connect 'jdbc:derby:testdb;shutdown=true';
      ERROR 08006: Database 'testdb' shutdown.
      ij(CONNB)> disconnect;

      -- Shows no current connections after a shutdown

      ij> show connections;
      No current connection
      ij> set connection connA;
      IJ ERROR: No connection exists with the name CONNA
      ij> select * from t;
      IJ ERROR: Unable to establish connection
      ij>

      Attachments

        1. ASF.LICENSE.NOT.GRANTED--shutdown.sql
          0.4 kB
          Rajesh Kartha
        2. ASF.LICENSE.NOT.GRANTED--shutdown_embed.sql
          0.4 kB
          Rajesh Kartha

        Issue Links

          Activity

            People

              Unassigned Unassigned
              kartha Rajesh Kartha
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated: