From: Zac Medico <zmedico@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Cc: Zac Medico <zmedico@gentoo.org>
Subject: [gentoo-portage-dev] [PATCH] dblink.treewalk: lock for parallel-install with blockers (bug 576888)
Date: Wed, 9 Mar 2016 13:57:23 -0800 [thread overview]
Message-ID: <1457560643-21014-1-git-send-email-zmedico@gentoo.org> (raw)
For parallel-install, lock when interacting with blocked packages, in
order to account for blocked packages being removed or replaced
concurrently.
X-Gentoo-Bug: 576888
X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=576888
---
pym/portage/dbapi/vartree.py | 45 ++++++++++++++++++++++++++++++++++----------
1 file changed, 35 insertions(+), 10 deletions(-)
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index e7effca..6d4514c 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -3932,9 +3932,25 @@ class dblink(object):
blockers = self._blockers
if blockers is None:
blockers = []
- collisions, dirs_ro, symlink_collisions, plib_collisions = \
- self._collision_protect(srcroot, destroot,
- others_in_slot + blockers, filelist, linklist)
+
+ # For parallel-install, acquire a lock to interact
+ # with blocked packages.
+ with_lock = bool(blockers) and "parallel-install" in self.settings.features
+
+ if with_lock:
+ self.lockdb()
+ self.vartree.dbapi._fs_lock()
+ # Filter out any blocked packages that may have
+ # been uninstalled concurrently.
+ blockers = [blocker for blocker in blockers if blocker.exists()]
+ try:
+ collisions, dirs_ro, symlink_collisions, plib_collisions = \
+ self._collision_protect(srcroot, destroot,
+ others_in_slot + blockers, filelist, linklist)
+ finally:
+ if with_lock:
+ self.vartree.dbapi._fs_unlock()
+ self.unlockdb()
# Check for read-only filesystems.
ro_checker = get_ro_checker()
@@ -4290,13 +4306,22 @@ class dblink(object):
self._clear_contents_cache()
contents = self.getcontents()
destroot_len = len(destroot) - 1
- self.lockdb()
- try:
- for blocker in blockers:
- self.vartree.dbapi.removeFromContents(blocker, iter(contents),
- relative_paths=False)
- finally:
- self.unlockdb()
+
+ if blockers:
+ self.lockdb()
+ self.vartree.dbapi._fs_lock()
+ try:
+ for blocker in blockers:
+ # Blocked packages may have been removed
+ # or replaced concurrently, so check if
+ # they still exist, and clear contents cache.
+ if blocker.exists():
+ blocker._clear_contents_cache()
+ self.vartree.dbapi.removeFromContents(blocker,
+ iter(contents), relative_paths=False)
+ finally:
+ self.vartree.dbapi._fs_unlock()
+ self.unlockdb()
plib_registry = self.vartree.dbapi._plib_registry
if plib_registry:
--
2.4.10
next reply other threads:[~2016-03-09 21:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-09 21:57 Zac Medico [this message]
2016-03-09 22:27 ` [gentoo-portage-dev] Re: [PATCH] dblink.treewalk: lock for parallel-install with blockers (bug 576888) Zac Medico
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1457560643-21014-1-git-send-email-zmedico@gentoo.org \
--to=zmedico@gentoo.org \
--cc=gentoo-portage-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox