Repository navigation
Upload: run the long steps in orchestration job pods, acked late and resumable - #260
Merged
Merged
Conversation
…umable On minnie (2026-10-25) a 337M-row upload's upload_to_db ran on the KEDA-scaled workflow queue: KEDA scaled the producer down 8 min into the import (the queue was empty), the preStop hook failed, and the 6000 s grace period ended mid index build. The task had been acked on receipt, so it was gone, and the spatial lookup and transfer never ran. upload_to_db, cluster_staging_tables and transfer_to_production now run on the orchestration queue: a job pod of their own on a non-preemptible node, which runs the one task and exits, with nothing to scale it down. They are acked late, so a pod lost anyway (node failure, the job deadline) means a redelivery: - upload_to_db records its Cloud SQL import (operation name, running/done) per job in redis. A redelivery skips table creation, truncation and the index drop, waits on the recorded import (it carries on without its client) or skips it if done, then waits for any CREATE INDEX the dead attempt left running before building the indexes (IF NOT EXISTS). - cluster and transfer were already safe to rerun. The broker visibility timeout must be longer than the job deadline (chart visibilityTimeout, now 90000 s by default): a dead pod's message is restored by the exporter on the default unacked key, and a shorter timeout would hand a task over 6 h to a second pod while it still runs. A job pod now stops consuming when its last allowed task starts, so it never claims a further message it would hold unacked until the visibility timeout. The old workflow:* names stay registered for one release, for messages queued under them during a deploy. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
fcollman
force-pushed
the
long-upload-steps-on-orchestration
branch
from
October 25, 2026 15:59
1550e46 to
a7b18f2
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.
On minnie on 2026-10-25, a 337M-row upload was lost partway through
upload_to_db, which then ran on the KEDA-scaled workflow queue:preStophook failed, and the 6000 s grace period expired in the middle of the second of six index builds.Neither keeping a minimum replica count nor a
preStophook can protect a task that runs for hours.Changes
upload_to_db,cluster_staging_tablesandtransfer_to_productionmove to the orchestration queue. Each runs in a KEDA job pod of its own, on a non-preemptible node, that runs the one task and exits. Nothing scales it down mid-task.upload_to_dbrecords its Cloud SQL import (operation name, running or done) per job in Redis.CREATE INDEXthe dead attempt left running before building the indexes, which useIF NOT EXISTS.process_csvruns.workflow:*names stay registered for one release, for messages queued under them during a deploy.Depends on the chart
cave-helm-charts #12 raises the broker visibility timeout (
materialize.celery.visibilityTimeout) to 90000 s by default, longer than the 86400 s job deadline. Without it, a late-acked task running longer than 6 h would be handed to a second pod while it still runs. The orchestration pods keep the default unacked key on purpose: the metrics exporter consumes on that key and restores a dead pod's message, and KEDA then starts a job pod for it. Deploy both together.Tradeoff
If a job pod's container crashes mid-task (OOM), its message is restored only after the visibility timeout (~25 h), and then it resumes. Today such a task is simply lost.
Tests
test_upload_long_tasks.py:🤖 Generated with Claude Code