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

Concurrent changes to attribute leave data in inconsistent state #202

Closed
ledsoft opened this issue Sep 14, 2023 · 1 comment · Fixed by #203
Closed

Concurrent changes to attribute leave data in inconsistent state #202

ledsoft opened this issue Sep 14, 2023 · 1 comment · Fixed by #203
Labels

Comments

@ledsoft
Copy link
Contributor

ledsoft commented Sep 14, 2023

When two concurrent transaction modify the same attribute of the same entity, both new values are saved in the repository.

Consider the following example, assuming Person.name is a singular attribute, T1 and T2 are transactions in separate persistence contexts (entity managers):

1. T1.begin()
2. T2.begin()
3. T1 load Person p as pT1
4. T2 load Person p as pT2
5. T1 set pT1.name = "T1 value"
6. T2 set pT2.name = "T2 value"
7. T1.commit()
8. T2.commit()

After this sequence, the repository contains both "T1 value" and "T2 value" for p, which causes IntegrityConstraintViolationExceptions on loading p because Person.name is a singular attribute.

@ledsoft ledsoft added the bug label Sep 14, 2023
@ledsoft
Copy link
Contributor Author

ledsoft commented Sep 14, 2023

Note that experiments with Eclipselink and Hibernate on the same scenario show that "T2 value" should be the only result - i.e., the last committed change overwrites any previous ones.

ledsoft added a commit that referenced this issue Sep 14, 2023
…ts update to prevent transaction concurrency issues.

Originally, all property values were selected and then these statements were removed on commit. However, if these changed in the meantime (e.g., when another transaction committed), it lead to stale data being in the repository.
ledsoft added a commit that referenced this issue Sep 19, 2023
…s update to prevent transaction concurrency issues.

Originally, all property values were selected and then these statements were removed on commit. However, if these changed in the meantime (e.g., when another transaction committed), it lead to stale data being in the repository.
@ledsoft ledsoft linked a pull request Sep 19, 2023 that will close this issue
ledsoft added a commit that referenced this issue Sep 22, 2023
…statements added with transaction to LocalModel.
ledsoft added a commit that referenced this issue Sep 22, 2023
…its update to prevent transaction concurrency issues.
@ledsoft ledsoft closed this as completed Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant