actions / cache

Cache dependencies and build outputs in GitHub Actions
MIT License
4.39k stars 1.17k forks source link

use 'cache' in composite action: Failed to save: Unable to reserve cache with key #1181

Closed colemickens closed 7 months ago

colemickens commented 1 year ago

I'm not really sure what's going.

Ever since I moved my cache restore+save into a composite action, the save fails every single time:

Run actions/cache/save@v3
  with:
    path: /tmp/cache
    key: nixcfg-hm-1
    enableCrossOsArchive: false
  env:
    NIXCFG_CI_BRANCH: nixcfg--
/usr/bin/tar --posix -cf cache.tzst --exclude cache.tzst -P -C /home/runner/work/nixcfg/nixcfg --files-from manifest.txt --use-compress-program zstdmt
Failed to save: Unable to reserve cache with key nixcfg-hm-1, another job may be creating this cache. More details: Cache already exists. Scope: refs/heads/main, Key: nixcfg-hm-1, Version: 2e3304f2b0fc224b01601463e4efe06a95c58b14257353eeb31e37898c172bea
Warning: Cache save failed.
colemickens commented 1 year ago

Well, I reved the cache key and ran it again and it saved the cache... and then failed to restore it on subsequent run, despite the fact you can see the cache key is the same...

+ date
Thu Jun  8 03:32:28 UTC 2023
Run actions/cache/save@v3
/usr/bin/tar --posix -cf cache.tzst --exclude cache.tzst -P -C /home/runner/work/nixcfg/nixcfg --files-from manifest.txt --use-compress-program zstdmt
Cache Size: ~273 MB (286535608 B)
Cache saved successfully
Cache saved with key: nixcfg-hm-2

subsequent run:

Run actions/cache/restore@v3

Cache not found for input keys: nixcfg-hm-2

Unless canceling a run invalidates a previous cache upload, which would be unfortunate... I already have the ability to save based on step conditions, so I'd really rather it didn't. Or maybe caching is optimistic at best? Not sure.

colemickens commented 1 year ago

And now back to complaints about not being able to reserve the cache.

So:

Failed to save: Unable to reserve cache with key nixcfg-hm-2, another job may be creating this cache. More details: Cache already exists. Scope: refs/heads/main, Key: nixcfg-hm-2, Version: 9e02f6448824ce56c58e934cb740949d94970ffb76a9156cebc26bf241acf5dc
colemickens commented 1 year ago

And now another run again says the cache key isn't there.

Is there some reason that it would tell me it saved the cache, but then be in this stuck state?

colemickens commented 1 year ago

It feels like what's happening is:

  1. Workflow gets to "cache save" step, it is successful.
  2. The workflow continues running, and I stop it because I'm debugging/working on it.
  3. The saved cache is invalidated, but the reservation for it isn't invalidated.

Is this possible? It seems to match my symptoms anyway.

colemickens commented 1 year ago

This just flat out seems broken. I can very clearly see a cache with that key in the Actions Cache Management UI and yet it keeps:

  1. Telling me there's no cache with that key.
  2. Telling me it can't save the cache because another job is (it isn't).
github-actions[bot] commented 7 months ago

This issue is stale because it has been open for 200 days with no activity. Leave a comment to avoid closing this issue in 5 days.

github-actions[bot] commented 7 months ago

This issue was closed because it has been inactive for 5 days since being marked as stale.

colemickens commented 7 months ago

lol.