Phase 0 of the event persistence plan, apart from the write transaction helper: - `experimental_features.rust_event_persistence`, one ordered level (off, shadow, prepare, transaction, full). Nothing uses the levels yet beyond building the persister. - `RustHandlers.persister`: built on the events writer when the level is not off and the main database uses the native driver. It holds the pool, the shared caches and the events, backfill and cache stream trackers. - `PersistEffects`, the Python cache updates a Rust transaction will ask for in place of `txn.call_after`, applied in one call by `DataStore._apply_rust_persist_effects`. A test persists batches through Python and checks that applying the matching effects updates the same caches. The chunk's stream IDs come back unfinished and are finished last, as Python's `get_next_mult` does after the transaction's callbacks, so the current token never passes an event the stream change caches don't know about. - `PersistContext`, read from an `EventContext` once per event. - `Event::to_persistence_value` and `EventInternalMetadata::to_persistence_value`: the `event_json` columns built without the GIL. - Rust-side persistence counters, added to the Python metrics by a pre-collect hook. A homeserver can now register more than one such hook. The persisted position is reported only when it moved, so it can't pull back the gauge the Python path sets. - `SYNAPSE_TEST_RUST_PERSIST` for trial and `RUST_PERSIST` for Complement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UHKYPSc37kWqGACn9aKxKL
Unified Complement image for Synapse
This is an image for testing Synapse with the Complement integration test suite. It contains some insecure defaults that are only suitable for testing purposes, so please don't use this image for a production server.
This multi-purpose image is built on top of Dockerfile-workers in the parent directory
and can be switched using environment variables between the following configurations:
- Monolithic Synapse with SQLite (default, or
SYNAPSE_COMPLEMENT_DATABASE=sqlite) - Monolithic Synapse with Postgres (
SYNAPSE_COMPLEMENT_DATABASE=postgres) - Workerised Synapse with Postgres (
SYNAPSE_COMPLEMENT_DATABASE=postgresandSYNAPSE_COMPLEMENT_USE_WORKERS=true)
The image is self-contained; it contains an integrated Postgres, Redis and Nginx.
How to get Complement to pass the environment variables through
To pass these environment variables, use Complement's COMPLEMENT_SHARE_ENV_PREFIX
variable to configure an environment prefix to pass through, then prefix the above options
with that prefix.
Example:
COMPLEMENT_SHARE_ENV_PREFIX=PASS_ PASS_SYNAPSE_COMPLEMENT_DATABASE=postgres
Consult scripts-dev/complement.sh in the repository root for a real example.
How to modify homeserver.yaml for Complement tests
It's common for MSCs to be gated behind a feature flag like this:
experimental_features:
faster_joins: true
To modify this for the Complement image, modify ./conf/workers-shared-extra.yaml.j2. Despite the name,
this will affect non-worker mode as well. Remember to rebuild the image (so don't use -e if using
complement.sh).