Skip to content

"Cache not found" but "Cache already exists" #144

Closed

Description

@3flex

https://github.com/3flex/detekt/commit/5cf02d5164a6cff162ea494f6e3734759863fbd6/checks?check_suite_id=391438197

See the "Cache Gradle dependency cache" step for each job, where it says:

Cache not found for input keys: Windows-gradle-...

But then in each "Post Cache Gradle dependency cache" step, it says:

[warning]Cache already exists. Scope: refs/heads/gh_actions, Key: Windows-gradle-...

So, cache wasn't found (which was expected for this build) but none of the jobs were able to save the cache either? I saw in a comment on another issue that multiple jobs in a matrix with the same cache key will cause a race and the first to finish will save results to the cache which is OK for what I'm doing, but that hasn't happened - none of the jobs saved the result as expected.

Activity

  1. dhadka commented on Jan 9, 2020

    @dhadka
    Contributor

    It looks like some of the runners failed with a tar error:

    C:\windows\System32\tar.exe -cz -f d:\a\_temp\2872e9c9-c5e0-4d11-b84e-7581c522ad03\cache.tgz -C d:\a\detekt\detekt\$HOME\.gradle\caches\modules-2 .
    tar.exe: could not chdir to 'd:\a\detekt\detekt\$HOME\.gradle\caches\modules-2'
    
    [warning]Tar failed with error: The process 'C:\windows\System32\tar.exe' failed with exit code 1. Ensure BSD tar is installed and on the PATH.
    

    This failure occurred after that runner "reserved" the cache. The issue now is that that cache is in the "reserved" state, which is preventing other runners from uploading to the cache. The "reserved" state is automatically cleared once a day, however, we'll need to fix the tar issue or you'll continue to see this warning.

    @joshmgross Was there any fix for having multiple tar commands on the path?

  2. zhangyoufu commented on Jan 14, 2020

    @zhangyoufu

    I'm running into same issue using actions/cache@v1.

    Run actions/cache@v1
      with:
        path: toolchain
        key: toolchain-b5bb1ca45a199ba1026d31f7995b3f04bbae726b0390b2f6b2c67bdf7d98183e
    Cache not found for input keys: toolchain-b5bb1ca45a199ba1026d31f7995b3f04bbae726b0390b2f6b2c67bdf7d98183e.
    
    Post job cleanup.
    [warning]Cache already exists. Scope: refs/heads/master, Key: toolchain-b5bb1ca45a199ba1026d31f7995b3f04bbae726b0390b2f6b2c67bdf7d98183e, Version: (null)
    

    I think I triggered this bug by setting the path to a single file instead of a folder.

  3. hiranya911 commented on Jan 15, 2020

    @hiranya911

    I'm getting this error too. Was experimenting with this feature and a mistake caused an action fail with a tar error. Now it seems there's no way to fix it. Is there at least a workaround?

  4. zhangyoufu commented on Jan 15, 2020

    @zhangyoufu

    @hiranya911 Use a different key.

    Per https://help.github.com/en/actions/automating-your-workflow-with-github-actions/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy, you have other choices:

    1. Wait 7 days, and don't use that cache entry.
    2. Put some garbage (2GiB) into another cache entry, so that GitHub should evict old cache entries.
  5. hiranya911 commented on Jan 15, 2020

    @hiranya911

    @zhangyoufu I've already tried several different keys. For each key I get a not found at the initialization and an already exists at the post cleanup.

  6. dhadka commented on Jan 15, 2020

    @dhadka
    Contributor

    Hi @hiranya911, could you please link me to the repo if it is public. If you're getting a tar error each time, it'll continue to get stuck in the bad state.

  7. hiranya911 commented on Jan 15, 2020

    @hiranya911
  8. dhadka commented on Jan 15, 2020

    @dhadka
    Contributor

    Thanks, I'm taking a look. Can you also please enable debugging and trigger another run?

  9. dhadka commented on Jan 15, 2020

    @dhadka
    Contributor

    @hiranya911 Thanks for providing the requested info. I took a look and both issues are related to how runners "reserve" the cache.

    1. The run using firebase-cli as the key worked successfully. Essentially, one of the runners of your matrix strategy reserves the right to upload the cache. If you look at the post cache step in build (3.6), you'll see that step succeeded in creating the cache. The others fail with the message that the cache already exists because build (3.6) created the cache.

    2. In the run with the tar error, the cache gets into a bad state because it already reserved the cache but failed to create the tar. The workaround is to either use a different key or wait the approximately 24 hours for the reservation to expire. We reserve the cache this way to prevent having many runners (when a matrix strategy is used) all tarring and uploading the identical cache. We are working on a fix to reduce the time a cache stays reserved, which should help alleviate this issue.

    Unfortunately, there's not a good way right now to distinguish these cases, except to look at the post cache step in each runner to see if one succeeded. Hope this helps :)

  10. hiranya911 commented on Jan 15, 2020

    @hiranya911

    Thanks @dhadka for looking into it. You're indeed right. I finally managed to get a cache hit with the firebase-cli key: https://github.com/firebase/firebase-admin-python/runs/390362670

    It looks like Linux-Firebase-CLI key is currently in the broken reserved state, so it won't work until 24 hours has passed.

    It also looks like, content under $HOME are indeed cacheable:

    Post job cleanup.
    /bin/tar -cz -f /home/runner/work/_temp/0b50a961-b830-4502-b18b-7ef90a419b14/cache.tgz -C /home/runner/.cache .
    Cache saved successfully
    
  11. added a commit that references this issue on Jan 21, 2020
  12. added
    enhancement
    question
    on Jan 27, 2020
  13. thisismydesign commented on Jan 28, 2020

    @thisismydesign

    I think I triggered this bug by setting the path to a single file instead of a folder.

    Same.

    @joshmgross Why is this an enhancement instead of a bug?

  14. 49 remaining items

  15. github-actions commented on Nov 28, 2022

    @github-actions

    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.

  16. Phantsure commented on Nov 28, 2022

    @Phantsure
    Contributor
  17. Phantsure commented on Dec 13, 2022

    @Phantsure
    Contributor

    Anyone who has recently faced this can they share the workflow? Need to reproduce this to investigate. Logs of workflow run should also work

  18. Phantsure commented on Dec 13, 2022

    @Phantsure
    Contributor

    I have a similar issue. On my system it seems, that caches are bound to an OS. We have implemented the following pipeline using matrix build parallelization :

    linux+java11   -\                        /->  linux+java11
    linux+java8      ->  linux+java8  ->    linux+java8
    win+java8      -/                        \->   win+java8
    win+java11   -/                          \->  win+java11
    

    the jobs on the right should all restore a cache created by the middle job. Anyhow, what's interesting is, that the linux jobs on the right get a cache hit while the windows builds on the right cannot find the cache of the middle job. Is this by intention, even considered to be a different bug, or simply related to this issue?

    @maybeec This feels different. You are pointing out that linux and macos caches are compatible and windows are not. Work is going in that area if you like to track: #984

  19. wpbonelli commented on Dec 14, 2022

    @wpbonelli

    Anyone who has recently faced this can they share the workflow? Need to reproduce this to investigate. Logs of workflow run should also work

    https://github.com/MODFLOW-USGS/modflow6/actions/runs/3624583228/jobs/6111766806#step:6:152

    That run uses a fork of actions/cache offering finer-grained control but presumably encounters the same issue

  20. Phantsure commented on Dec 15, 2022

    @Phantsure
    Contributor

    @w-bonelli Was the cache already present as I don't see a Cache not found warning? If it was already present then this message is correct.

    Update: I also see that the workflow is using save only action. And this message is possible with save only action when cache exists with same key

  21. Phantsure commented on Dec 16, 2022

    @Phantsure
    Contributor

    Closing this as this issue seems resolved with newer versions. I am not able to reproduce this.

  22. wpbonelli commented on Dec 16, 2022

    @wpbonelli

    Is it no longer possible for the cache to get stuck in a reserved state after a failed upload?

    Would you mind helping me better understand what's going on when there is a Cache not found but then the cache can't save?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions