Skip to content
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

Synchronization issue in using this library #101

Open
Yardentexel opened this issue May 23, 2021 · 2 comments
Open

Synchronization issue in using this library #101

Yardentexel opened this issue May 23, 2021 · 2 comments

Comments

@Yardentexel
Copy link

Maybe I am missing something

but in using this library I am creating a sync issue

Thread = T

in the DB:
Class Foo {
int x = 1;
int y = 1;
}

T1 get Foo (x=1, y=1)
T2 get Foo and updates y=2 (x=1, y=2)
T1 update Foo to x=5 (x=5, y=1)

and partial update is not an option because there is not access to the Operation/Path/Value we update

for a server with multiple replica set i need to create a distributed lock in order to avoid sync issue

am i missing any thing?

@Yardentexel
Copy link
Author

I am using spring framework

and referring to this article on the implementation of a server controller
https://www.baeldung.com/spring-rest-json-patch#2-the-rest-controller-method

@andrebrait
Copy link

This is a classical concurrent programming issue, not specific to this library.
What I would recommend to you would be to use a version field on your entity and use optimistic locking.
A good idea would be to make the updates transactional as well. If you don't have transaction support on your database, or you want better read performance still, then optimistic locking with a version would be your best bet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants