New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimistic Locking is not working when using Repository save method [DATACOUCH-212] #522
Comments
Anastasiia Smirnova commented I've just found the same issue, tried last version with fix. But it seems that it does not handle case of concurrent writes of new document with the same key. |
Simon Baslé commented
So what you could do is do a first insert, get the associated |
Anastasiia Smirnova commented Thanks for the quick reply! |
Simon Baslé commented I think it should work equally as well with the |
Simon Baslé commented Jordan's scenario works as well: get the doc from the database (through the repository), which will populate it's |
Anastasiia Smirnova commented Using the following https://github.com/spring-projects/spring-retry#java-configuration-for-retry-proxies
This flow was working for spring data for couchbase client 1.x and gives data loss in 2.x since there is no error when saving document with no version over existing document in concurrent mode. |
Anastasiia Smirnova commented I've made a fix, please review |
Jordan Scherle opened DATACOUCH-212 and commented
Optimistic Locking doesn't appear to be working any longer when using the repository "save" method to save an entity. This was previously working in the 1.4 release.
Steps to reproduce:
-Create a Document class with the
@Version
annotation-Create a CrudRepository referencing the Document class
-Load an existing document via the repository "findOne" method in thread 1 (validated the cas is set in this document)
-In thread 2 update the same document
-In thread 1, save the document using the repository "save" method
Expected Result:
A CASMismatchException is thrown
Actual Result:
No exception is thrown and thread 1 overwrites the document thread 2 had saved
Note: this exact scenario was working in 1.4 release
Affects: 2.0 GA, 2.1 RC1 (Hopper)
Issue Links:
("is depended on by")
The text was updated successfully, but these errors were encountered: