cache icon indicating copy to clipboard operation
cache copied to clipboard

Cache not found between jobs while being in the same run

Open mwestphal opened this issue 2 years ago • 8 comments

I've found a strange bug with cache action. I know about cache being only available to the PR with the branch you are working on, and only when run is finished. this is not an usage issue on my side.

In short, here is what I do with cache.

My CI:

job 1 is recovering a cache using a key, if not available, download the data from somewhere else and upload an artifact, on sucess, cache is updated with the new data if any as cache action do automatically.

job 2 is recovering a cache using the same key, if not available download the artifact and keep going from there. On sucess cache is updated but technically it is not even needed as job1 has already done it.

The problematic workflow: There is a specific situation where this breaks and it should not, when new data is available and job 2 fails.

RUN 1 (new data, broken build)

job 1 is trying to recover cache using a key, there is new data so cache is not available, so data is being downloaded from alternate source and uploaded as artifacts. cache is created from the new data as job1 is successful.

job 2 is trying to recover cache using a key, there is new data so cache is not available, so data artifact is donwloaded instead. job 2 fails to build for an unrelated reason. no cache is created from the new data as the job failed.

All behavior is expected from now

RUN 2 (no new data, build fixed)

job 1 is trying to recover cache using a key it is found, job1 succeed

job 2 is trying to recover cache using a key BUT FAILS FOR AN UNKNOWN REASON, job 2 tries to fallback on artifact, which is not available, job 2 fails.

I can see the cache listed in the cache, but job2 is not able and will never be able to access it, while job 1 can access it super fine.

Let me know If I missed anything here. I could try to create a minimal repo to reproduce this but that would be a fair amount of work so I will wait for some feedback first.

mwestphal avatar Jun 18 '23 20:06 mwestphal

Link to an actual CI failing like this: https://github.com/f3d-app/f3d/actions/runs/5305416707

(Ignore MacOS jobs, something else seems to be going on with these)

mwestphal avatar Jun 18 '23 20:06 mwestphal

I also am experiencing this, we have a workflow that basically does this:

jobs:
  cache_check:
    secrets: inherit
    uses: ./.github/workflows/module-cache-check.yml

  lint:
    secrets: inherit
    uses: ./.github/workflows/module-lint.yml
    needs: [cache_check]

A first job to cache the code, then a second (actually many more) which pull that cache and read from it. Despite being in literally the same run, cache_check consistently finds the key while all other jobs do not. Is this because we're using workflow_call? Bad github behavior?

comp615 avatar Jun 23 '23 20:06 comp615

I'm having an issue where the cache is just not found at all, even between separate runs. #1198

infogulch avatar Jun 24 '23 02:06 infogulch

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] avatar Jan 10 '24 08:01 github-actions[bot]

comment

mwestphal avatar Jan 10 '24 10:01 mwestphal

Facing the same issue. Chained jobs can't restore the cache created on the very first job in the chain on the same run

constgen avatar Feb 14 '24 17:02 constgen