Projects tigase _server tigase-pubsub Issues #39
PubSub tig_pubsub_nodes schema issue (#39)
Closed
wojciech.kapcia@tigase.net opened 10 years ago
Due Date
2015-02-08
com.microsoft.sqlserver.jdbc.SQLServerException: Violation of UNIQUE KEY constraint 'UQ__tig_pubs__4A4CCE286F02D367'. Cannot insert duplicate key in object 'dbo.tig_pubsub_nodes'. The duplicate key value is (322, 0x08826706323704a3431e7a150626387e5053b9db).
        at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515)
        at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:404)
        at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:350)
        at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:180)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:155)
        at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:314)
        at tigase.pubsub.repository.PubSubDAOJDBC.createNode(PubSubDAOJDBC.java:178)
        at tigase.pubsub.repository.PubSubDAOJDBC.createNode(PubSubDAOJDBC.java:59)
        at tigase.pubsub.repository.PubSubDAOPool.createNode(PubSubDAOPool.java:93)
        at tigase.pubsub.repository.cached.CachedPubSubRepository.createNode(CachedPubSubRepository.java:313)
        at tigase.pubsub.modules.PublishItemModule.process(PublishItemModule.java:468)
        at tigase.component2.modules.ModulesManager.process(ModulesManager.java:87)
        at tigase.component2.AbstractComponent.processStanzaPacket(AbstractComponent.java:221)
        at tigase.component2.AbstractComponent.processPacket(AbstractComponent.java:209)
        at tigase.pubsub.PubSubComponent.processPacket(PubSubComponent.java:599)
        at tigase.pubsub.cluster.PubSubComponentClustered.processPacket(SourceFile:144)
        at tigase.server.AbstractMessageReceiver$QueueListener.run(AbstractMessageReceiver.java:1424)
Andrzej Wójcik (Tigase) commented 10 years ago

After short analysis, I do not think this is schema issue, but issue with clustering using ACS ClusteredNodeStrategy with PEP (persistent) in which when item is published on not existing PEP node then packet with publication is cloned to every node for processing, which in some cases leads to case when 2 or more nodes might try to create node as this packet may be processed on both nodes at the same time.

Andrzej Wójcik (Tigase) commented 10 years ago

I changed clustering implementation to check in clustering strategy publication of item for not existing PEP node and create this node if needed (same as PublishItemModule would do). This (as done before sending notification to other nodes) protects from race condition which lead to this issue.

wojciech.kapcia@tigase.net commented 10 years ago

tested, the issue is fixed.

issue 1 of 1
Type
Bug
Priority
Normal
Assignee
RedmineID
2659
Spent time
6h 30m
Issue Votes (0)
Watchers (0)
Reference
tigase/_server/tigase-pubsub#39
Please wait...
Page is in error, reload to recover