More explicit requirements regarding add_version#130
Merged
djmitche merged 2 commits intoGothenburgBitFactory:mainfrom Jul 14, 2025
Merged
More explicit requirements regarding add_version#130djmitche merged 2 commits intoGothenburgBitFactory:mainfrom
add_version#130djmitche merged 2 commits intoGothenburgBitFactory:mainfrom
Conversation
The core crate calls `get_client` and verifies the `latest_version_id` before it invokes `add_version`. With the SQLite backend, transactions lock the entire database, so these two queries cannot be interleaved with any changes to the `latest_version_id` and there's no possibility of incorrect updates. With Postgres (GothenburgBitFactory#129) the effect is similar: the read performed by `get_client` locks that row and prevents other transactions from writing to it. However, the storage trait should not rely on this behavior -- `add_version` should verify that it is adding a new version on top of the correct parent version.
ryneeverett
approved these changes
Jul 14, 2025
Co-authored-by: ryneeverett <ryneeverett@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The core crate calls
get_clientand verifies thelatest_version_idbefore it invokesadd_version. With the SQLite backend, transactions lock the entire database, so these two queries cannot be interleaved with any changes to thelatest_version_idand there's no possibility of incorrect updates. With Postgres (#129) the effect is similar: the read performed byget_clientlocks that row and prevents other transactions from writing to it.However, the storage trait should not rely on this behavior --
add_versionshould verify that it is adding a new version on top of the correct parent version.