Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to reserve cache with key X another job may be creating this cache #22

Closed
ruudk opened this issue Dec 14, 2021 · 9 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@ruudk
Copy link

ruudk commented Dec 14, 2021

Describe the bug
Since today our workflows started failing 80% of the time.

Version

  • Latest version

Runners

  • GitHub Hosted

Operating systems

  • Ubuntu 20.04

PHP versions

  • 8.0

To Reproduce

env:
    REQUIRED_PHP_TOOLS: cs2pr
    REQUIRED_PHP_EXTENSIONS: mbstring,bcmath,intl,gd,zip,memcached,redis,rdkafka
    PHP_VERSION: '8.0'
jobs:
    checks-and-guards:
        strategy:
            fail-fast: false
        runs-on: ubuntu-20.04
        steps:
            -   name: Checkout
                uses: actions/checkout@v2.4.0
                with:
                    ref: ${{ github.event.pull_request.head.sha }}
                    fetch-depth: 0
            -   name: Setup cache environment
                id: extcache
                uses: shivammathur/cache-extensions@1.6.2
                with:
                    php-version: ${{ env.PHP_VERSION }}
                    extensions: ${{ env.REQUIRED_PHP_EXTENSIONS }}
                    key: php-build-v1

Expected behavior
No error

Additional context
Feels like a race condition similar to ramsey/composer-install#195

@ruudk ruudk added the bug Something isn't working label Dec 14, 2021
@shivammathur
Copy link
Owner

@ruudk try bumping the key input in cache-extensions

@ruudk
Copy link
Author

ruudk commented Dec 14, 2021

Does not make a difference :(

@shivammathur
Copy link
Owner

shivammathur commented Dec 14, 2021

Can you provide links to the workflow runs

@ruudk
Copy link
Author

ruudk commented Dec 16, 2021

They are in private repos so I cannot share them. For now, I removed the caching of extensions and it works fine.

if more people report this, it might be related to cache race conditions mentioned above.

@ruudk ruudk closed this as completed Dec 16, 2021
@shivammathur
Copy link
Owner

The "Unable to reserve cache ..." error is not because of a race condition, but a known issue when something breaks between reserving the cache and the final upload in the post cache step. Because of this failure, the cache gets stuck in a reserved state and new runs are not able to use that cache key again. So resetting the key should have fixed it.
This comment on actions/cache explains it.

I released 1.7.0 of this action today and that should reset every cache. Whenever you have time please try running it again in a public test repo and let me know if you still get that error.

@ruudk
Copy link
Author

ruudk commented Dec 17, 2021

Thank you for the followup. I just enabled the actions on my private repo again. Let's see how it goes. If you don't hear from me after a week, all should be fixed 😊

@angrybrad
Copy link

Running into this myself.

Have tried various things like changing the extension list, updating cache keys, creating dynamic cache keys from the build matrix, etc. with no luck.

Can't help but think I'm doing something wrong, but not sure what.

https://github.com/craftcms/cms/runs/5635773446

@shivammathur
Copy link
Owner

@angrybrad

This can happen when a cache is reserved but not saved for some reason. Now that key cannot be used again till 24hrs till that reserved lock is released.

I improved how we handle cache errors in 257e3c9. So try again and let me know. Also, you don't need to set dynamic keys, a simple string would work, the action will parameterize it as needed.

@angrybrad
Copy link

@shivammathur So far that appears to have resolved the issue. I will report back if it comes up again. Thank you!

ManasJayanth added a commit to ManasJayanth/fullstack-reason-react-demo2 that referenced this issue May 11, 2024
We kept getting,

```
Error: Unable to reserve cache with key
build-darwin-arm64-ed94a82639847ed06afe84af9fb368d5dae34dfd4556ef0c864fc11b0b9f3b58,
another job may be creating this cache.
```

As suggested here: oven-sh/setup-bun#45 (comment)

```
@xHyroM Does this comment help you with further investigation →
shivammathur/cache-extensions#22 (comment) ? That one also mentions
this one from actions/cache: actions/cache#485 (comment)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants