Bug 1668 - image locking needed to prevent race conditions
: image locking needed to prevent race conditions
Status: RESOLVED FIXINSOURCE
Product: pkg
api-python
: unspecified
: i86pc/i386 OpenSolaris
: P3 normal (vote)
: ---
Assigned To: Shawn Walker
: pkg/api-python watcher
:
: sst-osp
:
:
: 7781 13873
  Show dependency treegraph
 
Reported: 2008-04-28 05:23 UTC by Vit Hrachovy
Modified: 2010-01-29 04:16 UTC (History)
9 users (show)

See Also:


Attachments
pkg install log (1.89 KB, text/plain)
2008-09-02 03:56 UTC, Vit Hrachovy
no flags Details


Note

You need to log in before you can comment on or make changes to this bug.


Description Vit Hrachovy 2008-04-28 05:23:39 UTC
pkg write operations is missing locking facility.

It's possible to run
  pfexec pkg install SUNWmysql5
from two different terminals at the same time.

Both appear to run and finish with success.


keyword: sst-osp
Comment 1 Vit Hrachovy 2008-04-28 06:06:38 UTC
To further clarify the importance of the issue:

The same goes when you uninstall package dependency of package currently being
installed.

In one terminal:
  pkg install SUNWbinutils

  pkg install SUNWgcc

In second terminal, while SUNWgcc is downloading/installing:
  pkg uninstall SUNWbinutils

SUNWgcc installation proceeds successfully even if dependency is missing.

This leads to broken functionality.
Comment 2 David Comay 2008-04-28 11:29:24 UTC
Moving to the correct Product/Component.
Comment 3 Dan Price 2008-04-29 22:12:42 UTC
Adjusting priority, severity, accepting.
Comment 4 Vit Hrachovy 2008-09-02 03:56:22 UTC
Created an attachment (id=462) [details]
pkg install log
Comment 5 Vit Hrachovy 2008-09-02 03:57:09 UTC
Another manifestation of this problem rises on system with
´flush-content-cache-on-success = True´ in /var/pkg/cfg_cache.

1. Issue two separate pkg installs 
2. one finishes first and starts deleting /var/pkg/download contents
3. the second one bails out with internal error (see the attachment) 

my pkg version is 093ca22da67c
Comment 6 Brock Pytlik 2008-12-22 11:38:26 UTC
*** Bug 4860 has been marked as a duplicate of this bug. ***
Comment 7 Brock Pytlik 2009-02-26 13:15:53 UTC
*** Bug 6909 has been marked as a duplicate of this bug. ***
Comment 8 Shawn Walker 2009-09-30 17:28:31 UTC
*** Bug 11639 has been marked as a duplicate of this bug. ***
Comment 9 Shawn Walker 2009-10-08 17:02:07 UTC
*** Bug 11760 has been marked as a duplicate of this bug. ***
Comment 10 Shawn Walker 2009-11-16 17:41:29 UTC
*** Bug 12693 has been marked as a duplicate of this bug. ***
Comment 11 Shawn Walker 2010-01-08 23:51:44 UTC
Starting work on this.
Comment 12 Shawn Walker 2010-01-13 18:41:43 UTC
Webrev and explanation of approach forthcoming.
Comment 13 Shawn Walker 2010-01-29 04:14:39 UTC
Implementation is roughly as follows:

When performing image-modifying operations (such as install, metadata refresh,
update, configuration change, etc.):

The API attempts to obtain an exclusive lock using lockf on the $IMGDIR/lock
file.  If it cannot, an ImageLockedError is raised with the information found
in the lock file as part of the error message.  If it obtains the lock, it
writes information about the caller into the lock file.

In addition, any time a plan is created for modifying the image (install,
update, repair, fix, etc.), a timestamp of the image's state is stored.  If
that state timestamp is different from the current one after obtaining the
image lock at the beginning of each phase of the operation (prepare,
preexecute, execute) an InvalidPlanError will be raised and the operation
aborted with an appropriate message.
Comment 14 Shawn Walker 2010-01-29 04:15:45 UTC
Resolved in changeset 1710 / 139720e2e756da4246adf44c7f9cdbcb77d185d6.