Repository navigation
Avoid running out of memory on large result deletes and dropping continuations of chunked jobs - #1452
Merged
Merged
Conversation
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Two problems that show up when a large backlog of old results is pruned.
Deleting a poll's results loaded every result id into memory
Poll.delete_poll_resultsevaluated the whole id queryset, only to count it, before deleting anything. On a flow with tens of millions of results that can exhaust the worker's memory, and the worker is killed before a single row goes. The ids are now streamed, and counted as they're deleted.A continuation could be dropped, leaving its job stalled
A chunk enqueues its continuation before it releases the lease. If a worker picks the continuation up in between, its claim fails, and if the release lands before it checks why, it finds no lease and gives up, as if there was nothing to do. That message was the only thing driving the run, so the job stays running with nothing moving it until the next dispatch nudges it.
A failed claim on a running job that no longer has a lease now retries a few seconds later. Jobs that have ended or are paused are still skipped, as nothing is waiting on those messages and retrying one could start another run.
This doesn't change the wait when the lease is still live at that check, which is still until it expires.