guix/tests
Reepca Russelstein 78da695178
daemon: Explicitly unlock output path in the has-become-valid case.
Fixes <https://issues.guix.gnu.org/31785>.

Similar to <https://github.com/NixOS/nix/issues/178>, fixed in
<29cde917fe>.

We can't rely on Goal deletion to release our locks in a timely manner.  In
the case in which multiple guix-daemon processes simultaneously try producing
an output path path1, the one that gets there first (P1) will get the lock,
and the second one (P2) will continue trying to acquire the lock until it is
released.  Once it has acquired the lock, it checks to see whether the path
has already become valid in the meantime, and if so it reports success to
those Goals waiting on its completion and finishes.  Unfortunately, it fails
to release the locks it holds first, so those stay held until that Goal gets
deleted.

Suppose we have the following store path dependency graph:

          path4
      /     |     \
   path1   path2   path3

P2 is now sitting on path1's lock, and will continue to do so until path4 is
completed.  Suppose there is also a P3, and it has been blocked while P1
builds path2.  Now P3 is sitting on path2's lock, and can't acquire path1's
lock to determine that it has been completed.  Likewise P2 is sitting on
path1's lock, and now can't acquire path2's lock to determine that it has been
completed.  Finally, P3 completes path3 while P2 is blocked.

Now:

- P1 knows that path1 and path2 are complete, and holds no locks, but can't
  determine that path3 is complete
- P2 knows that path1 and path3 are complete, and holds locks on path1 and
  path3, but can't determine that path2 is complete
- P3 knows that path2 and path3 are complete, and holds a lock on path2, but
  can't determine that path1 is complete

And none of these locks will be released until path4 is complete.  Thus, we
have a deadlock.

To resolve this, we should explicitly release these locks as soon as they
should be released.

* nix/libstore/build.cc
  (DerivationGoal::tryToBuild, SubstitutionGoal::tryToRun):
  Explicitly release locks in the has-become-valid case.
* tests/store-deadlock.scm: New file.
* Makefile.am (SCM_TESTS): Add it.

Change-Id: Ie510f84828892315fe6776c830db33d0f70bcef8
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-12-30 00:51:57 +01:00
..
keys
services services: configuration: Use transducers within serialize-configuration. 2023-10-07 12:41:05 -04:00
accounts.scm accounts: Add /etc/subid and /etc/subgid allocation logic. 2024-12-18 18:32:40 +01:00
base16.scm
base32.scm
base64.scm
boot-parameters.scm
bournish.scm
build-emacs-utils.scm
build-utils.scm build: utils: Raise error in modify-phases upon missing key. 2024-08-31 10:42:06 +02:00
builders.scm git-download: Use “builtin:git-download” when available. 2023-09-26 17:36:58 +02:00
cache.scm cache: Avoid cache cleanup storms from concurrent processes. 2024-08-21 00:52:39 +02:00
challenge.scm
channels.scm channels: ‘latest-channel-instances’ traverses user-provided channels first. 2024-01-31 09:07:25 +01:00
combinators.scm
composer.scm guix: import: Add composer importer. 2023-12-18 23:16:28 +01:00
containers.scm linux-container: 'container-excursion' forks to join the PID namespace. 2023-01-30 22:24:27 +01:00
cpan.scm tests: Ensure 'cpan' updater test does not access the network. 2023-06-09 14:19:14 +02:00
cpio.scm utils: Don’t re-export ‘call-with-temporary-output-file’. 2024-04-15 22:36:42 +02:00
cran.scm
crate.scm Revert "import: crate: Emit new-style package inputs." 2024-09-19 12:41:54 +02:00
cve-sample.json
cve.scm
debug-link.scm
derivations.scm derivations: ‘derivation-build-plan’ returns builds in topological order. 2024-11-12 23:46:49 +01:00
discovery.scm
egg.scm utils: Don’t re-export ‘call-with-temporary-output-file’. 2024-04-15 22:36:42 +02:00
elm.scm tests: Adjust ‘elm’ importer test to expect inputs without labels. 2024-09-17 17:34:58 +02:00
elpa.scm tests: Ensure 'elpa' test does not access the network. 2023-06-09 14:19:14 +02:00
file-systems.scm
gem.scm import: utils: End package descriptions with period. 2024-06-03 22:58:53 +02:00
gexp.scm gexp: ‘imported-files’ does not create symlinks. 2024-09-16 00:16:20 +02:00
git-authenticate.scm tests: Assume ‘git’ is always available. 2023-09-26 17:36:59 +02:00
git.scm git: Remove untracked files from cached checkouts. 2024-07-18 17:31:19 +02:00
glob.scm
gnu-maintenance.scm tests: ‘rewrite-url’ test no longer depends on network access. 2023-09-27 23:38:21 +02:00
go.scm tests: Fix the 'go-module->guix-package' test. 2024-11-17 20:32:50 +09:00
grafts.scm grafts: Fix corner case involving multiple-output derivations. 2023-10-28 00:17:23 +02:00
graph.scm tests: Adjust 'node-back-edges' test for 'bag' to system-dependent glibc. 2023-08-21 16:16:47 +02:00
gremlin.scm tests: Fix gremlin.scm for GCC 14 2024-11-12 23:40:39 +01:00
guix-archive.sh tests: Fix checks for expected failures. 2023-04-21 16:16:38 +02:00
guix-authenticate.sh
guix-build-branch.sh tests: Fix checks for expected failures. 2023-04-21 16:16:38 +02:00
guix-build.sh tests: Adjust ‘guix build -P1’ test to new packages. 2024-12-02 23:18:52 +01:00
guix-daemon.sh tests: Fix checks for expected failures. 2023-04-21 16:16:38 +02:00
guix-describe.sh
guix-download.sh tests: Remove interference from the user’s Git config. 2024-05-13 16:31:35 +02:00
guix-environment-container.sh tests: Adjust to cope with glibc graft. 2023-10-28 01:30:37 +02:00
guix-environment.sh tests: Fix checks for expected failures. 2023-04-21 16:16:38 +02:00
guix-gc.sh tests: Fix checks for expected failures. 2023-04-21 16:16:38 +02:00
guix-git-authenticate.sh git authenticate: Record introduction and keyring in ‘.git/config’. 2024-05-01 17:26:18 +02:00
guix-graph.sh tests: Adjust ‘guix graph --path’ test to latest Emacs changes. 2023-09-26 17:36:57 +02:00
guix-hash.sh tests: Fix checks for expected failures. 2023-04-21 16:16:38 +02:00
guix-home.sh tests: guix-home: Fix description search for home-mcron. 2023-08-25 17:45:47 +02:00
guix-lint.sh
guix-locate.sh locate: Accept ‘--clear’ without additional arguments. 2023-11-15 18:29:37 +01:00
guix-pack-localstatedir.sh
guix-pack-relocatable.sh tests: Fix checks for expected failures. 2023-04-21 16:16:38 +02:00
guix-pack.sh tests: Adjust to cope with glibc graft. 2023-10-28 01:30:37 +02:00
guix-package-aliases.sh tests: Relax two tests that expected a non-zero error code. 2023-04-21 17:09:46 +02:00
guix-package-net.sh tests: Fix checks for expected failures. 2023-04-21 16:16:38 +02:00
guix-package.sh tests: guix-package: Fix guix package --search test. 2024-12-14 00:34:28 +01:00
guix-refresh.sh refresh: Add --target-version option. 2023-08-15 09:38:29 -04:00
guix-repl.sh
guix-shell-export-manifest.sh tests: guix-shell-export-manifest: Fix pyproject-build-system python test. 2024-12-14 01:28:49 +01:00
guix-shell.sh shell: ‘--development’ honors ‘--system’. 2023-12-06 23:50:04 +01:00
guix-style.sh scripts: style: Add 'alphabetical-sort' option. 2024-09-03 13:59:33 +02:00
guix-system.sh tests: Adjust ‘guix system’ test for EFI bootloader. 2024-06-13 22:34:00 +02:00
guix-time-machine.sh time-machine: Allow time travels to v0.16.0. 2024-03-11 22:12:34 +01:00
hackage.scm guix: import: Fix parsing Cabal files that import many stanzas 2023-12-03 16:15:29 +01:00
hexpm.scm import: utils: End package descriptions with period. 2024-06-03 22:58:53 +02:00
home-import.scm
home-services.scm
http-client.scm
import-git.scm tests: Assume ‘git’ is always available. 2023-09-26 17:36:59 +02:00
import-github.scm
import-utils.scm import: utils: Wrap function names in @code. 2024-12-03 16:59:54 +01:00
inferior.scm
ipfs.scm
lint.scm lint: More abbreviations. 2024-12-12 12:52:07 +01:00
minetest.scm import: utils: End package descriptions with period. 2024-06-03 22:58:53 +02:00
modules.scm build-systems: gnu: Export %default-gnu-imported-modules and %default-gnu-modules. 2024-08-31 10:42:16 +02:00
monads.scm
nar.scm
networking.scm services: ntp-service-type: Remove deprecated server as strings support. 2023-04-07 17:56:07 +02:00
npm-binary.scm import: Add binary npm importer. 2024-05-19 16:05:00 +02:00
offload.scm
opam.scm utils: Don’t re-export ‘call-with-temporary-output-file’. 2024-04-15 22:36:42 +02:00
openpgp.scm
pack.scm pack: Add support for AppImage pack format. 2024-11-23 16:30:17 +01:00
packages.scm packages: Add #:recursive? to ‘package-input-rewriting’. 2024-12-18 18:32:41 +01:00
pki.scm
print.scm tests: Make ‘tests/print.scm’ deterministic. 2024-09-28 00:20:18 +02:00
processes.scm
profiles.scm profiles: Use C.UTF-8 instead of ‘glibc-utf8-locales’ where possible. 2024-08-31 10:42:49 +02:00
publish.scm utils: Don’t re-export ‘call-with-temporary-output-file’. 2024-04-15 22:36:42 +02:00
pypi.scm import: pypi: Support extracting dependencies from pyproject.toml. 2024-12-16 19:27:43 +00:00
read-print.scm read-print: Properly indent ‘parameterize’. 2023-11-22 16:51:46 +01:00
records.scm tests: records: Add test for ellipsis in body. 2023-06-04 10:59:28 +02:00
rpm.scm pack: Add RPM format. 2023-02-19 21:13:23 -05:00
scripts.scm
search-paths.scm
services.scm gnu: services: Revert to deleting and updating all matching services 2023-08-31 23:31:50 -04:00
sets.scm
size.scm
status.scm
store-database.scm utils: Don’t re-export ‘call-with-temporary-output-file’. 2024-04-15 22:36:42 +02:00
store-deadlock.scm daemon: Explicitly unlock output path in the has-become-valid case. 2024-12-30 00:51:57 +01:00
store-deduplication.scm deduplication: Detect holes and create sparse files. 2024-05-25 16:44:42 +02:00
store-roots.scm tests: store-roots: Remove bogus test. 2023-08-18 16:10:08 +02:00
store.scm daemon: Implement ‘substitute-urls’ RPC. 2023-12-11 23:18:53 +01:00
style.scm style: Fix conversion of ‘unquote-splicing’ by ‘-S arguments’. 2024-06-03 22:58:52 +02:00
substitute.scm substitute: Do not exit when failing to find a nar. 2023-12-04 22:26:36 +01:00
swh.scm swh: ‘lookup-origin-revision’ handles branches pointing to directories. 2024-03-09 18:55:49 +01:00
syscalls.scm syscalls: Add ‘kexec-load-file’. 2024-12-28 22:32:38 +01:00
system.scm
test.drv
texlive.scm guix: import texlive: Add UPSTREAM-NAME property when necessary. 2024-08-31 10:45:37 +02:00
toml.scm guix: toml: Fix parsing empty strings in arrays. 2024-12-13 20:18:36 +00:00
transformations.scm transformations: ‘package-with-upstream-version’ can preserve patches. 2024-12-01 20:14:16 +01:00
ui.scm
union.scm
upstream.scm tests: upstream: Restore test that was skipped. 2023-05-31 23:25:25 +02:00
utils.scm utils: Don’t re-export ‘call-with-temporary-output-file’. 2024-04-15 22:36:42 +02:00
uuid.scm
workers.scm