-
Couldn't load subscription status.
- Fork 2.7k
Closed
Labels
C-bugCategory: bugCategory: bug
Description
Problem
There is a race condition when building multiple projects concurrently that depend on the same crates. When extracting crates from a local registry, the crate is opened as read-only with shared locks (https://github.com/rust-lang/cargo/blob/master/src/cargo/sources/registry/local.rs#L74). Unpacking the crate is assumed to be safe due to the tar file being locked (https://github.com/rust-lang/cargo/blob/master/src/cargo/sources/registry/mod.rs#L428).
Output of build failure:
Unpacking form v0.4.0 (registry `file:///home/builduser/cargo_registry/latest`)
Unpacking svd2rust v0.14.0 (registry `file:///home/builduser/cargo_registry/latest`)
Installing svd2rust v0.14.0
Installing form v0.4.0
Unpacking log v0.4.6 (registry `file:///home/builduser/cargo_registry/latest`)
Unpacking cast v0.2.2 (registry `file:///home/builduser/cargo_registry/latest`)
Unpacking getopts v0.2.18 (registry `file:///home/builduser/cargo_registry/latest`)
Unpacking svd-parser v0.6.0 (registry `file:///home/builduser/cargo_registry/latest`)
Unpacking failure v0.1.3 (registry `file:///home/builduser/cargo_registry/latest`)
Unpacking quote v0.3.15 (registry `file:///home/builduser/cargo_registry/latest`)
Unpacking env_logger v0.5.13 (registry `file:///home/builduser/cargo_registry/latest`)
Unpacking clap v2.32.0 (registry `file:///home/builduser/cargo_registry/latest`)
Unpacking syn v0.11.11 (registry `file:///home/builduser/cargo_registry/latest`)
Unpacking syn v0.11.11 (registry `file:///home/builduser/cargo_registry/latest`)
error: failed to compile `form v0.4.0`, intermediate artifacts can be found at `/tmp/cargo-installKeMHuZ`
Caused by:
unable to get packages from source
Caused by:
failed to download replaced source registry `https://github.com/rust-lang/crates.io-index`
Caused by:
failed to unpack package `syn v0.11.11 (registry `file:///home/builduser/cargo_registry/latest`)`
Caused by:
failed to unpack entry at `syn-0.11.11/src/aster/mod.rs`
Caused by:
failed to unpack `/home/builduser/.cargo/registry/src/-39fe0c9a09214cd4/syn-0.11.11/src/aster/mod.rs`
Steps
- Create a local registry.
- Clear the local crate source cache.
- Execute two builds at the same time.
Possible Solution(s)
- Lock the crate file on the local registry. This is not ideal, as the local registry might be read-only or an NFS mount.
- Copy the crate file to the registry cache in
$CARGO_HOME, exclusively locking that copy. - Locking an empty file in
$CARGO_HOME.
Notes
Output of cargo version:
cargo 1.29.0 (524a578d7 2018-08-05)
Metadata
Metadata
Assignees
Labels
C-bugCategory: bugCategory: bug