-
Notifications
You must be signed in to change notification settings - Fork 361
DATAJDBC-493 Resolve Deadlock occurs when competing with Jdbc Repository Update and Delete. #196
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
DATAJDBC-493 Resolve Deadlock occurs when competing with Jdbc Repository Update and Delete. #196
Conversation
mhyeon-lee
commented
Feb 26, 2020
- DATAJDBC-498
- First step for resolving [DATAJDBC-493]
This looks decent, but I'd like to have a complete solution DATAJDBC-493 before merging parts of the fix. I'd therefore appreciate it if you could combine this PR with #195 and possibly the rest of what you outlined in DATAJDBC-493 . |
…tgres lock hint
@schauder
|
I needed to modify the PostgreSQL lock clause, so I committed it further. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acquiring a lock should be a DbAction
wich gets generated and executed with all the other DbActions
.
If there are no other entities in the aggregate which get stored in other tables, the lock is superfluous and should not be acquired.
The lock should also be acquired for deleteAll
, without actually returning the entities.
Which is something that would be nice for the single locks as well, after all we don't really need the values and wasting resources by actually hydrating the objects involved.
@@ -352,6 +355,9 @@ public void deleteAll(Class<?> domainType) { | |||
entity = triggerBeforeDelete(entity, id, change); | |||
change.setEntity(entity); | |||
|
|||
// [DATAJDBC-493] Acquire Lock to avoid DeadLock | |||
this.acquireLockIfActualTransactionActive(id, domainType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be encoded in a DbAction
and then executed by the executor.
|
Thanks, I'll take a look. |
…able. Introduces infrastructure to obtain locks and uses them to acquire locks on the table of the aggregate root before deleting references. Without this lock deletes access non root entities before the aggregate root, which is the opposite order of updates and thus may cause deadlocks. Original pull request: #196.
Using `execute` instead of `query` since we are not interested in the results. Refactoring of the concurrency tests. Make the concurrency tests run with all databases. Added support for DB2. Moved AnsiDialect to the main sources so it can be referenced in other Dialects. Original pull request: #196.
Thanks, that is a nice fix. |