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

locks: allow locks to work under high contention #27846

Merged
merged 2 commits into from
Dec 22, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/spack/spack/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ def _check_deps_status(self, request):
# Attempt to get a write lock to ensure another process does not
# uninstall the dependency while the requested spec is being
# installed
ltype, lock = self._ensure_locked('write', dep_pkg)
ltype, lock = self._ensure_locked('read', dep_pkg)
if lock is None:
msg = '{0} is write locked by another process'.format(dep_id)
raise InstallError(err.format(request.pkg_id, msg))
Expand All @@ -816,6 +816,8 @@ def _check_deps_status(self, request):
tty.debug('Flagging {0} as installed per the database'
.format(dep_id))
self._flag_installed(dep_pkg)
else:
lock.release_read()

def _prepare_for_install(self, task):
"""
Expand Down Expand Up @@ -1027,7 +1029,7 @@ def _ensure_locked(self, lock_type, pkg):
except (lk.LockDowngradeError, lk.LockTimeoutError) as exc:
tty.debug(err.format(op, desc, pkg_id, exc.__class__.__name__,
str(exc)))
lock = None
return (lock_type, None)

except (Exception, KeyboardInterrupt, SystemExit) as exc:
tty.error(err.format(op, desc, pkg_id, exc.__class__.__name__,
Expand Down Expand Up @@ -1627,6 +1629,7 @@ def install(self):
# established by the other process -- failed, installed, or
# uninstalled -- on the next pass.
if ltype == 'read':
lock.release_read()
self._requeue_task(task)
continue

Expand Down