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 Oskar Zinger <os...@yahoo.com> on 2013/02/26 15:44:54 UTC
Finding a role of Derby pair in Replication (Master or Slave)
Is there a way to find out if a replicating pair of Derby is either master or slave? Or if the derby pair is participating in replication (mode)?
It would be nice to have a way to find out a role and if its in replicating mode.
This would be useful and easy way to determine which stopMaster=true or stopSlave=true attribute to use.
Thanks,
Oskar
Re: Finding a role of Derby pair in Replication (Master or Slave)
Posted by Oskar Zinger <os...@yahoo.com>.
hi Dag,
Thanks for reply.
Currently what I do is the following, in nested try / catch blocks:
I try to execute stopMaster=true which will either work, or will give me an SQL Exception:
Error Code: '0', SQL State Code: 'XRE07' and Exception: 'java.sql.SQLException: Could not perform operation because the database is not in replication master mode.'
I then try to execute stopSlave=true which will either work, or will give me an SQL Exception:
Error Code: '0', SQL State Code: 'XRE40' and Exception: 'java.sql.SQLException: Could not perform operation because the database is not in replication slave mode.'
or
Error Code: '40000', SQL State Code: 'XRE41' and Exception: 'java.sql.SQLException: Replication operation 'failover' or 'stopSlave' refused on the slave database because the connection with the master is working. Issue the 'failover' or 'stopMaster' operation on the master database instead.'
I then try to execute remote call stopMaster=true which will either work, or will give me an SQL Exception:
Error Code: '0', SQL State Code: 'XRE07' and Exception: 'java.sql.SQLException: Could not perform operation because the database is not in replication master mode.'
or
Error Code: '40000', SQL State Code: '08001' and Exception: 'java.sql.SQLNonTransientConnectionException: java.net.ConnectException : Error connecting to server romelab.it.ibm.com on port 1527 with message Connection refused.'
I also execute remote call stopSlave=true, which probably will never get executed anyway.
So this approach seems to work reliably.
Regards,
Oskar
________________________________
From: Dag Wanvik <da...@oracle.com>
To: derby-dev@db.apache.org
Sent: Tuesday, February 26, 2013 10:37 PM
Subject: Re: Finding a role of Derby pair in Replication (Master or Slave)
The replication feature in Derby is pretty much bare bones still. I don't believe there is an easy API to enquire about the
state as you request. I think you should be able to detect if the
slave has failed over, by seeing you can now connect to it (when it
is still a slave it isn't fully booted an normal connection attempt
will fail).
As for an active Derby db instance being master, I think you can
inspect the log file to detect that state. Trying a startMaster
would fail if it is already a master, but that could have side
effects you don't want of course.
Hope this helps,
Dag
On 27.02.2013 00:44, Oskar Zinger wrote:
Is there a way to find out if a replicating pair of Derby is either master or slave? Or if the derby pair is participating in replication (mode)?
>
>
>It would be nice to have a way to find out a role and if its in replicating mode.
>
>
>This would be useful and easy way to determine which stopMaster=true or stopSlave=true attribute to use.
>
>
>
>Thanks,
>Oskar
>
Re: Finding a role of Derby pair in Replication (Master or Slave)
Posted by Dag Wanvik <da...@oracle.com>.
The replication feature in Derby is pretty much bare bones still. I
don't believe there is an easy API to enquire about the
state as you request. I think you should be able to detect if the slave
has failed over, by seeing you can now connect to it (when it is still a
slave it isn't fully booted an normal connection attempt will fail).
As for an active Derby db instance being master, I think you can inspect
the log file to detect that state. Trying a startMaster would fail if it
is already a master, but that could have side effects you don't want of
course.
Hope this helps,
Dag
On 27.02.2013 00:44, Oskar Zinger wrote:
> Is there a way to find out if a replicating pair of Derby is either
> master or slave? Or if the derby pair is participating in replication
> (mode)?
>
> It would be nice to have a way to find out a role and if its in
> replicating mode.
>
> This would be useful and easy way to determine which stopMaster=true
> or stopSlave=true attribute to use.
>
> Thanks,
> Oskar