Derby
  1. Derby
  2. DERBY-4812

ReplicationMessageTransmit run does not unwrap PrivilegedActionException which can lead to failure of replicationTests.ReplicationRun_Local_StateTest_part1_1

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 10.5.3.1
    • Fix Version/s: 10.5.3.2, 10.6.2.4, 10.7.1.1
    • Component/s: Replication
    • Labels:
      None
    • Environment:
      AIX 64 bit, IBM 1.6 jvm
    • Issue & fix info:
      Patch Available
    • Bug behavior facts:
      Regression Test Failure

      Description

      One of our nightly tests failed with the exception (db path slightly edited) below.
      Looking at the source of org.apache.derby.impl.store.replication.net.ReplicationMessageTransmit.run, it seems that the code does not completely unwrap the PrivilegedActionException (compared to how this is done in for example org.apache.derbyTesting.functionTests.util.PrivilegedFileOpsForTests.getFileInputStream()).
      It could be that the test is looking for the java.io.IOException, which it doesn't get (it gets the PrivilegedActionException instead).

      ----------------------
      1) testReplication_Local_StateTest_part1_1(org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun_Local_StateTest_part1_1)junit.framework.AssertionFailedError: Got -1 XRE42 DERBY SQL error: SQLCODE: -1, SQLSTATE: XRE42, SQLERRMC: Replicated database '/test/results/db_slave/wombat' shutdown.. Expected XRE41
      at java.lang.Throwable.<init>(Throwable.java:67)
      at junit.framework.AssertionFailedError.<init>(AssertionFailedError.java:11)
      at org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun.assertException(ReplicationRun.java:3427)
      at org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun_Local_StateTest_part1_1._testPostStartedMasterAndSlave_StopSlave(ReplicationRun_Local_StateTest_part1_1.java:150)
      at org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun_Local_StateTest_part1_1.testReplication_Local_StateTest_part1_1(ReplicationRun_Local_StateTest_part1_1.java:134)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:109)
      at org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun.runBare(ReplicationRun.java:201)
      at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
      at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
      at junit.extensions.TestSetup.run(TestSetup.java:16)
      ----------------------

      The exception in the db_master-derby.log was:

      ------------------------
      Database Class Loader started - derby.database.classpath=''
      ---- BEGIN REPLICATION ERROR MESSAGE (9/13/10 9:40 AM) ----
      Replication slave got a fatal error for database '/test/results/db_master/wombat'. Replication will be stopped.
      ERROR XRE04: Could not establish a connection to the peer of the replicated database '/test/results/db_master/wombat' on address 'localhost:8888'.
      at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
      at org.apache.derby.impl.store.replication.master.MasterController.setupConnection(Unknown Source)
      at org.apache.derby.impl.store.replication.master.MasterController.startMaster(Unknown Source)
      at org.apache.derby.impl.store.raw.RawStore.startReplicationMaster(Unknown Source)
      at org.apache.derby.impl.store.access.RAMAccessManager.startReplicationMaster(Unknown Source)
      at org.apache.derby.impl.db.BasicDatabase.startReplicationMaster(Unknown Source)
      at org.apache.derby.impl.jdbc.EmbedConnection.handleStartReplicationMaster(Unknown Source)
      at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
      at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Unknown Source)
      at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
      at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
      at org.apache.derby.impl.drda.Database.makeConnection(Unknown Source)
      at org.apache.derby.impl.drda.DRDAConnThread.getConnFromDatabaseName(Unknown Source)
      at org.apache.derby.impl.drda.DRDAConnThread.verifyUserIdPassword(Unknown Source)
      at org.apache.derby.impl.drda.DRDAConnThread.parseSECCHK(Unknown Source)
      at org.apache.derby.impl.drda.DRDAConnThread.parseDRDAConnection(Unknown Source)
      at org.apache.derby.impl.drda.DRDAConnThread.processCommands(Unknown Source)
      at org.apache.derby.impl.drda.DRDAConnThread.run(Unknown Source)
      Caused by: java.security.PrivilegedActionException: java.net.ConnectException: Connection refused
      at java.security.AccessController.doPrivileged(AccessController.java:255)
      at org.apache.derby.impl.store.replication.net.ReplicationMessageTransmit.initConnection(Unknown Source)
      ... 17 more
      Caused by: java.net.ConnectException: Connection refused
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:352)
      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:214)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:201)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:378)
      at java.net.Socket.connect(Socket.java:528)
      at org.apache.derby.impl.store.replication.net.ReplicationMessageTransmit$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(AccessController.java:251)
      ... 18 more
      ============= begin nested exception, level (1) ===========
      java.security.PrivilegedActionException: java.net.ConnectException: Connection refused
      at java.security.AccessController.doPrivileged(AccessController.java:255)
      at org.apache.derby.impl.store.replication.net.ReplicationMessageTransmit.initConnection(Unknown Source)
      at org.apache.derby.impl.store.replication.master.MasterController.setupConnection(Unknown Source)
      at org.apache.derby.impl.store.replication.master.MasterController.startMaster(Unknown Source)
      at org.apache.derby.impl.store.raw.RawStore.startReplicationMaster(Unknown Source)
      at org.apache.derby.impl.store.access.RAMAccessManager.startReplicationMaster(Unknown Source)
      at org.apache.derby.impl.db.BasicDatabase.startReplicationMaster(Unknown Source)
      at org.apache.derby.impl.jdbc.EmbedConnection.handleStartReplicationMaster(Unknown Source)
      at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
      at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Unknown Source)
      at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
      at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
      at org.apache.derby.impl.drda.Database.makeConnection(Unknown Source)
      at org.apache.derby.impl.drda.DRDAConnThread.getConnFromDatabaseName(Unknown Source)
      at org.apache.derby.impl.drda.DRDAConnThread.verifyUserIdPassword(Unknown Source)
      at org.apache.derby.impl.drda.DRDAConnThread.parseSECCHK(Unknown Source)
      at org.apache.derby.impl.drda.DRDAConnThread.parseDRDAConnection(Unknown Source)
      at org.apache.derby.impl.drda.DRDAConnThread.processCommands(Unknown Source)
      at org.apache.derby.impl.drda.DRDAConnThread.run(Unknown Source)
      Caused by: java.net.ConnectException: Connection refused
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:352)
      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:214)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:201)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:378)
      at java.net.Socket.connect(Socket.java:528)
      at org.apache.derby.impl.store.replication.net.ReplicationMessageTransmit$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(AccessController.java:251)
      ... 18 more
      ============= end nested exception, level (1) ===========
      ============= begin nested exception, level (2) ===========
      java.net.ConnectException: Connection refused
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:352)
      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:214)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:201)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:378)
      at java.net.Socket.connect(Socket.java:528)
      at org.apache.derby.impl.store.replication.net.ReplicationMessageTransmit$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(AccessController.java:251)
      at org.apache.derby.impl.store.replication.net.ReplicationMessageTransmit.initConnection(Unknown Source)
      at org.apache.derby.impl.store.replication.master.MasterController.setupConnection(Unknown Source)
      at org.apache.derby.impl.store.replication.master.MasterController.startMaster(Unknown Source)
      at org.apache.derby.impl.store.raw.RawStore.startReplicationMaster(Unknown Source)
      at org.apache.derby.impl.store.access.RAMAccessManager.startReplicationMaster(Unknown Source)
      at org.apache.derby.impl.db.BasicDatabase.startReplicationMaster(Unknown Source)
      at org.apache.derby.impl.jdbc.EmbedConnection.handleStartReplicationMaster(Unknown Source)
      at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
      at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Unknown Source)
      at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
      at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
      at org.apache.derby.impl.drda.Database.makeConnection(Unknown Source)
      at org.apache.derby.impl.drda.DRDAConnThread.getConnFromDatabaseName(Unknown Source)
      at org.apache.derby.impl.drda.DRDAConnThread.verifyUserIdPassword(Unknown Source)
      at org.apache.derby.impl.drda.DRDAConnThread.parseSECCHK(Unknown Source)
      at org.apache.derby.impl.drda.DRDAConnThread.parseDRDAConnection(Unknown Source)
      at org.apache.derby.impl.drda.DRDAConnThread.processCommands(Unknown Source)
      at org.apache.derby.impl.drda.DRDAConnThread.run(Unknown Source)
      ============= end nested exception, level (2) ===========

      1. derby-4812-2_diff.txt
        8 kB
        Lily Wei
      2. derby-4812_diff.txt
        7 kB
        Kathey Marsden
      3. derby-4812_diff.txt
        7 kB
        Kathey Marsden
      4. derby-4812_diff.txt
        7 kB
        Kathey Marsden
      5. derby-4812_diff.txt
        7 kB
        Kathey Marsden

        Issue Links

          Activity

          Myrna van Lunteren created issue -
          Kathey Marsden made changes -
          Field Original Value New Value
          Assignee Kathey Marsden [ kmarsden ]
          Hide
          Kathey Marsden added a comment -

          Here is a patch for this issue. The replication tests passed and I will run the full suite now. i see other instances PrivilegeActionException being thrown, especially in PlanExporter. I will file another issue for that.

          Show
          Kathey Marsden added a comment - Here is a patch for this issue. The replication tests passed and I will run the full suite now. i see other instances PrivilegeActionException being thrown, especially in PlanExporter. I will file another issue for that.
          Kathey Marsden made changes -
          Attachment derby-4812_diff.txt [ 12455388 ]
          Kathey Marsden made changes -
          Issue & fix info [Patch Available]
          Hide
          Knut Anders Hatlen added a comment -

          Hi Kathey,

          Perhaps you could remove PrivilegedActionException from the method's throws clause too? I mean from the method signature, not only from the javadoc.

          And one nit: It looks like the patch mixes tabs and spaces, sometimes even on the same line. This class is a tab-free one, it would be good to keep it that way.

          Show
          Knut Anders Hatlen added a comment - Hi Kathey, Perhaps you could remove PrivilegedActionException from the method's throws clause too? I mean from the method signature, not only from the javadoc. And one nit: It looks like the patch mixes tabs and spaces, sometimes even on the same line. This class is a tab-free one, it would be good to keep it that way.
          Hide
          Kathey Marsden added a comment -

          Thanks Knut, here is the revised patch. I will commit in a bit.

          Show
          Kathey Marsden added a comment - Thanks Knut, here is the revised patch. I will commit in a bit.
          Kathey Marsden made changes -
          Attachment derby-4812_diff.txt [ 12455427 ]
          Hide
          Knut Anders Hatlen added a comment -

          Thanks Kathey. Looks like there's still a mix of tabs and spaces in ReplicationMessageReceive, though.

          Show
          Knut Anders Hatlen added a comment - Thanks Kathey. Looks like there's still a mix of tabs and spaces in ReplicationMessageReceive, though.
          Hide
          Kathey Marsden added a comment -

          Sorry for the trouble. one more try. I went back to emacs to double check. Hopefully all those nasty tabs are really gone this time and my Eclipse is properly positioned for next time. Apparently I lost my setup when I upgraded eclipse and had to use the following tip from Lily.
          right click you mouse and choose preference
          <lilywei> In the General->Editor->Text Editors->choose insert spaces for tabs and show whitespace characters

          Show
          Kathey Marsden added a comment - Sorry for the trouble. one more try. I went back to emacs to double check. Hopefully all those nasty tabs are really gone this time and my Eclipse is properly positioned for next time. Apparently I lost my setup when I upgraded eclipse and had to use the following tip from Lily. right click you mouse and choose preference <lilywei> In the General->Editor->Text Editors->choose insert spaces for tabs and show whitespace characters
          Kathey Marsden made changes -
          Attachment derby-4812_diff.txt [ 12455442 ]
          Hide
          Knut Anders Hatlen added a comment -

          Sorry... I get so distracted by tab/space issues that I forget to look at the code...

          + public Object run() throws IOException, StandardException

          { + ServerSocketFactory sf = ServerSocketFactory.getDefault(); + return sf.createServerSocket(slaveAddress.getPortNumber(), + 0, slaveAddress.getHostAddress()); + }

          + });
          + return ss;
          + } catch(PrivilegedActionException pea)

          { + throw (IOException) pea.getException(); + }

          Can the run() method really throw a StandardException here? (Its throws clause says it can...) If so, the catch block needs to check the type of the exception and not cast it unconditionally to IOException.

          Show
          Knut Anders Hatlen added a comment - Sorry... I get so distracted by tab/space issues that I forget to look at the code... + public Object run() throws IOException, StandardException { + ServerSocketFactory sf = ServerSocketFactory.getDefault(); + return sf.createServerSocket(slaveAddress.getPortNumber(), + 0, slaveAddress.getHostAddress()); + } + }); + return ss; + } catch(PrivilegedActionException pea) { + throw (IOException) pea.getException(); + } Can the run() method really throw a StandardException here? (Its throws clause says it can...) If so, the catch block needs to check the type of the exception and not cast it unconditionally to IOException.
          Hide
          Kathey Marsden added a comment -

          I don't see that it could and it compiles fine without it, so I think the right thing to do is to take out the throws clause, but now it is the end of my day. I will take a less hurried approach tomorrow. Thank you for your careful attention in what must be the wee hours of the morning for you.

          Show
          Kathey Marsden added a comment - I don't see that it could and it compiles fine without it, so I think the right thing to do is to take out the throws clause, but now it is the end of my day. I will take a less hurried approach tomorrow. Thank you for your careful attention in what must be the wee hours of the morning for you.
          Hide
          Lily Wei added a comment -

          Just for testing purpose, I take out the StandardException and attach patch derby-4812-2_diff.txt. The test runs inside the debugger. However, the test hangs outside the debugger in my git environment. I sync up to 1001564 and reverts all the changes. The test still hangs. I am afraid it could be my environment. Does anyone have any suggestion for me to try to fix the hanging problem?

          Show
          Lily Wei added a comment - Just for testing purpose, I take out the StandardException and attach patch derby-4812-2_diff.txt. The test runs inside the debugger. However, the test hangs outside the debugger in my git environment. I sync up to 1001564 and reverts all the changes. The test still hangs. I am afraid it could be my environment. Does anyone have any suggestion for me to try to fix the hanging problem?
          Lily Wei made changes -
          Attachment derby-4812-2_diff.txt [ 12455673 ]
          Hide
          Kathey Marsden added a comment -

          I didn't realize Lily had posted a patch, but I think I will use this one., which I tested last night.

          Show
          Kathey Marsden added a comment - I didn't realize Lily had posted a patch, but I think I will use this one., which I tested last night.
          Kathey Marsden made changes -
          Attachment derby-4812_diff.txt [ 12455852 ]
          Kathey Marsden made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 10.5.3.2 [ 12315436 ]
          Fix Version/s 10.6.2.3 [ 12315434 ]
          Fix Version/s 10.7.1.0 [ 12314971 ]
          Resolution Fixed [ 1 ]
          Rick Hillegas made changes -
          Fix Version/s 10.7.1.1 [ 12315564 ]
          Fix Version/s 10.7.1.0 [ 12314971 ]
          Myrna van Lunteren made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Knut Anders Hatlen made changes -
          Link This issue breaks DERBY-4910 [ DERBY-4910 ]
          Gavin made changes -
          Workflow jira [ 12521281 ] Default workflow, editable Closed status [ 12799758 ]

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Development