dHi,
I'm using Derby replication successfully (with v 10.4.1.3, on Solaris x86,
Java 1.5, 32 bit), but what I'm now trying to do is to automate synchronisation
between two servers (both of which are running embedded with applications).
One scenario I'm trying to cope with is where the master database has been
restarted, to stop & re-synchronize the slave database.
After the master has stopped, I'm successfully stopping the replication on
the slave by passing the stopSlave=true attribute, and getting back a XRE42 SQL
State to indicate this success.
However, after this has stopped, it would appear that derby is still
listening on the slave port (verified using netstat), so if after re-copying
the database from the master, I try & restart the slave (using
startSlave=true), I'm getting an exception due to the port already being in use:
2008-09-15 16:54:56,842 ERROR MYAPP.DB - Cannot start slave synchronization on
'MYDB'
java.sql.SQLException: Failed to start database 'MYDB', see the next exception
for details.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.seeNextException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection30.<init>(Unknown Source)
at org.apache.derby.jdbc.Driver30.getNewEmbedConnection(Unknown Source)
at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at
com.coppereye.myapp.derby.DerbyServer.getEmbeddedConnection(DerbyServer.java:912)
at com.coppereye.myapp.derby.DerbyServer.access$400(DerbyServer.java:55)
at com.coppereye.myapp.derby.DerbyServer$2.run(DerbyServer.java:1327)
Caused by: java.sql.SQLException: Could not establish a connection to the peer
of the replicated database 'MYDB' on address 'testbox:6959'.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown
Source)
... 11 more
Caused by: ERROR XRE04: Could not establish a connection to the peer of the
replicated database 'MYDB' on address 'testbox:6959'.
at org.apache.derby.iapi.error.StandardException.newException(Unknown
Source)
at
org.apache.derby.impl.store.replication.slave.SlaveController.setupConnection(Unknown
Source)
at
org.apache.derby.impl.store.replication.slave.SlaveController.startSlave(Unknown
Source)
at org.apache.derby.impl.store.raw.RawStore.boot(Unknown Source)
at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown
Source)
at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown
Source)
at
org.apache.derby.impl.services.monitor.BaseMonitor.startModule(Unknown Source)
at
org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Unknown Source)
at org.apache.derby.impl.store.access.RAMAccessManager.boot(Unknown
Source)
at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown
Source)
at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown
Source)
at
org.apache.derby.impl.services.monitor.BaseMonitor.startModule(Unknown Source)
at
org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Unknown Source)
at org.apache.derby.impl.db.BasicDatabase.bootStore(Unknown Source)
at org.apache.derby.impl.db.BasicDatabase.boot(Unknown Source)
at org.apache.derby.impl.db.SlaveDatabase.bootBasicDatabase(Unknown
Source)
at org.apache.derby.impl.db.SlaveDatabase.access$000(Unknown Source)
at
org.apache.derby.impl.db.SlaveDatabase$SlaveDatabaseBootThread.run(Unknown
Source)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.security.PrivilegedActionException: java.net.BindException:
Address already in use
at java.security.AccessController.doPrivileged(Native Method)
at
org.apache.derby.impl.store.replication.net.ReplicationMessageReceive.createServerSocket(Unknown
Source)
at
org.apache.derby.impl.store.replication.net.ReplicationMessageReceive.initConnection(Unknown
Source)
... 18 more
Caused by: java.net.BindException: Address already in use
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
at java.net.ServerSocket.bind(ServerSocket.java:319)
at java.net.ServerSocket.<init>(ServerSocket.java:185)
at
javax.net.DefaultServerSocketFactory.createServerSocket(ServerSocketFactory.java:169)
at
org.apache.derby.impl.store.replication.net.ReplicationMessageReceive$2.run(Unknown
Source)
... 21 more
Is this something that ought to work? - or in this scenario would I need to
restart derby completely?
many thanks in advance for any advice.
Andrew Lawrenson