Skip to content
This repository was archived by the owner on Feb 21, 2025. It is now read-only.
This repository was archived by the owner on Feb 21, 2025. It is now read-only.

Parallel workflows containing jobs with the same name use the same cache key, resulting in "Failed to save cache entry" #699

Description

@lilgallon

Context

Here are the steps of our Github CI

            -   name: Build platform commons with Gradle
                uses: gradle/gradle-build-action@v2.4.2
                env:
                    GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
                with:
                    gradle-version: 7.6
                    build-root-directory: systems/commons
                    arguments: build --parallel --scan -Pci -PlintIgnored -x test -x loadKtlintReporters  "-Dorg.gradle.jvmargs=-Xmx2G -XX:MaxMetaspaceSize=1G"
                    cache-read-only: ${{ github.ref != 'refs/heads/develop' }}

            -   name: Build platform base with Gradle
                uses: gradle/gradle-build-action@v2.4.2
                env:
                    GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
                with:
                    gradle-version: 7.6
                    build-root-directory: systems/base
                    arguments: build --parallel --scan -Pci -PlintIgnored -x test -x loadKtlintReporters "-Dorg.gradle.jvmargs=-Xmx2G -XX:MaxMetaspaceSize=1G"
                    cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/develop' }}

            -   name: Build platform tools with Gradle
                uses: gradle/gradle-build-action@v2.4.2
                env:
                    GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
                with:
                    gradle-version: 7.6
                    build-root-directory: systems/platform
                    arguments: build --parallel --scan -Pci -PlintIgnored -x test -x distTar -x distZip -x loadKtlintReporters "-Dorg.gradle.jvmargs=-Xmx2G -XX:MaxMetaspaceSize=1G"
                    cache-read-only: ${{ github.ref != 'refs/heads/develop' }}

            -   name: Build platform with Gradle
                uses: gradle/gradle-build-action@v2.4.2
                env:
                    GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
                with:
                    gradle-version: 7.6
                    arguments: build --parallel --scan -Pci -PlintIgnored -x test -x distTar -x distZip -x loadKtlintReporters "-Dorg.gradle.jvmargs=-Xmx2G -XX:MaxMetaspaceSize=1G"
                    cache-read-only: ${{ github.ref != 'refs/heads/develop' }}

            -   name: Run platform fastest tests with gradle
                uses: gradle/gradle-build-action@v2.4.2
                env:
                    GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
                with:
                    gradle-version: 7.6
                    arguments: test --no-parallel --scan -Pfast -Pci -PlintIgnored "-Dorg.gradle.jvmargs=-Xmx2G -XX:MaxMetaspaceSize=1G"
                    cache-read-only: ${{ github.ref != 'refs/heads/develop' }}

            -   name: Run platform infrastructure tests with Gradle
                uses: gradle/gradle-build-action@v2.4.2
                env:
                    GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true
                with:
                    gradle-version: 7.6
                    arguments: test --no-parallel --scan -Plong -Pci -PlintIgnored "-Dorg.gradle.jvmargs=-Xmx2G -XX:MaxMetaspaceSize=1G"
                    cache-read-only: ${{ github.ref != 'refs/heads/develop' }}

From the logs of "Post build platform commons with Gradle":

  Caching Gradle User Home with cache key: v7-gradle|Linux|build[37a6259cc0c1dae299a7866489dff0bd]-0b6a99e5b69f94372a2cba9093df7c6801d274f2
  Using cache paths: /home/runner/.gradle/caches,/home/runner/.gradle/notifications,/home/runner/.gradle/.gradle-build-action
  /usr/bin/tar --posix -cf cache.tzst --exclude cache.tzst -P -C /home/runner/work/anoymous/anoymous --files-from manifest.txt --use-compress-program zstdmt
  Failed to save cache entry with path '/home/runner/.gradle/caches,/home/runner/.gradle/notifications,/home/runner/.gradle/.gradle-build-action,zstd-without-long,1.0' and key: v7-gradle|Linux|build[37a6259cc0c1dae299a7866489dff0bd]-0b6a99e5b69f94372a2cba9093df7c6801d274f2: ReserveCacheError: Unable to reserve cache with key v7-gradle|Linux|build[37a6259cc0c1dae299a7866489dff0bd]-0b6a99e5b69f94372a2cba9093df7c6801d274f2, another job may be creating this cache. More details: Cache already exists. Scope: refs/heads/develop, Key: v7-gradle|Linux|build[37a6259cc0c1dae299a7866489dff0bd]-0b6a99e5b69f94372a2cba9093df7c6801d274f2, Version: eb03f63337b25bd615bd5f2e3e2f06a28f197125b72943445f4e43a1c0565302

We had the problem using the version 2.2.2 of this action. Updating to 2.4.2 did not fix the issue.

Source of the problem

After investigating for a few hours, it turns out that a cache entry is systematically created between the "Build platform with Gradle" step and the "Run platform fastest tests with gradle" step. This cache entry is almost empty (usually around 8MB).

There is no log whatsoever indicating that the cache entry has been saved at this time.

Workaround:

I added a step that manually deletes the cache entry created during the build. Now there is no more problem when saving gradle home. The whole CI now takes between 5-10 minutes whereas it took more than 45 minutes before this workaround.

Notes:

This project is private, so I can not share it. I tried to reproduce it with an example project, the problem happened during the first action run (a cache entry for gradle home was saved during the build, its size was around 100kb). The next ones did not have the issue. I tried looking at the source code of this project, but I could not find the issue either.

I may try to find the issue later on and if I find it, I open a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions