Skip to content

Load REST-API DCCs into a staging area and swap under a short cutover lock #129

Open

Description

@conradbzura

Description

The REST-API loaders (ENCODE, and HuBMAP since #127) stream their upstream metadata into files while holding the global cutover lock, and clear their slice at the first committed batch. Two consequences follow, shared by both loaders:

  • Read outage. Every /data, /index, /tiles, /tilesets, /jobs and GraphQL request for every DCC waits in wait_for_cutover, which raises after CUTOVER_WAIT_TIMEOUT = 60 s. A HuBMAP sync streams ~52 pages at 1–2 s each plus inserts, so it holds the lock for roughly two minutes; ENCODE's experiment stream holds it far longer. Requests arriving early in the window fail.
  • Partial slices. A stream that fails after its first batch has already deleted the previous slice, so the API serves a partial one until the next successful sync.

The cutover lock also has no stale handling or startup reset: a task replaced mid-stream leaves it active, and every request then fails until it is cleared by hand.

Proposal

Load into a staging location outside the cutover lock, then swap under a short lock. Two candidate shapes:

  • Insert with a per-sync generation stamp, and on clean completion delete the previous generation under the lock (on failure, delete the new one). Readers must filter to the live generation, or the swap must be atomic from their point of view.
  • Load into a shadow collection and rename or merge it into files under the lock.

Either makes a failed load all-or-nothing and shrinks the lock window from the stream's duration to the swap's. Separately, give the cutover lock a stale threshold or a startup reset.

Motivation

Raised in the review of PR #128 (#127, findings A14 and A12). HuBMAP adopted ENCODE's in-lock streaming design, so the fix belongs to both loaders rather than to one PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions