-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[10.0] Remove RowExclusiveLock on exception_rule #1647
[10.0] Remove RowExclusiveLock on exception_rule #1647
Conversation
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.
Small comment, but approving.
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.
Thanks a lot for the fix @guewen
It seems fine to me.
I agree these concurrent update issues have to be fixed and we'll eventually fix some other performance issue in the future if necessary, having this issue in mind.
The goal of the modified method is to create or remove the relationship (in the M2m relation tabel) between the tested model (such as sale_order) and the exception rules. When the ORM writes on ExceptionRule.sale_ids (using the example of sale_exception), it will first proceeds with these updates: * an UPDATE on exception_rule to set the write_date * INSERT or DELETE on the relation table * but then, as "write" is called on the exception rule, the ORM will trigger the api.depends to recompute all the "main_exception_ids" of the records (sales, ...) related to it, leading to an UPDATE for each sale order We end up with RowExclusiveLock on such records: * All the records of the relation table added / deleted for the current sale order * All the records of exception_rule matching the current sale order * All the records of sale_order related to the exception rules matching the current sale order The first one is expected, the next 2 are not. We can remove the lock on the exception_rule table by removing `_log_access`, however in any case, the main_exception_ids computed field will continue to lock many sale orders, effectively preventing 2 sales orders with the same exception to be confirmed at the same time. Reversing the write by writing on SaleOrder instead of ExceptionRule fixes the 2 unexpected locks. It should not result in more queries: the "to remove" part generates a DELETE on the relation table for the rule to remove and the "to add" part generates an INSERT for the rule to add, both will be exactly the same in both cases. Related to OCA#1642 Replaces OCA#1638
248da11
to
6a301a1
Compare
Squashed the fixup |
This PR has the |
/ocabot merge minor |
On my way to merge this fine PR! |
Congratulations, your PR was merged at 8df0132. Thanks a lot for contributing to OCA. ❤️ |
The goal of the modified method is to create or remove the relationship
(in the M2m relation tabel) between the tested model (such as
sale_order) and the exception rules. When the ORM writes on
ExceptionRule.sale_ids (using the example of sale_exception), it will
first proceeds with these updates:
trigger the api.depends to recompute all the "main_exception_ids"
of the records (sales, ...) related to it, leading to an UPDATE
for each sale order
We end up with RowExclusiveLock on such records:
sale order
the current sale order
The first one is expected, the next 2 are not. We can remove the lock on
the exception_rule table by removing
_log_access
, however in any case,the main_exception_ids computed field will continue to lock many sale
orders, effectively preventing 2 sales orders with the same exception
to be confirmed at the same time.
Reversing the write by writing on SaleOrder instead of ExceptionRule
fixes the 2 unexpected locks. It should not result in more queries: the
"to remove" part generates one DELETE on the relation table for the rule
to remove and the "to add" part generates one INSERT (with unnest) for the rule to add,
both will be exactly the same in both cases.
Related to #1642
Replaces #1638