synapse-product/synapse/storage
Erik Johnston 664409b169
Fix bug in account data replication stream. (#7656)
* Ensure account data stream IDs are unique.

The account data stream is shared between three tables, and the maximum
allocated ID was tracked in a dedicated table. Updating the max ID
happened outside the transaction that allocated the ID, leading to a
race where if the server was restarted then the same ID could be
allocated but the max ID failed to be updated, leading it to be reused.

The ID generators have support for tracking across multiple tables, so
we may as well use that instead of a dedicated table.

* Fix bug in account data replication stream.

If the same stream ID was used in both global and room account data then
the getting updates for the replication stream would fail due to
`heapq.merge(..)` trying to compare a `str` with a `None`. (This is
because you'd have two rows like `(534, '!room')` and `(534, None)` from
the room and global account data tables).

Fix is just to order by stream ID, since we don't rely on the ordering
beyond that. The bug where stream IDs can be reused should be fixed now,
so this case shouldn't happen going forward.

Fixes #7617
2020-06-09 16:28:57 +01:00
..
data_stores Fix bug in account data replication stream. (#7656) 2020-06-09 16:28:57 +01:00
engines Persist user interactive authentication sessions (#7302) 2020-04-30 13:47:49 -04:00
schema Only run one background update at a time 2020-03-31 17:43:58 +01:00
util Move event stream handling out of slave store. (#7491) 2020-05-15 16:43:59 +01:00
__init__.py Move are_all_users_on_domain checks to main data store. 2019-12-06 13:43:40 +00:00
_base.py remove builtins.buffer code from storage code 2020-05-15 19:37:41 +01:00
background_updates.py Update docstring per review comments 2020-04-03 10:51:32 +01:00
database.py Replace device_27_unique_idx bg update with a fg one (#7562) 2020-05-26 11:43:17 +01:00
keys.py Move storage classes into a main "data store". 2019-10-21 16:05:06 +01:00
persist_events.py Add option to move event persistence off master (#7517) 2020-05-22 16:11:35 +01:00
prepare_database.py Fix bug in account data replication stream. (#7656) 2020-06-09 16:28:57 +01:00
presence.py Move storage classes into a main "data store". 2019-10-21 16:05:06 +01:00
purge_events.py Fix purge_room admin API (#6711) 2020-01-15 18:13:47 +00:00
push_rule.py Move storage classes into a main "data store". 2019-10-21 16:05:06 +01:00
relations.py Move storage classes into a main "data store". 2019-10-21 16:05:06 +01:00
roommember.py Move storage classes into a main "data store". 2019-10-21 16:05:06 +01:00
state.py Add StateMap type alias (#6715) 2020-01-16 13:31:22 +00:00
types.py Add some type annotations in synapse.storage (#6987) 2020-02-27 11:53:40 +00:00