summary refs log tree commit diff
path: root/synapse/storage/state.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-09-05 15:07:23 +0100
committerErik Johnston <erik@matrix.org>2016-09-05 15:07:23 +0100
commita7032abb2e64f79be5823b770230cb223cc22ff1 (patch)
tree0e37d67a9eaa0252e7a8c663237f3eaee6ef1e8d /synapse/storage/state.py
parentMerge branch 'develop' of github.com:matrix-org/synapse into erikj/state_storage (diff)
downloadsynapse-a7032abb2e64f79be5823b770230cb223cc22ff1.tar.xz
Correctly handle reindexing state groups that already have an edge
Diffstat (limited to 'synapse/storage/state.py')
-rw-r--r--synapse/storage/state.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/synapse/storage/state.py b/synapse/storage/state.py

index 589a4fec6e..af3ddd962d 100644 --- a/synapse/storage/state.py +++ b/synapse/storage/state.py
@@ -674,6 +674,17 @@ class StateStore(SQLBaseStore): 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 = ?", (state_group, 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",