Skip to content

Upload cluster staging - #245

Open
fcollman wants to merge 2 commits into
masterfrom
upload-cluster-staging
Open

fcollman wants to merge 2 commits into
masterfrom
upload-cluster-staging

Conversation

@fcollman

@fcollman fcollman commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

this will make the large table uploads clustered on primary ID on the annotation and segmentation table to speed up joins

fcollman and others added 2 commits October 2, 2026 08:53
/api/process/start now writes a "pending" job record before enqueueing
process_and_upload and passes the job id to the task. Previously the record
was only created once an orchestration worker picked the task up, which can
take minutes while KEDA schedules the job and pulls the image, so the
running uploads page showed no jobs in the meantime.

update_job_status now carries "status" forward when an update omits it,
like user_id and datastack_name, so the task's "Workflow Chain Initialized"
update does not drop the pending status.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Add a process:cluster_staging_tables step between
monitor_spatial_workflow_completion and transfer_to_production that runs
CLUSTER ... USING <pkey> and ANALYZE on the staging annotation and
segmentation tables. transfer_table_using_pg_dump copies rows with pg_dump,
which reads them in physical order, into an emptied production table, so
production tables come out in id order without clustering the production
database. The spatial lookup writes segmentation rows in spatial chunk
order, so that table in particular was not in id order before.

Clustering only changes row order, so a failure is logged and the upload
continues to the transfer unclustered.

pg_dump now runs with synchronize_seqscans=off so a concurrent scan cannot
start the copy partway through a large table, and each production table is
marked CLUSTER ON its primary key after its indices are rebuilt, so a later
plain CLUSTER keeps the id order.

Table and index names in the new SQL are quoted, so mixed-case names work
there, unlike the existing unquoted transfer SQL.

Move the upload job status tests into a class: the conftest ordering hook
requires class-based tests.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
pg_env = os.environ.copy()
if db_info["password"]:
pg_env["PGPASSWORD"] = db_info["password"]
# pg_dump copies rows in the source table's physical order, which preserves the id

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this modifying something global to postgres? just wary of that after the recent bug i caused with something similar

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