Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [smila-dev] XssConnectionHelper.addOrUpdateDocument throws DOCUMENT_ALREADY_EXSISTS exception

Hi Marius,

Yes, thanks that you removed that XssConnectionHelper ))
Yes you are right the problem was with concurrent threads.

--
Ivan


Marius Cimpean wrote:
Hi Ivan,

Technically speaking, this is because there was an attempt to add a document (into BDB Xml container - through xml storage) having a name which already exists inside of the BDB Xml, for another document (Document exists: <document_name>, errcode = UNIQUE_ERROR)

Functionality speaking, the document name is the Id.hashId; so this is because of trying to add a record having an already stored id.... The addOrUpdateDocument method should take care of this, so in our case the document exists, and it should be updated not added.

I can only assume (regarding to your tests...if i'wrong please let me know) that there were parallel threads processing the same record/document (same id) where: 1. thread A enters the addOrUpdateDocument and decides new document needs to be added
2. thread A starts transaction
3. thread B enters the addOrUpdateDocument method and checks if the document already exists and finds that document doesn't exist
4. thread A commits transaction
5. thread B starts transaction and tries to add document (which now already exists because of thread A) 6. thread B commits transaction ==> Document exists: <document_name>, errcode = UNIQUE_ERROR

PS: I 've just refactored the addOrUpdateDocument functionality (from other considerations), which is now synchronized

Best regards,
Marius

----- Original Message ----- From: "Ivan Churkin" <ivan@xxxxxxxxxxxx>
To: "Smila project developer mailing list" <smila-dev@xxxxxxxxxxx>
Sent: Thursday, November 13, 2008 1:27 PM
Subject: [smila-dev] XssConnectionHelper.addOrUpdateDocument throws DOCUMENT_ALREADY_EXSISTS exception


How it is possible???

Caused by: org.eclipse.smila.xmlstorage.XssException: DOCUMENT_ALREADY_EXSISTS at org.eclipse.smila.xmlstorage.internal.impl.XssConnectionImpl.handleXmlException(XssConnectionImpl.java:314) at org.eclipse.smila.xmlstorage.internal.impl.XssConnectionImpl.addDocumentGeneric(XssConnectionImpl.java:156) at org.eclipse.smila.xmlstorage.internal.impl.XssConnectionSyncImpl.addDocument(XssConnectionSyncImpl.java:56) at org.eclipse.smila.xmlstorage.XssConnectionHelper.addOrUpdateDocument(XssConnectionHelper.java:61) at org.eclipse.smila.blackboard.impl.BlackboardServiceImpl.commit(BlackboardServiceImpl.java:280)

--
Regards, Ivan
_______________________________________________
smila-dev mailing list
smila-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/smila-dev




_______________________________________________
smila-dev mailing list
smila-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/smila-dev



Back to the top