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

[10.0] Remove RowExclusiveLock on exception_rule #1647

Merged
merged 1 commit into from
Sep 11, 2019

Commits on Aug 15, 2019

  1. [10.0] Remove RowExclusiveLock on exception_rule

    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
    guewen committed Aug 15, 2019
    Configuration menu
    Copy the full SHA
    6a301a1 View commit details
    Browse the repository at this point in the history