Correctly handle reindexing state groups that already have an edge

This commit is contained in:
Erik Johnston 2016-09-05 15:07:23 +01:00
parent 9e6d88f4e2
commit a7032abb2e
1 changed files with 19 additions and 0 deletions

View File

@ -673,6 +673,17 @@ class StateStore(SQLBaseStore):
if not row or not state_group:
return True, count
txn.execute(
"SELECT state_group FROM state_group_edges"
" WHERE state_group = ?",
(state_group,)
)
# If we reach a point where we've already started inserting
# edges we should stop.
if txn.fetchall():
return True, count
txn.execute(
"SELECT coalesce(max(id), 0) FROM state_groups"
" WHERE id < ? AND room_id = ?",
@ -709,6 +720,14 @@ class StateStore(SQLBaseStore):
if prev_state.get(key, None) != value
}
self._simple_delete_txn(
txn,
table="state_group_edges",
keyvalues={
"state_group": state_group,
}
)
self._simple_insert_txn(
txn,
table="state_group_edges",