mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
f112cfe5bb
On startup `MultiWriteIdGenerator` fetches the maximum stream ID for each instance from the table and uses that as its initial "current position" for each writer. This is problematic as a) it involves either a scan of events table or an index (neither of which is ideal), and b) if rows are being persisted out of order elsewhere while the process restarts then using the maximum stream ID is not correct. This could theoretically lead to race conditions where e.g. events that are persisted out of order are not sent down sync streams. We fix this by creating a new table that tracks the current positions of each writer to the stream, and update it each time we finish persisting a new entry. This is a relatively small overhead when persisting events. However for the cache invalidation stream this is a much bigger relative overhead, so instead we note that for invalidation we don't actually care about reliability over restarts (as there's no caches to invalidate) and simply don't bother reading and writing to the new table in that particular case. |
||
---|---|---|
.. | ||
02remove_dup_outbound_pokes.sql | ||
03persist_ui_auth.sql | ||
05cache_instance.sql.postgres | ||
06dlols_unique_idx.py | ||
07add_method_to_thumbnail_constraint.sql.postgres | ||
07add_method_to_thumbnail_constraint.sql.sqlite | ||
07persist_ui_auth_ips.sql | ||
08_media_safe_from_quarantine.sql.postgres | ||
08_media_safe_from_quarantine.sql.sqlite | ||
09shadow_ban.sql | ||
10_pushrules_enabled_delete_obsolete.sql | ||
10drop_local_rejections_stream.sql | ||
10federation_pos_instance_name.sql | ||
11user_id_seq.py | ||
12room_stats.sql | ||
13remove_presence_allow_inbound.sql | ||
14events_instance_name.sql | ||
14events_instance_name.sql.postgres | ||
15_catchup_destination_rooms.sql | ||
15unread_count.sql | ||
16populate_stats_process_rooms_fix.sql | ||
17_catchup_last_successful.sql | ||
18stream_positions.sql |