Repository navigation
feat(orchestrator): Prefetch finished containers' logs and outputs off the loop thread #427
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
Open
morgan-wowk
wants to merge
1
commit into
master
Choose a base branch
from
orchestrator-completion-prefetch
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(AI Assisted)
m1 · 🔹 minor — a prefetch for an execution that is never revisited is never forgotten
🔹 Severity: minor
Issue.
self._completion_prefetches[container_execution.id] = future(
orchestrator_sql.py:1330) is cleared in exactly two places: the next visit that takes thefinished prefetch (
:1333), and the cancellation path (:987). Any execution that reaches aterminal state by another route keeps its entry — and its
_CompletionPrefetch, with up to 255bytes per preloaded output — for the life of the process.
The route that matters is the refresh-error path: after
_max_container_execution_refresh_error_retriesconsecutive retriable failures the sweep setsSYSTEM_ERRORand commits (:321), and the execution is never selected again. The entry stays.Losing the orchestrator lock has the same effect for everything in flight at that moment.
Fix. Forget the prefetch wherever the execution leaves
PENDING|RUNNING— theSYSTEM_ERRORpath is the one that matters today — or bound the dict, since an entry is only ever useful on the
very next visit.
Counter-argument, stated honestly. On the happy path an entry lives for one sweep, the leak
rate is one dict entry per stuck execution, and the orchestrator restarts on every deploy. This
will never be the reason the process runs out of memory. It is raised because an unbounded dict
keyed by execution id is the kind of thing that is cheap to bound now and awkward to diagnose
later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤖 AI-assisted: Fixed in ed84d1a.
_forget_completion_prefetchnow runs on the SYSTEM_ERROR path as well as on cancel. It pops the future and the stored ended container, and cancels the future. Lost-lock exits the process, so nothing outlives it there. New test covers SYSTEM_ERROR.