actions / cache

Cache dependencies and build outputs in GitHub Actions
MIT License
4.58k stars 1.22k forks source link

Duplicated cache due to concurrency #1392

Open pespinel opened 6 months ago

pespinel commented 6 months ago

Misc

When running multiple runs at the same time, the cache is duplicated due to concurrency, even with the same key and for the same branch:

Captura de pantalla 2024-05-02 a las 8 47 11

Version: cache@v4 Step:

    - name: Cache
      uses: actions/cache@v4
      id: cache
      with:
        key: venv-${{ runner.os }}-${{ runner.arch }}-pip-${{ hashFiles(format('acceptance/{0}', inputs.file)) }}
        path: ${{ steps.cache-dir.outputs.dir }}
        restore-keys: ${{ runner.os }}-${{ runner.arch }}-pip-
moetezch commented 6 months ago

I am facing same issue with the following configuration

  uses: actions/cache@v4
        id: node_modules
        with:
          path: |
            **/node_modules
          key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}-${{ steps.node.outputs.version }}
Screenshot 2024-05-08 at 10 19 04
pespinel commented 6 months ago

I am facing same issue with the following configuration

  uses: actions/cache@v4
        id: node_modules
        with:
          path: |
            **/node_modules
          key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}-${{ steps.node.outputs.version }}
Screenshot 2024-05-08 at 10 19 04

You have one for each ref. I think that this is the expected result. The problem is when a cache is duplicated for the same hash and the same ref.

moetezch commented 6 months ago

I am facing same issue with the following configuration

  uses: actions/cache@v4
        id: node_modules
        with:
          path: |
            **/node_modules
          key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}-${{ steps.node.outputs.version }}
Screenshot 2024-05-08 at 10 19 04

You have one for each ref. I think that this is the expected result. The problem is when a cache is duplicated for the same hash and the same ref.

Ah sorry you are right, I was expecting the case to be used if the key is same regardless of the ref

pespinel commented 6 months ago

More examples:

Captura de pantalla 2024-05-20 a las 11 43 50