Avoid pruning parent cache objects #176
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When looking for cache results to be pruned, we execute this SQL query:
Here
rc
is the number of children a particular cache object has, andused
is the timestamp of when that object was used. As soon as the next cache object starts building, it becomes dependent on the parent, but we only updaterc
when the build has finished and the object is saved to the database.There is a map
in_progress
which holds the current builds. This PR adds a check to the prune function to query thein_progress
operations to prevent the removal of these parents.Depending upon the backend store, the delete operation may take a fraction of a second or many minutes; therefore, the query results are refreshed between each deletion. The query must return many results (not just one) as the
in_progress
check may filter some results. This prevents the prune from being blocked by a single active build with the oldest parent.~before
could be removed from the code in the future.Addresses ocurrent/ocaml-ci#873