mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-02-07 18:57:19 +02:00
LocalStore::addTempRoot(): Handle ENOENT
If the garbage collector has acquired the global GC lock, but hasn't created the GC socket yet, then a client attempting to connect would get ENOENT. Note that this only happens when the GC runs for the first time on a machine. Subsequently clients will get ECONNREFUSED which was already handled. Fixes #7370.
This commit is contained in:
parent
f5e620bf2b
commit
c5fdbdae32
2 changed files with 15 additions and 5 deletions
|
@ -138,9 +138,9 @@ void LocalStore::addTempRoot(const StorePath & path)
|
||||||
try {
|
try {
|
||||||
nix::connect(fdRootsSocket->get(), socketPath);
|
nix::connect(fdRootsSocket->get(), socketPath);
|
||||||
} catch (SysError & e) {
|
} catch (SysError & e) {
|
||||||
/* The garbage collector may have exited, so we need to
|
/* The garbage collector may have exited or not
|
||||||
restart. */
|
created the socket yet, so we need to restart. */
|
||||||
if (e.errNo == ECONNREFUSED) {
|
if (e.errNo == ECONNREFUSED || e.errNo == ENOENT) {
|
||||||
debug("GC socket connection refused");
|
debug("GC socket connection refused");
|
||||||
fdRootsSocket->close();
|
fdRootsSocket->close();
|
||||||
goto restart;
|
goto restart;
|
||||||
|
@ -503,6 +503,11 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
|
||||||
auto fdGCLock = openGCLock();
|
auto fdGCLock = openGCLock();
|
||||||
FdLock gcLock(fdGCLock.get(), ltWrite, true, "waiting for the big garbage collector lock...");
|
FdLock gcLock(fdGCLock.get(), ltWrite, true, "waiting for the big garbage collector lock...");
|
||||||
|
|
||||||
|
/* Synchronisation point to test ENOENT handling in
|
||||||
|
addTempRoot(), see tests/gc-non-blocking.sh. */
|
||||||
|
if (auto p = getEnv("_NIX_TEST_GC_SYNC_2"))
|
||||||
|
readFile(*p);
|
||||||
|
|
||||||
/* Start the server for receiving new roots. */
|
/* Start the server for receiving new roots. */
|
||||||
auto socketPath = stateDir.get() + gcSocketPath;
|
auto socketPath = stateDir.get() + gcSocketPath;
|
||||||
createDirs(dirOf(socketPath));
|
createDirs(dirOf(socketPath));
|
||||||
|
@ -772,7 +777,7 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Synchronisation point for testing, see tests/gc-concurrent.sh. */
|
/* Synchronisation point for testing, see tests/gc-non-blocking.sh. */
|
||||||
if (auto p = getEnv("_NIX_TEST_GC_SYNC"))
|
if (auto p = getEnv("_NIX_TEST_GC_SYNC"))
|
||||||
readFile(*p);
|
readFile(*p);
|
||||||
|
|
||||||
|
|
|
@ -9,16 +9,21 @@ clearStore
|
||||||
fifo=$TEST_ROOT/test.fifo
|
fifo=$TEST_ROOT/test.fifo
|
||||||
mkfifo "$fifo"
|
mkfifo "$fifo"
|
||||||
|
|
||||||
|
fifo2=$TEST_ROOT/test2.fifo
|
||||||
|
mkfifo "$fifo2"
|
||||||
|
|
||||||
dummy=$(nix store add-path ./simple.nix)
|
dummy=$(nix store add-path ./simple.nix)
|
||||||
|
|
||||||
running=$TEST_ROOT/running
|
running=$TEST_ROOT/running
|
||||||
touch $running
|
touch $running
|
||||||
|
|
||||||
(_NIX_TEST_GC_SYNC=$fifo nix-store --gc -vvvvv; rm $running) &
|
(_NIX_TEST_GC_SYNC=$fifo _NIX_TEST_GC_SYNC_2=$fifo2 nix-store --gc -vvvvv; rm $running) &
|
||||||
pid=$!
|
pid=$!
|
||||||
|
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
|
(sleep 1; echo > $fifo2) &
|
||||||
|
|
||||||
outPath=$(nix-build --max-silent-time 60 -o "$TEST_ROOT/result" -E "
|
outPath=$(nix-build --max-silent-time 60 -o "$TEST_ROOT/result" -E "
|
||||||
with import ./config.nix;
|
with import ./config.nix;
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
|
|
Loading…
Add table
Reference in a new issue