Ensure we don't use unpersisted state group as prev group

This commit is contained in:
Erik Johnston 2017-06-08 11:59:57 +01:00
parent c62c480dc6
commit ea11ee09f3
2 changed files with 19 additions and 7 deletions

View file

@ -223,6 +223,19 @@ class StateStore(SQLBaseStore):
# We persist as a delta if we can, while also ensuring the chain
# of deltas isn't tooo long, as otherwise read performance degrades.
if context.prev_group:
is_in_db = self._simple_select_one_onecol_txn(
txn,
table="state_groups",
keyvalues={"id": context.prev_group},
retcol="id",
allow_none=True,
)
if not is_in_db:
raise Exception(
"Trying to persist state with unpersisted prev_group: %r"
% (context.prev_group,)
)
potential_hops = self._count_state_group_hops_txn(
txn, context.prev_group
)