Files
synapse/tests/storage
Quentin Gliech 00b5c166b0 Honour a read receipt for an event older than the last summary rotation
`event_push_summary` rows written by rotation for a room the user has never
sent a receipt in have a NULL `last_receipt_stream_ordering`, and the badge
queries read NULL as "already accounts for every receipt" -- a compatibility
branch for rows written before Synapse v1.62.0. It is only sound while the user
has no receipt: such a row counts from the user's join, so once a receipt
arrives it may include events at or before it. A receipt for an event older
than the row's high-water mark was therefore ignored until the next rotation,
up to 30 seconds later, leaving a stale unread count.

Only trust a NULL row while the user has no receipt covering the thread. The
manual count from `event_push_actions` that replaces it can only be complete
above the point `_remove_old_push_actions_that_have_rotated` deletes from, so
below that we keep serving the (possibly stale) summary and let the next
rotation correct it: distrusting the row there would drop the counts entirely
rather than merely delay them.

For the same reason, keep a row whose stamp cannot be reconciled with any
receipt at all. With no unthreaded receipt the comparison is against the user's
membership event, which a receipt from before their latest join can never
match -- and nothing recalculates such a row, since the receipt is not new.

(cherry picked from commit f18998e6ce)
2026-10-02 11:57:15 +02:00
..
2026-09-21 10:00:53 +01:00