This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Ensure we always drop the federation inbound lock #10336
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't help wondering if
Lock
should really be implementing the context manager interface. What's the advantage over just mandating that people calllock.release()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I find using a context manager interface clearer than using a
try/finally
. We could also have an explicitlock.release()
to use hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well maybe, but that seems a bit irrelevant.
basically:
seems a more intuitive way of dropping a lock than
I think it's basically a bit silly to have an
aenter
which does nothing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a
lock.release()
methodHow so? The other place we use the
async with lock
we'd need to convert to atry/finally
if we got rid of the context manager.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see. Well, yes, we would, and tbh I think that would be an improvement. Currently it looks like something magical happens at the start of that
async with
block, which is misleading. Thewith
mechanism doesn't really work very well here, because in each case we already hold the resource (ie, the lock) when we enter thewith
block.Instead we could put the whole body of
_process_incoming_pdus_in_room_inner
inside atry
block:... thus ensuring that we always drop the lock even if we end up bailing out at odd points due to exceptions or whatever.
Anyway, what you have now is fine.