tvl-depot/tools
talyz 28417afbb4 fix(nixery): Avoid race when the same image is fetched in parallel
Remove a race condition which appears when uploadHashLayer is called
with the same key from multiple threads simultaneously. This can
easily happen when the same image path is requested by multiple
clients at the same time. When it does, a 500 status is returned and
the following error message is logged:

{
  "context": {
    "filePath": "github.com/google/nixery/builder/builder.go",
    "lineNumber": 440,
    "functionName": "github.com/google/nixery/builder.uploadHashLayer"
  },
  "error": "rename /var/lib/nixery/staging/<hash> /var/lib/nixery/layers/<hash>: no such file or directory",
  "eventTime": "...",
  "layer": "<hash>",
  "message": "failed to move layer from staging",
  ...
}

To solve this issue, introduce a mutex keyed on the uploaded hash and
move all layer caching into uploadHashLayer. This could additionally
provide a small performance benefit when an already built image is
requested and NIXERY_PKGS_PATH is set, since symlink layers and config
layers are now also cached.

Change-Id: I50788a7ec7940cb5e5760f244692e361019a9bb7
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6695
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
2022-09-19 11:28:10 +00:00
..
checks fix(tools/checks): Minor typo fix 2022-06-07 10:46:15 +00:00
cheddar chore(tools/cheddar): bump cargo dependencies 2022-08-22 21:15:01 +00:00
depot-scanner chore(gerrit): migrate OWNERS files to code-owners style 2022-09-19 11:13:28 +00:00
emacs-pkgs chore(gerrit): migrate OWNERS files to code-owners style 2022-09-19 11:13:28 +00:00
magrathea feat(tools/magrathea): add repl command 2022-06-01 10:32:01 +00:00
nixery fix(nixery): Avoid race when the same image is fetched in parallel 2022-09-19 11:28:10 +00:00
nsfv-setup style: format entire depot with nixpkgs-fmt 2022-01-31 16:11:53 +00:00
releases fix(tools/releases): Explicitly set release phase in filteredGitPush 2022-06-06 12:02:26 +00:00
rust-crates-advisory chore(gerrit): migrate OWNERS files to code-owners style 2022-09-19 11:13:28 +00:00
tvlc chore(gerrit): migrate OWNERS files to code-owners style 2022-09-19 11:13:28 +00:00
crfo-approve.nix feat(tools/crfo-approve): Add tool for CRFO depot-interventions 2022-02-07 19:12:31 +00:00
depot-deps.nix feat(ops/buildkite): Bootstrap Buildkite Terraform configuration 2022-06-06 11:05:12 +00:00
depotfmt.nix feat(tvix/tests): check in Nix' language test suite 2022-08-24 21:25:41 +00:00
eprintf.nix style: format entire depot with nixpkgs-fmt 2022-01-31 16:11:53 +00:00
gerrit-cli.nix fix(gerrit-cli): don't output the path to SSH if it's on the path 2020-06-21 23:49:30 +00:00
gerrit-update.nix feat(gerrit-update): Add helper script for updating Gerrit schema 2020-11-29 11:50:58 +00:00
hash-password.nix test(tools/hash-password): ensure that script can execute correctly 2022-05-27 23:48:37 +00:00
perf-flamegraph.nix fix(tools/perf-flamegraph): Get rid of most 'unknown's 2020-07-16 00:37:29 +00:00