Lock rows used for computation when assigning
As we are now in "REPEATABLE READ" (r0a4097cbe662), there are a case where the assignation process is not safe enough.
If another transaction tries to update/insert/delete on the stock_move table concurrently with the assignation, it will just be waiting for the lock to be released and continue with old read data.
Normally, the good practice when doing operation on rows that depends on other rows is to perform a "SELECT … FOR UPDATE/SHARE" to acquire a lock on the rows.
In our case, we should issue a "SELECT … FROM stock_move … FOR UPDATE NOWAIT" for all rows used to compute products_by_location.
As SQLite does not support this syntax, we need to define an attribute on Database to use it.
Files
Download | Creator | Timestamp | Type |
---|---|---|---|
unnamed | @albertca | 2017-01-17 17:21:09.114000 UTC | text/plain |