CI jobs with multiple cache and cache:key:files experiencing cache miss due to new cache key prefix
Summary
CI jobs using multiple cache and cache:key:files starting to experience cache miss due to a prefix appearing in the cache key (before the hash).
This prefix corresponds to the index of the specific cache in the list of caches when multiple caches are used
Steps to reproduce
Create two CI jobs using multiple caches, at least one using files as key. Ensure the caches are in different orders. Cache keys will be different!
Example Project
https://gitlab.com/gfaugere-safti/reproduce-cache-key-file
Look at the latest pipeline: CI is green, but there is a cache miss and you can observe different cache keys
What is the current bug behavior?
The same file used has key will have different keys depending on order
What is the expected correct behavior?
Files which are the same should have the same cache key, regardless of the order of the cache declaration on the jobs
Relevant logs and/or screenshots
Checking cache for 0-a283b02686edf0a3d17ea06d6e761b72d8210907-protected...
...
Creating cache 0-a283b02686edf0a3d17ea06d6e761b72d8210907-protected...
Checking cache for 1-a283b02686edf0a3d17ea06d6e761b72d8210907-protected...
WARNING: file does not exist
Failed to extract cache
...
Creating cache 1-a283b02686edf0a3d17ea06d6e761b72d8210907-protected...
This bug happens on GitLab.com
Possible fixes
Caused by this fix: !104885 (merged) (thanks @kir.gilroy for the find!)
Maybe the original hash collision bug needs a different fix? And this behaviour should probably be documented (here ?) if it stays
Workarounds
Your can use the cache:key:prefix property to avoid having an auto-generated index-based prefix:
cache:
- key:
prefix: ""
files:
- ...
Or you can make sure your cache are in the same order in all jobs which uses the same keys (seems more fragile to me)