Fix recursive ingestion from lower store

This commit is contained in:
John Ericson 2023-05-09 16:42:28 -04:00
parent e7c3399ed2
commit 5059be53b1
2 changed files with 17 additions and 5 deletions

View file

@ -92,7 +92,12 @@ bool LocalOverlayStore::isValidPathUncached(const StorePath & path)
res = lowerStore->isValidPath(path); res = lowerStore->isValidPath(path);
if (res) { if (res) {
// Get path info from lower store so upper DB genuinely has it. // Get path info from lower store so upper DB genuinely has it.
LocalStore::registerValidPath(*lowerStore->queryPathInfo(path)); auto p = lowerStore->queryPathInfo(path);
// recur on references, syncing entire closure.
for (auto & r : p->references)
if (r != path)
isValidPath(r);
LocalStore::registerValidPath(*p);
} }
return res; return res;
} }

View file

@ -22,7 +22,8 @@ mkdir -p "$TEST_ROOT"/{store-a,store-b,merged-store/nix/store,workdir}
nix-store --store "$storeA" --add dummy nix-store --store "$storeA" --add dummy
# Build something in lower store # Build something in lower store
path=$(nix-build ./hermetic.nix --arg busybox "$busybox" --arg seed 1 --store "$storeA" --no-out-link) drvPath=$(nix-instantiate --store $storeA ./hermetic.nix --arg busybox "$busybox" --arg seed 1)
path=$(nix-store --store "$storeA" --realise $drvPath)
mount -t overlay overlay \ mount -t overlay overlay \
-o lowerdir="$storeA/nix/store" \ -o lowerdir="$storeA/nix/store" \
@ -38,9 +39,9 @@ cleanupOverlay () {
trap cleanupOverlay EXIT trap cleanupOverlay EXIT
toRealPath () { toRealPath () {
storeDir=$1; shift storeDir=$1; shift
storePath=$1; shift storePath=$1; shift
echo $storeDir$(echo $storePath | sed "s^$NIX_STORE_DIR^^") echo $storeDir$(echo $storePath | sed "s^$NIX_STORE_DIR^^")
} }
### Check status ### Check status
@ -60,6 +61,12 @@ nix-store --verify-path --store "$storeA" "$path"
# Verifying path in merged-store # Verifying path in merged-store
nix-store --verify-path --store "$storeB" "$path" nix-store --verify-path --store "$storeB" "$path"
[[ \
$(nix-store --store $storeA --query --outputs $drvPath) \
== \
$(nix-store --store $storeB --query --outputs $drvPath) \
]]
hashPart=$(echo $path | sed "s^$NIX_STORE_DIR/^^" | sed 's/-.*//') hashPart=$(echo $path | sed "s^$NIX_STORE_DIR/^^" | sed 's/-.*//')
# Lower store can find from hash part # Lower store can find from hash part