Skip to content

More explicit requirements regarding add_version#130

Merged
djmitche merged 2 commits intoGothenburgBitFactory:mainfrom
djmitche:add_version_checks_latest
Jul 14, 2025
Merged

More explicit requirements regarding add_version#130
djmitche merged 2 commits intoGothenburgBitFactory:mainfrom
djmitche:add_version_checks_latest

Conversation

@djmitche
Copy link
Collaborator

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 (#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.

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.
Co-authored-by: ryneeverett <ryneeverett@gmail.com>
@djmitche djmitche merged commit 816c9a3 into GothenburgBitFactory:main Jul 14, 2025
7 checks passed
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.

2 participants