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

db: improve transactions handling #363

Merged
merged 1 commit into from
Dec 14, 2022

Conversation

sgotti
Copy link
Member

@sgotti sgotti commented Dec 13, 2022

Since the transactions can be repeated (i.e. due to serializable errors in postgres or locked errors in sqlite) we should ensure that the objects are created inside the transaction or at the second execution the transaction will fail since the object revision has been updated by the previous one.

This patch adds a txID to every transaction that it's set on objects fetched as an helper to ensure that the object is created/fetched inside the same transaction.

To handle cases were the object is fetched/created outside the transaction we MUST manually ensure that the object is still valid (the tx logic must be self consistent) and only in such case restore the txID to the current transactions and revision to the original value at the start of the transaction.

@sgotti sgotti force-pushed the db_improve_tx_handling branch from ecf2ed7 to a321726 Compare December 13, 2022 22:32
Since the transactions can be repeated (i.e. due to serializable errors
in postgres or locked errors in sqlite) we should ensure that the
objects are created inside the transaction or at the second execution
the transaction will fail since the object revision has been updated by
the previous one.

This patch adds a txID to every transaction that it's set on objects
fetched as an helper to ensure that the object is created/fetched inside
the same transaction.

To handle cases were the object is fetched/created outside the
transaction we MUST manually ensure that the object is still valid (the
tx logic must be self consistent) and only in such case restore the txID
to the current transactions and revision to the original value at the
start of the transaction.
@sgotti sgotti force-pushed the db_improve_tx_handling branch from a321726 to 0d4c1ed Compare December 14, 2022 10:17
@sgotti sgotti merged commit 0e53211 into agola-io:master Dec 14, 2022
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