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

[FIX] stock: _update_available_quantity avoid serialization failure #1

Open
wants to merge 3 commits into
base: 12.0
Choose a base branch
from

Conversation

IAY-DGTERA
Copy link
Owner

Description of the issue/feature this PR addresses:

serialization failures would appear in the case of multi cron jobs affecting the stock at the same time

Current behavior before PR:

serialization failures would appear in the case of multi cron jobs trying to acquire the lock in
self._cr.execute("SELECT 1 FROM stock_quant WHERE id = %s FOR UPDATE NOWAIT", [quant.id], log_exceptions=False)
as it could have obtained the lock, as the lock is currently available. But it had been locked at some previous point which overlaps with the current transaction's snapshot. So obtaining the lock is possible, but would create a serialization problem if it were to acquire it. Reporting that as a serialization failure seems like the correct outcome.

Desired behavior after PR is merged:

if the serialization failure happens we skip it and go to the next quant or create one if needed

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

IAY-DGTERA and others added 3 commits November 21, 2020 12:06
Before this Commit: serialization failures would appear in case of multi cron jobs trying to acquire the lock in
`self._cr.execute("SELECT 1 FROM stock_quant WHERE id = %s FOR UPDATE NOWAIT", [quant.id], log_exceptions=False)`
as it could have obtained the lock, as the lock is currently available. But it had been locked at some previous point which overlaps with the current transaction's snapshot. So obtaining the lock is possible, but would create a serialization problem if it were to acquire it. Reporting that as a serialization failure seems like the correct outcome.

after this commit: 
if the serialization failure happens we skip it and go to the next quant or create one if needed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant