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

Commit

Permalink
Ensure we always drop the federation inbound lock (#10336)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Jul 9, 2021
1 parent 974261c commit 1579fdd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/10336.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix bug where inbound federation in a room could be delayed due to not correctly dropping a lock. Introduced in v1.37.1.
1 change: 1 addition & 0 deletions synapse/federation/federation_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,7 @@ async def _process_incoming_pdus_in_room_inner(
room_id, room_version
)
if not next:
await lock.release()
return

origin, event = next
Expand Down
15 changes: 13 additions & 2 deletions synapse/storage/databases/main/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,25 @@ async def __aexit__(
_excinst: Optional[BaseException],
_exctb: Optional[TracebackType],
) -> bool:
await self.release()

return False

async def release(self) -> None:
"""Release the lock.
This is automatically called when using the lock as a context manager.
"""

if self._dropped:
return

if self._looping_call.running:
self._looping_call.stop()

await self._store._drop_lock(self._lock_name, self._lock_key, self._token)
self._dropped = True

return False

def __del__(self) -> None:
if not self._dropped:
# We should not be dropped without the lock being released (unless
Expand Down

0 comments on commit 1579fdd

Please sign in to comment.