fix(snapshot): unique staging directory per capture
VoidBuildSystem CI / 1 · Requirements (push) Successful in 8s
VoidBuildSystem CI / 2A · Linux build (debug) (push) Successful in 3m34s
VoidBuildSystem CI / 2A · Linux build (sanitizers) (push) Successful in 3m38s
VoidBuildSystem CI / 2A · Linux build (relwithdebinfo) (push) Successful in 4m8s
VoidBuildSystem CI / 3A · Linux test (debug) (push) Successful in 5m21s
VoidBuildSystem CI / 3A · Linux test (relwithdebinfo) (push) Successful in 5m6s
VoidBuildSystem CI / 3A · Linux test (sanitizers) (push) Successful in 49s
VoidBuildSystem CI / 4A · Linux package (debug) (push) Successful in 1m1s
VoidBuildSystem CI / 4A · Linux package (relwithdebinfo) (push) Successful in 1m13s
VoidBuildSystem CI / 4A · Linux package (sanitizers) (push) Successful in 1m13s
VoidBuildSystem CI / 2B · Windows Wine build (debug) (push) Successful in 1m34s
VoidBuildSystem CI / 2B · Windows Wine build (relwithdebinfo) (push) Successful in 2m53s
VoidBuildSystem CI / 3B · Windows Wine test (debug) (push) Successful in 15s
VoidBuildSystem CI / 3B · Windows Wine test (relwithdebinfo) (push) Successful in 17s
VoidBuildSystem CI / 4B · Windows package (debug) (push) Successful in 16s
VoidBuildSystem CI / 4B · Windows package (relwithdebinfo) (push) Successful in 29s
VoidBuildSystem CI / 4A2 · VBS installers (self-hosted) (push) Failing after 1m0s
VoidBuildSystem CI / 5 · Release (push) Skipped
VoidBuildSystem CI / 4A2 · VBS installers (windows target) (push) Failing after 1m2s

Concurrent captures in one process share the pid, so they used the same
staging tree: one capture's initial remove_all could delete files another
had already copied, sealing an incomplete content-addressed tree (the
installer jobs then failed with missing VoidLibrary sources). Add a
process-wide sequence to the staging name.

Verified: the self-hosted VBS install still succeeds locally.
This commit is contained in:
faumaray committed 2026-12-06 10:29:28 +03:00
1 parent b92fd9b1fd
commit 4f70e0640c
1 file changed
+9 -3
+9 -3
View File
@@ -492,9 +492,15 @@ Void::Result::Result<InputSnapshot, Void::Result::Error> capture_snapshot(
snap.materialized_root = options.snapshot_store_dir / "trees" / snap.snapshot_id; snap.materialized_root = options.snapshot_store_dir / "trees" / snap.snapshot_id;
const auto seal_marker = snap.materialized_root / ".sealed"; const auto seal_marker = snap.materialized_root / ".sealed";
if (!std::filesystem::exists(seal_marker, ec)) { if (!std::filesystem::exists(seal_marker, ec)) {
const auto tmp_tree = options.snapshot_store_dir / "trees" / // Unique per capture: concurrent captures in one process share the
(snap.snapshot_id + ".staging_" + // pid, and a shared staging directory lets one capture remove files
std::to_string(static_cast<long long>(::getpid()))); // another has already copied (sealing an incomplete tree).
static std::atomic<std::uint64_t> staging_sequence{0};
const auto tmp_tree =
options.snapshot_store_dir / "trees" /
(snap.snapshot_id + ".staging_" +
std::to_string(static_cast<long long>(::getpid())) + "_" +
std::to_string(staging_sequence.fetch_add(1, std::memory_order_relaxed)));
std::filesystem::remove_all(tmp_tree, ec); std::filesystem::remove_all(tmp_tree, ec);
std::filesystem::create_directories(tmp_tree, ec); std::filesystem::create_directories(tmp_tree, ec);