Hi, my project’s integration tests met several cache-related issues, which were Ok in Circle CI 1.0 but broken recently.
-
Environment.CIRCLE_SHA1
was unchanged
Please take a look at the step "
Uploading ./target Cache (master branch only)" in this run: https://circleci.com/gh/tikv/tikv/15384
.
Circle CI reported that: Skipping cache generation, cache already exists for key: v3-target-master-aWt1SBJau3sI1Ix2iCYSsQvxk8WUCz3k1FaUSTDBdBo=-e6971e863854d5d9a91ac2ea833ddd1829388068 Found one created at 2018-11-30 11:56:12 +0000 UTC
However the cache key is created using Environment.CIRCLE_SHA1
, which should never be conflicted with a commit several days ago, right? Our configured cache key is: key: v3-target-{{ .Branch }}-{{ checksum "rust-toolchain" }}-{{ .Environment.CIRCLE_SHA1 }}
(See
https://github.com/tikv/tikv/blob/6eb153338d1effb787a040fda4ad65b40e31d5cb/.circleci/config.yml#L128 )
- Cache is not reused
This build (https://circleci.com/gh/tikv/tikv/15389
) created a cache using key v3-target-master-aWt1SBJau3sI1Ix2iCYSsQvxk8WUCz3k1FaUSTDBdBo=-49ddf36e33400b48a5199b7041636105e3cf072e
in step “Uploading ./target Cache (master branch only)”.
3 hours later, another build (https://circleci.com/gh/tikv/tikv/15398
) tried to use this cache in step “Downloading ./target Cache from master”, but failed:
No cache is found for key: v3-target-master-aWt1SBJau3sI1Ix2iCYSsQvxk8WUCz3k1FaUSTDBdBo=
. This is a perfect prefix match.
Notice that, as described above, the key format is v3-target-{{ .Branch }}-{{ checksum "rust-toolchain" }}-{{ .Environment.CIRCLE_SHA1 }}
, and we have not changed the content of “rust-toolchain” for several months. So simply speaking, on master branches builds always upload cache named v3-target-master-xxx-yyy
where yyy
should be changed each time and xxx
has not been changed for very long time. Then PR builds always load cache using prefix v3-target-master-xxx
. As you can see however, the cache loading was not succeeded. This situation has been happening for long time (several weeks), which causes our test time from 20 minutes to 1 hours each.