Skip to content

Delete github cache entry blob storage outside transaction - #6597

Open
jeremyevans wants to merge 2 commits into
mainfrom
jeremy-delete-cache-blob-storage
Open

jeremyevans wants to merge 2 commits into
mainfrom
jeremy-delete-cache-blob-storage

Conversation

@jeremyevans

Copy link
Copy Markdown
Contributor

Deleting the blob storage takes 1-2 HTTP calls. It was previously done
after the cache entry was deleted from the database inside the, holding
a lock on the deleted row, which could block loads of the cache entries
for a repository.

Move the blob storage deletion code into a delete_blob_storage method,
and call that in .destroy_where and in the route to delete specific
cache entries.

After blob storage is deleted, this changes upload_id to an sentinel
string. I'm not sure whether there is a better way to do this that
doesn't require adding a column. I don't think the upload_id is needed
after the blob storage is deleted, and the value of saving it in the
deleted record seems low.

There are still a couple of progs that delete cache entries, and as
prog labels are run inside transactions by default, are still subject
to this problem. PR #6559 attempts to address this for
GithubRepositoryNexus, and with these changes, should result in blob
storage being deleted outside a transaction for most of the deletions.
A similar approach can be used for DeleteCacheEntries, and the remaing
GithubCacheEntry#destroy call in GithubRepositoryNexus can be changed
to call delete_blob_storage first.

@jeremyevans
jeremyevans requested a review from enescakir October 5, 2026 22:36
@jeremyevans
jeremyevans force-pushed the jeremy-http-inside-transaction branch from 8f48539 to ec1618b Compare October 6, 2026 15:06
Base automatically changed from jeremy-http-inside-transaction to main October 6, 2026 21:40
Avoids the need repeat the conditional in a where call.
Deleting the blob storage takes 1-2 HTTP calls. It was previously done
after the cache entry was deleted from the database inside the, holding
a lock on the deleted row, which could block loads of the cache entries
for a repository.

Move the blob storage deletion code into a delete_blob_storage method,
and call that in .destroy_where and in the route to delete specific
cache entries.

After blob storage is deleted, this changes upload_id to an sentinel
string.  I'm not sure whether there is a better way to do this that
doesn't require adding a column. I don't think the upload_id is needed
after the blob storage is deleted, and the value of saving it in the
deleted record seems low.

There are still a couple of progs that delete cache entries, and as
prog labels are run inside transactions by default, are still subject
to this problem. These will be addressed in the future.
@jeremyevans
jeremyevans force-pushed the jeremy-delete-cache-blob-storage branch from 751029e to ec1617f Compare October 6, 2026 21:58

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant