Files
synapse/tests
Erik JohnstonandClaude Opus 5.5 41c7808711 Store the event metadata in the Rust persist transaction
The third commit of phase 2. The Rust transaction now also runs
`_update_metadata_tables_txn`, apart from the event cache prefill at its
end (`_add_to_cache`), which stays in Python:

- `txn/metadata.rs`: push actions move from the staging table, and the
  chunk's staging rows go. A redaction removes the push actions and the
  relation of the event it redacts, and moves or deletes its thread.
  Then search (with the plain text topic from `m.topic`), redactions,
  retention, relations and threads, labels, expiry, and room members.
  An out-of-band membership of a local user also updates
  `local_current_membership` and the user's sliding sync snapshot, with
  the stripped state of an invite or knock.
- `txn/edges.rs`: `event_edges` with the backward extremities, and the
  MSC4242 state DAG edges.
- `txn/caches.rs`: `_invalidate_cache_and_stream`. The rows go into
  `cache_invalidation_stream_by_instance` inside the transaction, with
  IDs from the cache stream's tracker. The committed attempt hands its
  IDs to Python in `PersistEffects.cache_stream_ids`. Python finishes
  them after invalidating the caches, as `get_next_txn` does. A failed
  attempt's IDs are finished when its steps fail, or for a failed
  commit, by the next attempt or when the persist ends. A fetch of an ID
  that is dropped before the sequence answers still ends, so a cancelled
  persist cannot hold the stream's position back.

Where Python and Rust differ, the input is malformed:

- Python stores labels from any value it can iterate, and non-string
  labels. Rust stores only string labels from a list.
- An integer lifetime or expiry beyond `u64` is a float to serde, so
  Rust ignores it where Python's insert fails. Within `u64` but beyond
  `bigint`, both fail.

The persister reads `enable_search` and `enable_ephemeral_messages`
from the server config. `persist_events_txn_for_test` takes
`inhibit_local_membership_updates`.

New twin scenarios: each kind of relation and its redaction, which
moves the thread back and then deletes it, a relation redacted in its
own chunk, two thread replies in one chunk, search, retention (also two
policies in one chunk), labels and expiry, member rows, push actions and
their redaction, an out-of-band invite and its rejection, a knock, and a
backfilled invite. The out-of-band ones are skipped in state DAG rooms,
as a hand-built event has no state DAG context. A redaction before its
target is now stored with a recheck still needed.

The test harness compared `event_edges` by its `room_id` column, which
is no longer filled in, so it compared no rows. It now compares by
`event_id`. It also names the cache behind each invalidation, compares
the cache stream rows' times, and finishes the cache stream IDs Rust
hands back. Fifteen mutants of the new steps each fail the comparison.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LXMkcZVkcZhi21augBff4a
2026-10-17 14:28:54 +00:00
..
2026-09-18 12:00:45 +01:00
2026-10-14 13:35:25 +00:00