You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "V.Narayanan (JIRA)" <ji...@apache.org> on 2008/01/30 10:48:34 UTC

[jira] Created: (DERBY-3364) Replication failover implementation must be modified to fail at the master after slave has been stopped

Replication failover implementation must be modified to fail at the master after slave has been stopped
-------------------------------------------------------------------------------------------------------

                 Key: DERBY-3364
                 URL: https://issues.apache.org/jira/browse/DERBY-3364
             Project: Derby
          Issue Type: Bug
          Components: Replication
            Reporter: V.Narayanan


Jorgen says...

I tried to run the failover command on the master, which seems to work fine as long as the master and slave are still connected. If the slave has been stopped for some reason, however, failover hangs on MasterController#startFailover here: 
ack = transmitter.readMessage();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3364) Replication failover implementation must be modified to fail at the master after slave has been stopped

Posted by "V.Narayanan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3364?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

V.Narayanan updated DERBY-3364:
-------------------------------

    Attachment: Derby3364_v2.stat
                Derby3364_v2.diff

Changes from v1 of the patch submitted
---------------------------------------

java/engine/org/apache/derby/impl/services/replication/net/ReplicationMessageTransmit.java

* The tearDown() method is already present

java/engine/org/apache/derby/impl/services/replication/master/MasterController.java

* I assumed that stopping the log shipper would also tearDown the network associated
  with it. But I guess it is OK to use the tearDown method that is part of the MasterController.
  Each call of logShipper.stopLogShipment(); in the submitted patch will be followed by
  a teardownNetwork call.

java/engine/org/apache/derby/impl/services/replication/master/AsynchronousLogShipper.java

* stopLogShipment() will no longer call tearDown

-----------------------------------------------
I ran the repro in client/server and it seemed to work fine for me.

ij version 10.4
ij> connect 'jdbc:derby://localhost:1527/replicationdb';
ij> connect 'jdbc:derby://localhost:1527/replicationdb;startMaster=true;slaveHost=localhost;slavePort=8001';

Stopped slave here

ij(CONNECTION1)>  connect 'jdbc:derby://localhost:1527/replicationdb;failover=true';
ERROR XRE21: DERBY SQL error: SQLCODE: -1, SQLSTATE: XRE21, SQLERRMC: replicationdbXRE21
ij(CONNECTION1)>

> Replication failover implementation must be modified to fail at the master after slave has been stopped
> -------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3364
>                 URL: https://issues.apache.org/jira/browse/DERBY-3364
>             Project: Derby
>          Issue Type: Bug
>          Components: Replication
>    Affects Versions: 10.4.0.0
>            Reporter: V.Narayanan
>            Assignee: V.Narayanan
>         Attachments: Derby3364_v1.diff, Derby3364_v1.stat, Derby3364_v2.diff, Derby3364_v2.stat
>
>
> Jorgen says...
> I tried to run the failover command on the master, which seems to work fine as long as the master and slave are still connected. If the slave has been stopped for some reason, however, failover hangs on MasterController#startFailover here: 
> ack = transmitter.readMessage();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (DERBY-3364) Replication failover implementation must be modified to fail at the master after slave has been stopped

Posted by "V.Narayanan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3364?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

V.Narayanan closed DERBY-3364.
------------------------------


> Replication failover implementation must be modified to fail at the master after slave has been stopped
> -------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3364
>                 URL: https://issues.apache.org/jira/browse/DERBY-3364
>             Project: Derby
>          Issue Type: Bug
>          Components: Replication
>    Affects Versions: 10.4.0.0
>            Reporter: V.Narayanan
>            Assignee: V.Narayanan
>             Fix For: 10.4.0.0
>
>         Attachments: Derby3364_v1.diff, Derby3364_v1.stat, Derby3364_v2.diff, Derby3364_v2.stat, Derby3364_v3.diff, Derby3364_v3.stat, Derby3364_v4.diff, Derby3364_v4.stat
>
>
> Jorgen says...
> I tried to run the failover command on the master, which seems to work fine as long as the master and slave are still connected. If the slave has been stopped for some reason, however, failover hangs on MasterController#startFailover here: 
> ack = transmitter.readMessage();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3364) Replication failover implementation must be modified to fail at the master after slave has been stopped

Posted by "V.Narayanan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12572069#action_12572069 ] 

V.Narayanan commented on DERBY-3364:
------------------------------------

teardownNetwork does a log shipper shutdown too. In the attached patch the
log shipper is being shutdown everytime and then we call a teardownNetwork.
This was unnecessary, we could have called teardownNetwork directly.

Nit Picking: since the teardownNetwork does more than tearing down the
network, can't we just call it tearDown() ?

> Replication failover implementation must be modified to fail at the master after slave has been stopped
> -------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3364
>                 URL: https://issues.apache.org/jira/browse/DERBY-3364
>             Project: Derby
>          Issue Type: Bug
>          Components: Replication
>    Affects Versions: 10.4.0.0
>            Reporter: V.Narayanan
>            Assignee: V.Narayanan
>         Attachments: Derby3364_v1.diff, Derby3364_v1.stat, Derby3364_v2.diff, Derby3364_v2.stat
>
>
> Jorgen says...
> I tried to run the failover command on the master, which seems to work fine as long as the master and slave are still connected. If the slave has been stopped for some reason, however, failover hangs on MasterController#startFailover here: 
> ack = transmitter.readMessage();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (DERBY-3364) Replication failover implementation must be modified to fail at the master after slave has been stopped

Posted by "V.Narayanan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3364?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

V.Narayanan resolved DERBY-3364.
--------------------------------

       Resolution: Fixed
    Fix Version/s: 10.4.0.0

All relevant patches have been committed! Resolving issue!

> Replication failover implementation must be modified to fail at the master after slave has been stopped
> -------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3364
>                 URL: https://issues.apache.org/jira/browse/DERBY-3364
>             Project: Derby
>          Issue Type: Bug
>          Components: Replication
>    Affects Versions: 10.4.0.0
>            Reporter: V.Narayanan
>            Assignee: V.Narayanan
>             Fix For: 10.4.0.0
>
>         Attachments: Derby3364_v1.diff, Derby3364_v1.stat, Derby3364_v2.diff, Derby3364_v2.stat, Derby3364_v3.diff, Derby3364_v3.stat, Derby3364_v4.diff, Derby3364_v4.stat
>
>
> Jorgen says...
> I tried to run the failover command on the master, which seems to work fine as long as the master and slave are still connected. If the slave has been stopped for some reason, however, failover hangs on MasterController#startFailover here: 
> ack = transmitter.readMessage();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (DERBY-3364) Replication failover implementation must be modified to fail at the master after slave has been stopped

Posted by "V.Narayanan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12571136#action_12571136 ] 

narayanan edited comment on DERBY-3364 at 2/21/08 10:41 AM:
--------------------------------------------------------------

Thank you for the ctrl+c tip Jorgen. 

Pls find below the changes to the files explained and also the run of 
the attached repro.

General Failure Analysis
-------------------------------------- 

There was a lot of discrepancy I observed in the runs.

1) Failover succeeds the first time saying it was successful
2) Failover hangs the second time it is called
3) exit hangs after the first Failover

These were due to a combination of reasons,

a) The read on the InputStream obtained in the client socket was not
   timing out
b) The Transmitter should close the socket when a failover is successful or
   unsuccessful. (This is a client socket, I am not sure it was a big problem)
c) The log shipper thread should be terminate upon failover failure or success.

Files Modified and Explanation
-----------------------------------------------

M      java/engine/org/apache/derby/impl/services/replication/net/ReplicationMessageTransmit.java

* Set a timeout on the socket that is translated as a timeout on the reads on the
  I/P streams
* Add method to tear down the socket obtained.

M      java/engine/org/apache/derby/impl/services/replication/master/MasterController.java

* handle the IOException being thrown from stopLogShipment because of the exception thrown
  by tearDown.
* The log shipper needs to be stopped when failover fails also inaddition to being stopped
  upon a success.

M      java/engine/org/apache/derby/impl/services/replication/master/AsynchronousLogShipper.java

* Make the log shipper tear down the socket and the streams obtained from the socket.

Repro Runs
-------------------

Embedded
--------

ij version 10.4
ij> connect 'jdbc:derby:masterDB;user=oystein;password=pass;create=true';
ij> call syscs_util.syscs_freeze_database(); 
0 rows inserted/updated/deleted
ij> connect 'jdbc:derby:masterDB;user=oystein;password=pass;startMaster=true;slaveHost=localhost'; 

Did a ctrl+c on slave here

ij(CONNECTION1)> connect 'jdbc:derby:masterDB;user=oystein;password=pass;failover=true'; 
ERROR XRE21: Error occurred while performing failover for database 'masterDB', Failover attempt was aborted.
ij(CONNECTION1)> exit;

Client
------

ij version 10.4
ij> connect 'jdbc:derby://localhost:1527/replicationdb';
ij> connect 'jdbc:derby://localhost:1527/replicationdb;startMaster=true;slaveHost=localhost;slavePort=8001';

Did a ctrl + c on slave here

ij(CONNECTION1)> connect 'jdbc:derby://localhost:1527/replicationdb;failover=true';
ERROR XRE21: DERBY SQL error: SQLCODE: -1, SQLSTATE: XRE21, SQLERRMC: replicationdbXRE21
ij(CONNECTION1)> exit;

This patch will clash with Derby-3428. The patch that is committed first
will break the other.

      was (Author: narayanan):
    Thank you for the ctrl+c clip Jorgen. 

Pls find below the changes to the files explained and also the run of 
the attached repro. 

There was a lot of discrepancy I observed in the runs.

1) Failover succeeds the first time saying it was successful
2) Failover hangs the second time it is called
3) exit hangs after the first Failover

These were due to a combination of reasons,

a) The read on the InputStream obtained in the client socket was not
   timing out
b) The Transmitter should close the socket when a failover is successful or
   unsuccessful. (This is a client socket, I am not sure it was a big problem)
c) The log shipper thread should be terminate upon failover failure or success.

M      java/engine/org/apache/derby/impl/services/replication/net/ReplicationMessageTransmit.java

* Set a timeout on the socket that is translated as a timeout on the reads on the
  I/P streams
* Add method to tear down the socket obtained.

M      java/engine/org/apache/derby/impl/services/replication/master/MasterController.java

* handle the IOException being thrown from stopLogShipment because of the exception thrown
  by tearDown.
* The log shipper needs to be stopped when failover fails also inaddition to being stopped
  upon a success.

M      java/engine/org/apache/derby/impl/services/replication/master/AsynchronousLogShipper.java

* Make the log shipper tear down the socket and the streams obtained from the socket.

Embedded
--------

ij version 10.4
ij> connect 'jdbc:derby:masterDB;user=oystein;password=pass;create=true';
ij> call syscs_util.syscs_freeze_database(); 
0 rows inserted/updated/deleted
ij> connect 'jdbc:derby:masterDB;user=oystein;password=pass;startMaster=true;slaveHost=localhost'; 

Did a ctrl+c on slave here

ij(CONNECTION1)> connect 'jdbc:derby:masterDB;user=oystein;password=pass;failover=true'; 
ERROR XRE21: Error occurred while performing failover for database 'masterDB', Failover attempt was aborted.
ij(CONNECTION1)> exit;

Client
------

ij version 10.4
ij> connect 'jdbc:derby://localhost:1527/replicationdb';
ij> connect 'jdbc:derby://localhost:1527/replicationdb;startMaster=true;slaveHost=localhost;slavePort=8001';

Did a ctrl + c on slave here

ij(CONNECTION1)> connect 'jdbc:derby://localhost:1527/replicationdb;failover=true';
ERROR XRE21: DERBY SQL error: SQLCODE: -1, SQLSTATE: XRE21, SQLERRMC: replicationdbXRE21
ij(CONNECTION1)> exit;

This patch will clash with Derby-3428. The patch that is committed first
will break the other.
  
> Replication failover implementation must be modified to fail at the master after slave has been stopped
> -------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3364
>                 URL: https://issues.apache.org/jira/browse/DERBY-3364
>             Project: Derby
>          Issue Type: Bug
>          Components: Replication
>    Affects Versions: 10.4.0.0
>            Reporter: V.Narayanan
>            Assignee: V.Narayanan
>         Attachments: Derby3364_v1.diff, Derby3364_v1.stat
>
>
> Jorgen says...
> I tried to run the failover command on the master, which seems to work fine as long as the master and slave are still connected. If the slave has been stopped for some reason, however, failover hangs on MasterController#startFailover here: 
> ack = transmitter.readMessage();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3364) Replication failover implementation must be modified to fail at the master after slave has been stopped

Posted by "V.Narayanan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12572011#action_12572011 ] 

V.Narayanan commented on DERBY-3364:
------------------------------------

I noticed that the tearDown method is already there in ReplicationMessageTransmit.
So the tearDown method is not needed in this patch. I will be resubmitting this patch.
I request the patch  Derby3364_v1.diff to be please ignored.

> Replication failover implementation must be modified to fail at the master after slave has been stopped
> -------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3364
>                 URL: https://issues.apache.org/jira/browse/DERBY-3364
>             Project: Derby
>          Issue Type: Bug
>          Components: Replication
>    Affects Versions: 10.4.0.0
>            Reporter: V.Narayanan
>            Assignee: V.Narayanan
>         Attachments: Derby3364_v1.diff, Derby3364_v1.stat
>
>
> Jorgen says...
> I tried to run the failover command on the master, which seems to work fine as long as the master and slave are still connected. If the slave has been stopped for some reason, however, failover hangs on MasterController#startFailover here: 
> ack = transmitter.readMessage();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3364) Replication failover implementation must be modified to fail at the master after slave has been stopped

Posted by "V.Narayanan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12569796#action_12569796 ] 

V.Narayanan commented on DERBY-3364:
------------------------------------

Yes I did, I remember getting a connection lost message, I will try this once again since you have pointed this out

> Replication failover implementation must be modified to fail at the master after slave has been stopped
> -------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3364
>                 URL: https://issues.apache.org/jira/browse/DERBY-3364
>             Project: Derby
>          Issue Type: Bug
>          Components: Replication
>    Affects Versions: 10.4.0.0
>            Reporter: V.Narayanan
>            Assignee: V.Narayanan
>
> Jorgen says...
> I tried to run the failover command on the master, which seems to work fine as long as the master and slave are still connected. If the slave has been stopped for some reason, however, failover hangs on MasterController#startFailover here: 
> ack = transmitter.readMessage();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3364) Replication failover implementation must be modified to fail at the master after slave has been stopped

Posted by "V.Narayanan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12568935#action_12568935 ] 

V.Narayanan commented on DERBY-3364:
------------------------------------

In the fix explained above I used the same timeout value that is used
to timeout a connection attempt to the running slave.

> Replication failover implementation must be modified to fail at the master after slave has been stopped
> -------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3364
>                 URL: https://issues.apache.org/jira/browse/DERBY-3364
>             Project: Derby
>          Issue Type: Bug
>          Components: Replication
>            Reporter: V.Narayanan
>            Assignee: V.Narayanan
>
> Jorgen says...
> I tried to run the failover command on the master, which seems to work fine as long as the master and slave are still connected. If the slave has been stopped for some reason, however, failover hangs on MasterController#startFailover here: 
> ack = transmitter.readMessage();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3364) Replication failover implementation must be modified to fail at the master after slave has been stopped

Posted by "Øystein Grøvlen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3364?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Øystein Grøvlen updated DERBY-3364:
-----------------------------------

    Derby Info:   (was: [Patch Available])

Thanks, Narayanan.  Patch v4 committed as revision 633045.

> Replication failover implementation must be modified to fail at the master after slave has been stopped
> -------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3364
>                 URL: https://issues.apache.org/jira/browse/DERBY-3364
>             Project: Derby
>          Issue Type: Bug
>          Components: Replication
>    Affects Versions: 10.4.0.0
>            Reporter: V.Narayanan
>            Assignee: V.Narayanan
>         Attachments: Derby3364_v1.diff, Derby3364_v1.stat, Derby3364_v2.diff, Derby3364_v2.stat, Derby3364_v3.diff, Derby3364_v3.stat, Derby3364_v4.diff, Derby3364_v4.stat
>
>
> Jorgen says...
> I tried to run the failover command on the master, which seems to work fine as long as the master and slave are still connected. If the slave has been stopped for some reason, however, failover hangs on MasterController#startFailover here: 
> ack = transmitter.readMessage();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3364) Replication failover implementation must be modified to fail at the master after slave has been stopped

Posted by "Jørgen Løland (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12570972#action_12570972 ] 

Jørgen Løland commented on DERBY-3364:
--------------------------------------

To test the fix you describe, you could modify SlaveDatabase#stopSlave to call SlaveController#stopSlave(true) instead of stopSlave(false). That will reenable stopSlave when the network connection is working. This hack is only for testing your fix, of course...

> Replication failover implementation must be modified to fail at the master after slave has been stopped
> -------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3364
>                 URL: https://issues.apache.org/jira/browse/DERBY-3364
>             Project: Derby
>          Issue Type: Bug
>          Components: Replication
>    Affects Versions: 10.4.0.0
>            Reporter: V.Narayanan
>            Assignee: V.Narayanan
>
> Jorgen says...
> I tried to run the failover command on the master, which seems to work fine as long as the master and slave are still connected. If the slave has been stopped for some reason, however, failover hangs on MasterController#startFailover here: 
> ack = transmitter.readMessage();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3364) Replication failover implementation must be modified to fail at the master after slave has been stopped

Posted by "V.Narayanan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3364?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

V.Narayanan updated DERBY-3364:
-------------------------------

    Affects Version/s: 10.4.0.0

> Replication failover implementation must be modified to fail at the master after slave has been stopped
> -------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3364
>                 URL: https://issues.apache.org/jira/browse/DERBY-3364
>             Project: Derby
>          Issue Type: Bug
>          Components: Replication
>    Affects Versions: 10.4.0.0
>            Reporter: V.Narayanan
>            Assignee: V.Narayanan
>
> Jorgen says...
> I tried to run the failover command on the master, which seems to work fine as long as the master and slave are still connected. If the slave has been stopped for some reason, however, failover hangs on MasterController#startFailover here: 
> ack = transmitter.readMessage();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (DERBY-3364) Replication failover implementation must be modified to fail at the master after slave has been stopped

Posted by "V.Narayanan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3364?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

V.Narayanan reassigned DERBY-3364:
----------------------------------

    Assignee: V.Narayanan

> Replication failover implementation must be modified to fail at the master after slave has been stopped
> -------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3364
>                 URL: https://issues.apache.org/jira/browse/DERBY-3364
>             Project: Derby
>          Issue Type: Bug
>          Components: Replication
>            Reporter: V.Narayanan
>            Assignee: V.Narayanan
>
> Jorgen says...
> I tried to run the failover command on the master, which seems to work fine as long as the master and slave are still connected. If the slave has been stopped for some reason, however, failover hangs on MasterController#startFailover here: 
> ack = transmitter.readMessage();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3364) Replication failover implementation must be modified to fail at the master after slave has been stopped

Posted by "V.Narayanan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3364?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

V.Narayanan updated DERBY-3364:
-------------------------------

    Attachment: Derby3364_v4.stat
                Derby3364_v4.diff

Moved tearDownNetwork to the finally block
of the stopMaster method.

> Replication failover implementation must be modified to fail at the master after slave has been stopped
> -------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3364
>                 URL: https://issues.apache.org/jira/browse/DERBY-3364
>             Project: Derby
>          Issue Type: Bug
>          Components: Replication
>    Affects Versions: 10.4.0.0
>            Reporter: V.Narayanan
>            Assignee: V.Narayanan
>         Attachments: Derby3364_v1.diff, Derby3364_v1.stat, Derby3364_v2.diff, Derby3364_v2.stat, Derby3364_v3.diff, Derby3364_v3.stat, Derby3364_v4.diff, Derby3364_v4.stat
>
>
> Jorgen says...
> I tried to run the failover command on the master, which seems to work fine as long as the master and slave are still connected. If the slave has been stopped for some reason, however, failover hangs on MasterController#startFailover here: 
> ack = transmitter.readMessage();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3364) Replication failover implementation must be modified to fail at the master after slave has been stopped

Posted by "V.Narayanan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3364?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

V.Narayanan updated DERBY-3364:
-------------------------------

    Derby Info: [Patch Available]

> Replication failover implementation must be modified to fail at the master after slave has been stopped
> -------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3364
>                 URL: https://issues.apache.org/jira/browse/DERBY-3364
>             Project: Derby
>          Issue Type: Bug
>          Components: Replication
>    Affects Versions: 10.4.0.0
>            Reporter: V.Narayanan
>            Assignee: V.Narayanan
>         Attachments: Derby3364_v1.diff, Derby3364_v1.stat
>
>
> Jorgen says...
> I tried to run the failover command on the master, which seems to work fine as long as the master and slave are still connected. If the slave has been stopped for some reason, however, failover hangs on MasterController#startFailover here: 
> ack = transmitter.readMessage();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3364) Replication failover implementation must be modified to fail at the master after slave has been stopped

Posted by "Øystein Grøvlen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3364?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Øystein Grøvlen updated DERBY-3364:
-----------------------------------

    Derby Info:   (was: [Patch Available])

Committed the v3 patch as revision 631534. Thanks, Narayanan for the fix.

> Replication failover implementation must be modified to fail at the master after slave has been stopped
> -------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3364
>                 URL: https://issues.apache.org/jira/browse/DERBY-3364
>             Project: Derby
>          Issue Type: Bug
>          Components: Replication
>    Affects Versions: 10.4.0.0
>            Reporter: V.Narayanan
>            Assignee: V.Narayanan
>         Attachments: Derby3364_v1.diff, Derby3364_v1.stat, Derby3364_v2.diff, Derby3364_v2.stat, Derby3364_v3.diff, Derby3364_v3.stat
>
>
> Jorgen says...
> I tried to run the failover command on the master, which seems to work fine as long as the master and slave are still connected. If the slave has been stopped for some reason, however, failover hangs on MasterController#startFailover here: 
> ack = transmitter.readMessage();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3364) Replication failover implementation must be modified to fail at the master after slave has been stopped

Posted by "V.Narayanan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3364?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

V.Narayanan updated DERBY-3364:
-------------------------------

    Derby Info: [Patch Available]

> Replication failover implementation must be modified to fail at the master after slave has been stopped
> -------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3364
>                 URL: https://issues.apache.org/jira/browse/DERBY-3364
>             Project: Derby
>          Issue Type: Bug
>          Components: Replication
>    Affects Versions: 10.4.0.0
>            Reporter: V.Narayanan
>            Assignee: V.Narayanan
>         Attachments: Derby3364_v1.diff, Derby3364_v1.stat, Derby3364_v2.diff, Derby3364_v2.stat, Derby3364_v3.diff, Derby3364_v3.stat, Derby3364_v4.diff, Derby3364_v4.stat
>
>
> Jorgen says...
> I tried to run the failover command on the master, which seems to work fine as long as the master and slave are still connected. If the slave has been stopped for some reason, however, failover hangs on MasterController#startFailover here: 
> ack = transmitter.readMessage();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3364) Replication failover implementation must be modified to fail at the master after slave has been stopped

Posted by "Øystein Grøvlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12572851#action_12572851 ] 

Øystein Grøvlen commented on DERBY-3364:
----------------------------------------

I have tested that patch v3 fixes the reported problem, and the patch looks good so I will commit it.

However, I think there is still a case in MasterController where teardownNetwork() needs to be called:
If the call to flushBuffer in stopMaster fails, teardownNetwork() is not called.  Is this covered by another JIRA?

> Replication failover implementation must be modified to fail at the master after slave has been stopped
> -------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3364
>                 URL: https://issues.apache.org/jira/browse/DERBY-3364
>             Project: Derby
>          Issue Type: Bug
>          Components: Replication
>    Affects Versions: 10.4.0.0
>            Reporter: V.Narayanan
>            Assignee: V.Narayanan
>         Attachments: Derby3364_v1.diff, Derby3364_v1.stat, Derby3364_v2.diff, Derby3364_v2.stat, Derby3364_v3.diff, Derby3364_v3.stat
>
>
> Jorgen says...
> I tried to run the failover command on the master, which seems to work fine as long as the master and slave are still connected. If the slave has been stopped for some reason, however, failover hangs on MasterController#startFailover here: 
> ack = transmitter.readMessage();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3364) Replication failover implementation must be modified to fail at the master after slave has been stopped

Posted by "V.Narayanan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3364?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

V.Narayanan updated DERBY-3364:
-------------------------------

    Attachment: Derby3364_v3.stat
                Derby3364_v3.diff

This patch uses only teardownNetwork and does not shutdown the
log shipper seperately.

> Replication failover implementation must be modified to fail at the master after slave has been stopped
> -------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3364
>                 URL: https://issues.apache.org/jira/browse/DERBY-3364
>             Project: Derby
>          Issue Type: Bug
>          Components: Replication
>    Affects Versions: 10.4.0.0
>            Reporter: V.Narayanan
>            Assignee: V.Narayanan
>         Attachments: Derby3364_v1.diff, Derby3364_v1.stat, Derby3364_v2.diff, Derby3364_v2.stat, Derby3364_v3.diff, Derby3364_v3.stat
>
>
> Jorgen says...
> I tried to run the failover command on the master, which seems to work fine as long as the master and slave are still connected. If the slave has been stopped for some reason, however, failover hangs on MasterController#startFailover here: 
> ack = transmitter.readMessage();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3364) Replication failover implementation must be modified to fail at the master after slave has been stopped

Posted by "V.Narayanan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3364?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

V.Narayanan updated DERBY-3364:
-------------------------------

    Attachment: Derby3364_v1.stat
                Derby3364_v1.diff

Thank you for the ctrl+c clip Jorgen. 

Pls find below the changes to the files explained and also the run of 
the attached repro. 

There was a lot of discrepancy I observed in the runs.

1) Failover succeeds the first time saying it was successful
2) Failover hangs the second time it is called
3) exit hangs after the first Failover

These were due to a combination of reasons,

a) The read on the InputStream obtained in the client socket was not
   timing out
b) The Transmitter should close the socket when a failover is successful or
   unsuccessful. (This is a client socket, I am not sure it was a big problem)
c) The log shipper thread should be terminate upon failover failure or success.

M      java/engine/org/apache/derby/impl/services/replication/net/ReplicationMessageTransmit.java

* Set a timeout on the socket that is translated as a timeout on the reads on the
  I/P streams
* Add method to tear down the socket obtained.

M      java/engine/org/apache/derby/impl/services/replication/master/MasterController.java

* handle the IOException being thrown from stopLogShipment because of the exception thrown
  by tearDown.
* The log shipper needs to be stopped when failover fails also inaddition to being stopped
  upon a success.

M      java/engine/org/apache/derby/impl/services/replication/master/AsynchronousLogShipper.java

* Make the log shipper tear down the socket and the streams obtained from the socket.

Embedded
--------

ij version 10.4
ij> connect 'jdbc:derby:masterDB;user=oystein;password=pass;create=true';
ij> call syscs_util.syscs_freeze_database(); 
0 rows inserted/updated/deleted
ij> connect 'jdbc:derby:masterDB;user=oystein;password=pass;startMaster=true;slaveHost=localhost'; 

Did a ctrl+c on slave here

ij(CONNECTION1)> connect 'jdbc:derby:masterDB;user=oystein;password=pass;failover=true'; 
ERROR XRE21: Error occurred while performing failover for database 'masterDB', Failover attempt was aborted.
ij(CONNECTION1)> exit;

Client
------

ij version 10.4
ij> connect 'jdbc:derby://localhost:1527/replicationdb';
ij> connect 'jdbc:derby://localhost:1527/replicationdb;startMaster=true;slaveHost=localhost;slavePort=8001';

Did a ctrl + c on slave here

ij(CONNECTION1)> connect 'jdbc:derby://localhost:1527/replicationdb;failover=true';
ERROR XRE21: DERBY SQL error: SQLCODE: -1, SQLSTATE: XRE21, SQLERRMC: replicationdbXRE21
ij(CONNECTION1)> exit;

This patch will clash with Derby-3428. The patch that is committed first
will break the other.

> Replication failover implementation must be modified to fail at the master after slave has been stopped
> -------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3364
>                 URL: https://issues.apache.org/jira/browse/DERBY-3364
>             Project: Derby
>          Issue Type: Bug
>          Components: Replication
>    Affects Versions: 10.4.0.0
>            Reporter: V.Narayanan
>            Assignee: V.Narayanan
>         Attachments: Derby3364_v1.diff, Derby3364_v1.stat
>
>
> Jorgen says...
> I tried to run the failover command on the master, which seems to work fine as long as the master and slave are still connected. If the slave has been stopped for some reason, however, failover hangs on MasterController#startFailover here: 
> ack = transmitter.readMessage();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3364) Replication failover implementation must be modified to fail at the master after slave has been stopped

Posted by "V.Narayanan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12568934#action_12568934 ] 

V.Narayanan commented on DERBY-3364:
------------------------------------

Now the stopSlave on a slave when the connection is active will fail saying that
the connection with the master is still active. I was earlier using this particular
situation as the reproducible

1) Start Slave
2) start master
3) execute a few transactions on the master (a few inserts)
4) Issue stopSlave on the slave side
5) failover on the master

This hanged for me. But after stopSlave on a active connection being disabled
I am running short of ideas to reproduce this.

With the earlier reproducible doing a setSoTimeout on the socket connection in the
Transmitter worked for me.

I please request for help in generating a reproducible in the present trunk. I can
submit a fix with the setSoTimeout if that is acceptable since logically the read
on the InputStream obtained from the socket should time out.

> Replication failover implementation must be modified to fail at the master after slave has been stopped
> -------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3364
>                 URL: https://issues.apache.org/jira/browse/DERBY-3364
>             Project: Derby
>          Issue Type: Bug
>          Components: Replication
>            Reporter: V.Narayanan
>            Assignee: V.Narayanan
>
> Jorgen says...
> I tried to run the failover command on the master, which seems to work fine as long as the master and slave are still connected. If the slave has been stopped for some reason, however, failover hangs on MasterController#startFailover here: 
> ack = transmitter.readMessage();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3364) Replication failover implementation must be modified to fail at the master after slave has been stopped

Posted by "Jørgen Løland (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12569795#action_12569795 ] 

Jørgen Løland commented on DERBY-3364:
--------------------------------------

Did you try to replace 4) with crashing the slave using Ctrl-c (if embedded)? 

> Replication failover implementation must be modified to fail at the master after slave has been stopped
> -------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3364
>                 URL: https://issues.apache.org/jira/browse/DERBY-3364
>             Project: Derby
>          Issue Type: Bug
>          Components: Replication
>            Reporter: V.Narayanan
>            Assignee: V.Narayanan
>
> Jorgen says...
> I tried to run the failover command on the master, which seems to work fine as long as the master and slave are still connected. If the slave has been stopped for some reason, however, failover hangs on MasterController#startFailover here: 
> ack = transmitter.readMessage();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.