-
Notifications
You must be signed in to change notification settings - Fork 132
#93 - Adding support for optimistic locking based on @Version column #314
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
Conversation
Thanks for your pull request. We definitively want to add support for optimistic locking. We just didn't had the time yet to work ourselves into this matter in the context of R2DBC. The design of the R2DBC module evolves and we realized that we have to treat After quickly looking at the implementation, please make note that primitive version properties ( |
Thank you for the feedback, @mp911de. Regarding the initial version handling, could you please comment on the motivation for this decision? Me as a user expect to have the versioning consistent for all Btw, I've noticed that there is no |
The rationale for the difference is that an uninitialized Regarding the |
I created an issue in Spring Data JDBC for changing the version initialisation. https://jira.spring.io/browse/DATAJDBC-507 |
Thanks, guys, I've update the PR to follow Spring Data versioning policy. Coming back to the initial question about |
We previously had no support for optimistic locking so we used |
Done. |
Hi guys, is there anything I can do for this PR to get accepted? |
No, there's nothing else required from your side. Given the current situation, we're tied more to prioritization and some contributions may take longer to get merged. Thanks for your understanding. |
Formatting. Added issue to test comments. Removed the test for presence of the id in case of a potential optimistic locking exception. A deleted row is also a case of a concurrent modification and therefore should trigger the OptimisticLockingException. Original pull request: #314.
This is polished and merged. Thanks for the work. |
This PR is a proposal for implementation of optimistic locking (#93). Suggested solution was heavily inspired by spring-projects/spring-data-relational#124.
Current tests are failing, and I need an advice from the project members what would be the best way to resolve it.
The thing is that typically
OptimisticLockingException
is expected by a user if update failed due to version mismatch (expected result in the tests). But previous implementation already used ID criteria during update query execution and now fails withTransientDataAccessResourceException
if query did not update any rows (regardless if version or ID did not match). I do not see any way to distinguish between ID/version mismatches but executing an additional query in the failure case to throw a proper exception. But this obviously has a cost. At the same time usingTransientDataAccessResourceException
for optimistic locking does not seem to be a good design. AndTransientDataAccessResourceException
is already a part of API contract, just replacing it withOptimisticLockingException
would mean an incompatible contract change. So all available options seems to have downsides to me..