Repository navigation
Conversation
loadez
requested review from
DamjanBecirovic,
adbatista,
dexyk and
skipi
as code owners
November 10, 2026 13:04
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
jobs.private_ssh_key and jobs.agent_auth_token were kept forever. The debug SSH key is only served while the job is running, so it is cleared on every transition to finished (finish, stop, force_finish, bulk_force_finish). force_change is used because bulk_force_finish loads the job without that column. The agent auth token is still needed by post-job processing for a while after the job finishes, so it is cleared later by a new periodic worker, FinishedJobCleaner (START_FINISHED_JOB_CLEANER, off by default). It walks finished jobs in (finished_at, id) order, which the existing jobs index serves, and clears the token and the SSH key of jobs finished more than FINISHED_JOB_CLEANER_CUTOFF_DAYS (default 3) ago. Each tick handles at most FINISHED_JOB_CLEANER_BATCH_SIZE rows (default 250) and sleeps FINISHED_JOB_CLEANER_NAPTIME_MS (default 1000) while there is work, or FINISHED_JOB_CLEANER_LONGNAPTIME_MS (default 600000) once caught up. Progress is stored in the new job_cleanup_cursors table, so a restart resumes where it stopped, and the cursor row is locked with SKIP LOCKED so only one replica works at a time. Updates are guarded by the same predicates, so a second pass changes nothing.
The cleaner used to update its batch with a plain UPDATE, which waits on rows held by another transaction (for example a retention worker that claimed the row) until the query times out, failing the tick. The batch rows are now claimed with FOR UPDATE SKIP LOCKED and the batch is cut before the first row that could not be claimed. The cursor stops there, so the row is visited again on the next tick, which comes after the short nap. New metrics: finished_job_cleaner.locked (tick skipped because another instance holds the cursor), finished_job_cleaner.lock_skipped (rows cut from a batch) and finished_job_cleaner.cursor_lag_seconds (how far the cursor is behind the cutoff, 0 once caught up). The test mirror of job_cleanup_cursors now uses timestamp(6) for updated_at, matching the github_hooks migration.
loadez
force-pushed
the
mf/zebra-finished-job-cleaner
branch
from
December 4, 2026 19:17
3888c4a to
fcfb1d1
Compare
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.
Drop job credentials once they are no longer usable.
FinishedJobCleaner, clears the token (and the SSH key, for older rows) on jobs finished more than a configurable number of days ago (default 3).(finished_at, id)on the existing index in throttled batches, keeps its position in a newjob_cleanup_cursorstable (migration in github_hooks), runs on one replica at a time (SKIP LOCKED), skips rows deleted mid-batch, and is off by default behindSTART_FINISHED_JOB_CLEANER.Settings:
FINISHED_JOB_CLEANER_CUTOFF_DAYS(3),FINISHED_JOB_CLEANER_BATCH_SIZE(250),FINISHED_JOB_CLEANER_NAPTIME_MS(1000),FINISHED_JOB_CLEANER_LONGNAPTIME_MS(600000).Deploy order: github_hooks (migration), then zebra, then enable the flag on a single deployment.