-
Notifications
You must be signed in to change notification settings - Fork 301
fix: close stale S3BucketRegionCache on session refresh; guard _sessions=None; serialize set_session() under asyncio.Lock #1028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
josh-ag2
wants to merge
5
commits into
fsspec:main
from
josh-ag2:fix/close-stale-region-cache-on-refresh
+117
−34
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a09bb3a
fix: close stale S3BucketRegionCache on session refresh
josh-ag2 955c652
fix: remove premature close() method; guard stale-session check vs _s…
josh-ag2 eedacd6
fix: serialize set_session() under asyncio.Lock; fix spurious refresh…
josh-ag2 831a866
fix: move _setup_lock to __init__; treat sessions=None as stale
josh-ag2 7b36fd3
refactor: move kwargs setup before lock per reviewer suggestion
josh-ag2 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 hidden or 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
This file contains hidden or 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
This file contains hidden or 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.
Since there was noawaitbetween creation of the lock and acquiring it, no other coroutine could have run. The only way the lock might have been acquired is in another thread - but asyncio threads are not thread-safe anyway (and all async code should be running in the one event loop on the one thread)OK, so the model is, that one coroutine might have run to the
awaitsbelow (get_client,__aenter__) while this coroutine is waiting for the lock?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.
Yes, that's exactly right. A coroutine can yield control at the
await get_client(...)andawait __aenter__()calls below the lock, allowing a sibling coroutine (e.g. launched viaasyncio.gather) to also enterset_session()while the first is suspended. Without the lock they'd each create a separate_s3creator, and when the first resumes and replacesself._s3creator, it calls__aexit__on the stale one — tearing down a session the sibling is still actively using.