I'm using SymmetricClient in embedded mode, with embedded Derby database. Synchronization is mosty working, but I have trouble when client nodes come online after the given 'offline.node.detection.period.minutes'.
The server is disabling the sync on nodes when 'offline.node.detection.period.minutes' expires, which is just perfect.
On clients DefaultOfflineClientListener deletes NODE_IDENTITY in order to induce re-registration, which is also perfect.
But when the DataLoaderService is loading the virtual batch 9999, deleting from SYM_NODE causing violation of foreign key constraint 'SYM_FK_SEC_2_NODE'.
I've found out the possible cause of it, i.e. why deleting from SYM_NODE_SECURITY is not done beforehand. Symmetric is using the following SQL for that: delete from sym_node_security where created_at_node_id='server',
while in the database the CREATED_AT_NODE_ID contains the client node id, not the server node id. It's a bit strange, as the column with the same name in SYM_NODE table contains server node id!
Why is it so? What can I do to make the re-registration of clients work?
Thanks!
The logs:
2017-05-24 08:25:01,448 ERROR org.jumpmind.symmetric.io.data.writer.DefaultDatabaseWriter:547 - Failed to run the following sql: delete from sym_node where created_at_node_id='server'
2017-05-24 08:25:01,510 ERROR org.jumpmind.symmetric.service.impl.DataLoaderService$ManageIncomingBatchListener:1146 - Failed to load batch server--9999
org.jumpmind.db.sql.SqlException: DELETE on table 'SYM_NODE' caused a violation of foreign key constraint 'SYM_FK_SEC_2_NODE' for key (my-client-id). The statement has been rolled back.
at org.jumpmind.db.sql.AbstractSqlTemplate.translate(AbstractSqlTemplate.java:300)
at org.jumpmind.db.sql.AbstractSqlTemplate.translate(AbstractSqlTemplate.java:291)
at org.jumpmind.db.sql.JdbcSqlTransaction.executeCallback(JdbcSqlTransaction.java:406)
at org.jumpmind.db.sql.JdbcSqlTransaction.prepareAndExecute(JdbcSqlTransaction.java:372)
at org.jumpmind.symmetric.io.data.writer.DefaultDatabaseWriter.sql(DefaultDatabaseWriter.java:542)
at org.jumpmind.symmetric.io.data.writer.AbstractDatabaseWriter.write(AbstractDatabaseWriter.java:168)
at org.jumpmind.symmetric.io.data.writer.NestedDataWriter.write(NestedDataWriter.java:64)
at org.jumpmind.symmetric.model.ProcessInfoDataWriter.write(ProcessInfoDataWriter.java:65)
at org.jumpmind.symmetric.io.data.writer.NestedDataWriter.write(NestedDataWriter.java:64)
at org.jumpmind.symmetric.io.data.writer.TransformWriter.write(TransformWriter.java:207)
at org.jumpmind.symmetric.io.data.DataProcessor.forEachDataInTable(DataProcessor.java:200)
at org.jumpmind.symmetric.io.data.DataProcessor.forEachTableInBatch(DataProcessor.java:170)
at org.jumpmind.symmetric.io.data.DataProcessor.process(DataProcessor.java:116)
at org.jumpmind.symmetric.service.impl.DataLoaderService$LoadIntoDatabaseOnArrivalListener$1.call(DataLoaderService.java:975)
at org.jumpmind.symmetric.service.impl.DataLoaderService$LoadIntoDatabaseOnArrivalListener$1.call(DataLoaderService.java:950)
at java.util.concurrent.FutureTask.run(FutureTask.java:274)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1157)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:627)
at java.lang.Thread.run(Thread.java:809)
Caused by: java.sql.SQLIntegrityConstraintViolationException: DELETE on table 'SYM_NODE' caused a violation of foreign key constraint 'SYM_FK_SEC_2_NODE' for key (my-client-id). The statement has been rolled back.
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.execute(Unknown Source)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
at org.jumpmind.db.sql.JdbcSqlTransaction$6.execute(JdbcSqlTransaction.java:382)
at org.jumpmind.db.sql.JdbcSqlTransaction$6.execute(JdbcSqlTransaction.java:372)
at org.jumpmind.db.sql.JdbcSqlTransaction.executeCallback(JdbcSqlTransaction.java:404)
... 16 more
Caused by: java.sql.SQLException: DELETE on table 'SYM_NODE' caused a violation of foreign key constraint 'SYM_FK_SEC_2_NODE' for key (my-client-id). The statement has been rolled back.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
... 30 more
Caused by: ERROR 23503: DELETE on table 'SYM_NODE' caused a violation of foreign key constraint 'SYM_FK_SEC_2_NODE' for key (my-client-id). The statement has been rolled back.
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.sql.execute.ReferencedKeyRIChecker.doCheck(Unknown Source)
at org.apache.derby.impl.sql.execute.RISetChecker.doPKCheck(Unknown Source)
at org.apache.derby.impl.sql.execute.DeleteResultSet.collectAffectedRows(Unknown Source)
at org.apache.derby.impl.sql.execute.DeleteResultSet.open(Unknown Source)
at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(Unknown Source)
at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source)
... 24 more
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What version of SymmetricDS are you using? What is the state of sym_node and sym_node_security at both the server and the client before re-registration is attempted?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm currently using 3.8.14, but tried also with 3.8.24 with the same results.
The status before attempting the re-registration is the following:
On the server: the sym_node_security row is deleted when the sync on node is being disabled. the sym_node:
Hi!
I'm using SymmetricClient in embedded mode, with embedded Derby database. Synchronization is mosty working, but I have trouble when client nodes come online after the given 'offline.node.detection.period.minutes'.
The server is disabling the sync on nodes when 'offline.node.detection.period.minutes' expires, which is just perfect.
On clients DefaultOfflineClientListener deletes NODE_IDENTITY in order to induce re-registration, which is also perfect.
But when the DataLoaderService is loading the virtual batch 9999, deleting from SYM_NODE causing violation of foreign key constraint 'SYM_FK_SEC_2_NODE'.
I've found out the possible cause of it, i.e. why deleting from SYM_NODE_SECURITY is not done beforehand. Symmetric is using the following SQL for that:
delete from sym_node_security where created_at_node_id='server'
,while in the database the CREATED_AT_NODE_ID contains the client node id, not the server node id. It's a bit strange, as the column with the same name in SYM_NODE table contains server node id!
Why is it so? What can I do to make the re-registration of clients work?
Thanks!
The logs:
2017-05-24 08:25:01,448 ERROR org.jumpmind.symmetric.io.data.writer.DefaultDatabaseWriter:547 - Failed to run the following sql: delete from sym_node where created_at_node_id='server'
2017-05-24 08:25:01,510 ERROR org.jumpmind.symmetric.service.impl.DataLoaderService$ManageIncomingBatchListener:1146 - Failed to load batch server--9999
org.jumpmind.db.sql.SqlException: DELETE on table 'SYM_NODE' caused a violation of foreign key constraint 'SYM_FK_SEC_2_NODE' for key (my-client-id). The statement has been rolled back.
at org.jumpmind.db.sql.AbstractSqlTemplate.translate(AbstractSqlTemplate.java:300)
at org.jumpmind.db.sql.AbstractSqlTemplate.translate(AbstractSqlTemplate.java:291)
at org.jumpmind.db.sql.JdbcSqlTransaction.executeCallback(JdbcSqlTransaction.java:406)
at org.jumpmind.db.sql.JdbcSqlTransaction.prepareAndExecute(JdbcSqlTransaction.java:372)
at org.jumpmind.symmetric.io.data.writer.DefaultDatabaseWriter.sql(DefaultDatabaseWriter.java:542)
at org.jumpmind.symmetric.io.data.writer.AbstractDatabaseWriter.write(AbstractDatabaseWriter.java:168)
at org.jumpmind.symmetric.io.data.writer.NestedDataWriter.write(NestedDataWriter.java:64)
at org.jumpmind.symmetric.model.ProcessInfoDataWriter.write(ProcessInfoDataWriter.java:65)
at org.jumpmind.symmetric.io.data.writer.NestedDataWriter.write(NestedDataWriter.java:64)
at org.jumpmind.symmetric.io.data.writer.TransformWriter.write(TransformWriter.java:207)
at org.jumpmind.symmetric.io.data.DataProcessor.forEachDataInTable(DataProcessor.java:200)
at org.jumpmind.symmetric.io.data.DataProcessor.forEachTableInBatch(DataProcessor.java:170)
at org.jumpmind.symmetric.io.data.DataProcessor.process(DataProcessor.java:116)
at org.jumpmind.symmetric.service.impl.DataLoaderService$LoadIntoDatabaseOnArrivalListener$1.call(DataLoaderService.java:975)
at org.jumpmind.symmetric.service.impl.DataLoaderService$LoadIntoDatabaseOnArrivalListener$1.call(DataLoaderService.java:950)
at java.util.concurrent.FutureTask.run(FutureTask.java:274)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1157)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:627)
at java.lang.Thread.run(Thread.java:809)
Caused by: java.sql.SQLIntegrityConstraintViolationException: DELETE on table 'SYM_NODE' caused a violation of foreign key constraint 'SYM_FK_SEC_2_NODE' for key (my-client-id). The statement has been rolled back.
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.execute(Unknown Source)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
at org.jumpmind.db.sql.JdbcSqlTransaction$6.execute(JdbcSqlTransaction.java:382)
at org.jumpmind.db.sql.JdbcSqlTransaction$6.execute(JdbcSqlTransaction.java:372)
at org.jumpmind.db.sql.JdbcSqlTransaction.executeCallback(JdbcSqlTransaction.java:404)
... 16 more
Caused by: java.sql.SQLException: DELETE on table 'SYM_NODE' caused a violation of foreign key constraint 'SYM_FK_SEC_2_NODE' for key (my-client-id). The statement has been rolled back.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
... 30 more
Caused by: ERROR 23503: DELETE on table 'SYM_NODE' caused a violation of foreign key constraint 'SYM_FK_SEC_2_NODE' for key (my-client-id). The statement has been rolled back.
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.sql.execute.ReferencedKeyRIChecker.doCheck(Unknown Source)
at org.apache.derby.impl.sql.execute.RISetChecker.doPKCheck(Unknown Source)
at org.apache.derby.impl.sql.execute.DeleteResultSet.collectAffectedRows(Unknown Source)
at org.apache.derby.impl.sql.execute.DeleteResultSet.open(Unknown Source)
at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(Unknown Source)
at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source)
... 24 more
What version of SymmetricDS are you using? What is the state of sym_node and sym_node_security at both the server and the client before re-registration is attempted?
I'm currently using 3.8.14, but tried also with 3.8.24 with the same results.
The status before attempting the re-registration is the following:
On the server:
the sym_node_security row is deleted when the sync on node is being disabled.
the sym_node:
On the client:
* the sym_node_security:
Last edit: krivoz 2017-06-08
We just added a fix to this bug, it will come out in our next release, 3.8.26.
Thank you Klementina. May I know the issue number? I'm just curious about the solution :).
Here is the URL to the issue: https://www.symmetricds.org/issues/view.php?id=3154