forked-synapse/synapse/storage
Sean Quah 882277008c
Fix background updates failing to add unique indexes on receipts (#14453)
As part of the database migration to support threaded receipts, there is
a possible window in between
`73/08thread_receipts_non_null.sql.postgres` removing the original
unique constraints on `receipts_linearized` and `receipts_graph` and the
`reeipts_linearized_unique_index` and `receipts_graph_unique_index`
background updates from `72/08thread_receipts.sql` completing where
the unique constraints on `receipts_linearized` and `receipts_graph` are
missing. Any emulated upserts on these tables must therefore be
performed with a lock held, otherwise duplicate rows can end up in the
tables when there are concurrent emulated upserts. Fix the missing lock.

Note that emulated upserts no longer happen by default on sqlite, since
the minimum supported version of sqlite supports native upserts by
default now.

Finally, clean up any duplicate receipts that may have crept in before
trying to create the `receipts_graph_unique_index` and
`receipts_linearized_unique_index` unique indexes.

Signed-off-by: Sean Quah <seanq@matrix.org>
2022-11-16 15:01:22 +00:00
..
controllers Clean-up events persistance code (#14411) 2022-11-14 08:13:11 -05:00
databases Fix background updates failing to add unique indexes on receipts (#14453) 2022-11-16 15:01:22 +00:00
engines Drop support for Postgres 10 in full text search code. (#14397) 2022-11-09 09:55:34 -05:00
schema Fix PostgreSQL sometimes using table scans for event_search (#14409) 2022-11-10 19:02:27 +00:00
util Revert "Remove slaved id tracker (#14376)" (#14463) 2022-11-16 13:50:07 +00:00
__init__.py Rename storage classes (#12913) 2022-05-31 12:17:50 +00:00
_base.py Bump flake8-bugbear from 22.9.23 to 22.10.27 (#14329) 2022-11-04 18:43:14 +00:00
background_updates.py Generate separate snapshots for logical databases (#13792) 2022-09-20 14:14:12 +01:00
database.py When restarting a partial join resync, prioritise the server which actioned a partial join (#14126) 2022-10-18 12:33:18 +01:00
keys.py Use auto_attribs/native type hints for attrs classes. (#11692) 2022-01-13 13:49:28 +00:00
prepare_database.py Snapshot schema 72 (#13873) 2022-09-26 18:28:32 +01:00
push_rule.py Remove redundant "coding: utf-8" lines (#9786) 2021-04-14 15:34:27 +01:00
roommember.py Do not include rooms with an unknown room version in a sync response. (#10644) 2021-08-19 11:12:55 -04:00
state.py Update the rejected state of events during resync (#13459) 2022-08-11 10:42:24 +00:00
types.py Tidy up and type-hint the database engine modules (#12734) 2022-05-17 00:34:38 +01:00