Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix bug where we clobbered old state group values
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Dec 10, 2014
1 parent cabead6 commit 1d2a004
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
9 changes: 9 additions & 0 deletions synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@ def do_invite_join(self, target_host, room_id, joinee, content, snapshot):
event.get_pdu_json()
)

handled_events = set()

try:
builder.event_id = self.event_factory.create_event_id()
builder.origin = self.hs.hostname
Expand All @@ -371,6 +373,10 @@ def do_invite_join(self, target_host, room_id, joinee, content, snapshot):
auth_chain = ret["auth_chain"]
auth_chain.sort(key=lambda e: e.depth)

handled_events.update([s.event_id for s in state])
handled_events.update([a.event_id for a in auth_chain])
handled_events.add(new_event.event_id)

logger.debug("do_invite_join auth_chain: %s", auth_chain)
logger.debug("do_invite_join state: %s", state)

Expand Down Expand Up @@ -426,6 +432,9 @@ def do_invite_join(self, target_host, room_id, joinee, content, snapshot):
del self.room_queues[room_id]

for p, origin in room_queue:
if p.event_id in handled_events:
continue

try:
self.on_receive_pdu(origin, p, backfilled=False)
except:
Expand Down
3 changes: 2 additions & 1 deletion synapse/storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ def _persist_event_txn(self, txn, event, context, backfilled,
room_id=event.room_id,
)

self._store_state_groups_txn(txn, event, context)
if not outlier:
self._store_state_groups_txn(txn, event, context)

if current_state:
txn.execute(
Expand Down
3 changes: 2 additions & 1 deletion synapse/storage/schema/state.sql
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ CREATE TABLE IF NOT EXISTS state_groups_state(

CREATE TABLE IF NOT EXISTS event_to_state_groups(
event_id TEXT NOT NULL,
state_group INTEGER NOT NULL
state_group INTEGER NOT NULL,
CONSTRAINT event_to_state_groups_uniq UNIQUE (event_id)
);

CREATE INDEX IF NOT EXISTS state_groups_id ON state_groups(id);
Expand Down

0 comments on commit 1d2a004

Please sign in to comment.