Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make deleting a project purge the cache #2849

Merged
merged 1 commit into from
Jan 29, 2018
Merged

Make deleting a project purge the cache #2849

merged 1 commit into from
Jan 29, 2018

Conversation

di
Copy link
Member

@di di commented Jan 26, 2018

Fixes #2418. This is a prerequisite for #2821.

The reason that the project wasn't being purged is because using the bulk deletion API via request.db.query(...).delete() never loads the deleted objects into the session, so when our after_flush db hook fires, session.deleted is empty.

I thought an alternative might be hooking into the after_bulk_delete event, which receives a delete_context.matched_objects, but this also only contains objects already in the session that have been deleted.

The simplest thing we could do here is load everything that needs to be purged into the session (via request.db.query(...).all() and then delete them. Presumably doing so would make this a) a bit slower and b) require a bit more memory, but since deletion happens infrequently enough (and since the next thing we're doing is removing all these objects from the session) I figured this was OK, so that's what this PR does.

I don't totally love this, because it requires us to remember to delete things differently if we want them to be purged from the cache, but I don't see any alternatives that don't involve making purging more manual than it already is.

@di di requested a review from dstufft January 26, 2018 19:23
@di di merged commit 14a8c15 into master Jan 29, 2018
@di di deleted the fix-delete-cache-purge branch January 29, 2018 16:49
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.

2 participants