Opened 13 years ago

Last modified 6 years ago

#31056 new defect

Locking somewhat broken in MacPorts 2

Reported by: ryandesign (Ryan Carsten Schmidt) Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: base Version: 2.0.1
Keywords: Cc:
Port:

Description

There is something broken about locking ever since MacPorts 2.0.0.

Example 1: I tell MacPorts to uninstall a port, while some other port is installing; it tells me it's locked, but then silently doesn't complete the operation when the lock disappears. Retrying while MacPorts is not busy with other tasks works fine.

fossil $ sudo port uninstall
Waiting for lock on /opt/local/var/macports/registry/.registry.lock
fossil $ port installed fossil
The following ports are currently installed:
  fossil @20110523151112_1+universal (active)
fossil $ sudo port uninstall
Password:
--->  Deactivating fossil @20110523151112_1+universal
--->  Uninstalling fossil @20110523151112_1+universal
fossil $ 

Example 2: I tell MacPorts to upgrade a port, while some other port is busy; after the lock disappears, it tells me the port I asked to upgrade is not installed, but of course it is installed, and retrying the upgrade works fine.

$ sudo port -ud upgrade py26-docutils
Waiting for lock on /opt/local/var/macports/registry/.registry.lock
Error: py26-docutils is not installed
To report a bug, see <http://guide.macports.org/#project.tickets>
$ sudo port -ud upgrade py26-docutils
Password:
DEBUG: epoch: in tree: 0 installed: 0
DEBUG: py26-docutils 0.8.1_0 exists in the ports tree
DEBUG: py26-docutils 0.8_0  is the latest installed
DEBUG: py26-docutils 0.8_0  is active
[snip successful upgrade]
$

It does not seem to matter what ports are involved, or what MacPorts commands are being run; if an operation is being delayed via the lockfile, then it doesn't always run properly once the lock is removed.

The issue is intermittent so I think it's a race condition.

Change History (2)

comment:1 Changed 6 years ago by ryandesign (Ryan Carsten Schmidt)

Here is another instance of locking not working right, this one from MacPorts 2.4.2 on Mountain Lion. In one window I start to upgrade gnutls. While it is building, in another window, I upgrade libsoup which depends on glib-networking which depends on gnutls. It says it's waiting for a lock on gnutls, but once the first window finishes building gnutls and releases its lock and the second window gets it, it fails, while in the first window the upgrade of gnutls has successfully completed. Retrying the second window's upgrade of libsoup works.

$ sudo port -u upgrade libsoup
Waiting for lock on /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_gnutls/gnutls
/work/.macports.gnutls.state
--->  Computing dependencies for gnutls
Waiting for lock on /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_gnutls/gnutls
/work/.macports.gnutls.state
--->  Installing gnutls @3.5.16_0+universal
Error: Failed to install gnutls: sqlite error: columns name, epoch, version, revision, variants are not unique (19) while executing query: INSERT INTO r
egistry.ports (name, version, revision, variants, epoch) VALUES (?, ?, ?, ?, ?)
Error: See /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_gnutls/gnutls/main.log 
for details.
Error: Follow https://guide.macports.org/#project.tickets to report a bug.

comment:2 in reply to:  description Changed 6 years ago by jmroot (Joshua Root)

Replying to ryandesign:

Example 1: I tell MacPorts to uninstall a port, while some other port is installing; it tells me it's locked, but then silently doesn't complete the operation when the lock disappears. Retrying while MacPorts is not busy with other tasks works fine.

I can't reproduce this one, JFYI.

% sudo port uninstall testport3
Waiting for lock on /opt/local/var/macports/registry/.registry.lock
--->  Deactivating testport3 @1.0_0+python27
--->  Cleaning testport3
--->  Uninstalling testport3 @1.0_0+python27
--->  Cleaning testport3
Note: See TracTickets for help on using tickets.