File size mismatch when restoring the cache

For about a month we’ve been frequently seeing errors similar to these:

Found a cache from build 52425 at vf77e906d-b40c-49bd-a534-bc986582e5d9-git-CAS-8069/introduce-rate-limiting-5b8e93990251a03ca393490e3dc7379a94b11f03
Size: 281 MiB
Cached paths:
  * /home/circleci/project/.git

Downloading cache archive...

file size mismatch in downloaded cache archive, downloaded: 294346529, stored size: 294347099

This corresponds to the following part of our CircleCI config:

    - restore_cache:
        keys:
          - git-{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ .Branch }}-{{ .Revision }}
          - git-{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ .Branch }}
          - git-{{ .Environment.CIRCLE_CACHE_VERSION }}
    - checkout

We haven’t changed anything regarding this configuration for more than a year. This seems to us like a potential CircleCI bug. How do we fix this?

Having the same issue on a large percentage of builds. Were you able to find a fix?

@zreisman make sure you don’t save the cache in parallel jobs in a single workflow. I refactored my workflow from:

specs1
specs2
specs3
specs4

into:

                               -- specs1
prepare_cache -- -- specs2
                               -- specs3
                               -- specs4

The prepare_cache step downloads the git repo, bundles dependencies and caches both. The downstream jobs only restore the cache