Prune one at a time up to the limit #157
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 a new obuilder job is accepted by ocurrent/ocluster the
build
function in obuilder_build.ml is called. This checks that there is enough free disk space possibly spawning an asynchronous threaddo_prune
to prune builds before runningBuilder.build
.do_prune
invokesBuilder.prune
which callsStore.prune
fromdb_store.ml
. The prune function queries the database to build a list of items ordered by the least recently used and begins deleting them. The delete operation takes several minutes or longer, however the list of items was evaluated at the start. It is possible that the build job which was started in parallel withdo_prune
or a subsequent job will use one of the cache steps which is in the list to be pruned.The workaround proposed here is not perfect. It minimises the chance that this will happen by checking the last used time for each item as it is deleted. We will now have one SQL query per item deleted which is less efficient.
The logging has also been updated to show the start and end of the prune operation: