You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds a Beeper compare-and-swap (CAS) mechanism for account data. Clients may pass a com.beeper.expect_revision_id query param on account-data PUTs; the write only lands if the stored content's com.beeper.revision_id matches, otherwise the server returns 409 COM.BEEPER.REVISION_ID_MISMATCH with the current content so the client can retry. The CAS check is enforced atomically in the storage layer and handles the no-existing-row race and concurrent writers.
New error code COM.BEEPER.REVISION_ID_MISMATCH in synapse/api/errors.py.
expected_revision_id threaded through REST servlets, AccountDataHandler, the replication endpoints, and the storage writes.
New _upsert_account_data_txn enforces CAS: SELECT ... FOR UPDATE (Postgres), compares the stored revision id, and either raises 409 (with com.beeper.current_content) or upserts; the no-row case uses INSERT ... ON CONFLICT DO NOTHING + re-read to serialize concurrent first writes.
Room account-data writes moved from simple_upsert to runInteraction so the CAS read and write share one transaction.
The 409 error, including its extra fields, propagates verbatim across workers via the replication layer.
Issues
1 potential issue found:
Both account-data PUT servlets parse com.beeper.expect_revision_id but silently ignore it when MSC3391 is enabled and the body is {}, routing to the unconditional delete path; a client using CAS to clear account data loses the precondition. Latent: only triggers when experimental_features.msc3391_enabled is true (off by default).
↑ Select any checkbox above to have Indent auto-fix the issue
CI Checks
Both failures are unrelated to the account-data changes. build-python fails building the Docker image because the branch name tobias/plat-38547-account-data-expect contains slashes, producing an invalid image tag; test-complement fails on TestThreadsEndpoint (a threads/relations ordering assertion) which does not touch account data and is a pre-existing flake. Lint, types, trial, and sytest all pass.
The build step tags the image with the branch name for non-beeper refs: --tag .../synapse:tobias/plat-38547-account-data-expect-<sha>. Docker rejects this: invalid tag ...: invalid reference format, because Docker tags cannot contain /. This affects any branch whose name contains a slash and is unrelated to the PR's code; it would need a CI workflow change to sanitize the branch name before using it as a tag.
The only failing test is TestThreadsEndpoint (room_threads_test.go:89): HaveInOrder: index 0 got $L6w...1_1Y| want $L6w...1_1Y|$AMN...NTw, an ordering assertion on thread root events. This path does not exercise account data and is unrelated to the CAS change (the account-data complement tests TestAddAccountData passed). It looks like a pre-existing/flaky ordering test; re-running is the likely resolution.
Bulk Actions
Autofix all issues
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
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.
No description provided.