Skip to content
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

Fix deadlock when a path is re-locked while the cache is locked globally #133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions yas3fs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,16 @@ def get_lock(self, path, skip_is_ready = False, wait_until_cleared_proplist = No
if not skip_is_ready:
self.is_ready(path, proplist = wait_until_cleared_proplist)

# Work around a deadlock when operations such as flush_all_caches lock the global cache
# and do operations that perform path-based locks while a worker holding onto a path-based
# lock tries to re-lock it. The global operation will block waiting for the worker to give
# the path-based lock, while the worker blocks waiting for the global lock, completely
# locking up the FS
entry = self.entries.get(path) or {}
existing_lock = entry.get('lock')
if existing_lock and existing_lock._RLock__owner == threading.current_thread().ident:
return existing_lock

with self.lock: # Global cache lock, used only for giving file-level locks
try:
return self.entries[path]['lock']
Expand Down