Repository navigation
feat(datasets): the queue, the dispatcher and provisioning go per-dataset (PR5) - #396
Merged
Merged
Conversation
…aset (PR5)
The writer lock moves to where the writing is: one active job (and one live
pod) per DATASET, each dataset being its own lake, with org-level jobs
(dataset_id IS NULL: provision) still conflicting with everything of their
org in both directions. A per-org concurrency cap rides on top —
orgs.max_concurrent_jobs, defaulting to ER_ORG_JOB_CAP (shipped as 1, the
exact pre-dataset profile) — and because a COUNT cannot be index-enforced,
pg::claim serializes claims under an advisory lock while the per-dataset
partial unique stays the database-level backstop. Fixup 0003 retires the
superseded per-org indexes and the tenant_schema_states UNIQUE(org_id)
in-table constraint (looked up in pg_constraint — Postgres named it, and
names are the fragile part); tenant_schema_states becomes one row per
dataset via two partial uniques, because a plain UNIQUE(dataset_id) would
let NULL org-level rows accumulate.
The dispatcher resolves the DATASET env for every dataset job — config,
lake, models, deliveries all come from the dataset row — falling back to the
org env only for org-level kinds. The two org-env mutation paths (resources,
the lexicon path) now fan their patch out to every dataset env, because the
convergence sweep deliberately never rewrites an existing dataset.
Dataset provisioning exists end to end: Profile::plan_dataset derives the
lake (ER_LAKE_CATALOG_SCHEMA=ds_<name> inside the org's shared metadata
database; a nested directory locally; {dataset} substitution in the data
template and env_extra), POST /datasets without a config_path becomes the
tenant-admin auto path (workspace + starter config v1 + a provisioning row +
the dataset_provision job), and the new dispatcher arm reconciles the lake
into existence and flips provisioning→active. The deploy sweep fans out one
lake_migrate per ACTIVE DATASET, reported as org/dataset.
pg_dataset_concurrency proves the lot: cap 1 behaves exactly as before
datasets; cap 2 runs two datasets at once while each stays single-writer;
an org-level job waits for everything and blocks everything. pg_approval
now mirrors its raw env swap onto the dataset rows — the job it enqueues
carries the default dataset, which is the point of the whole change.
Co-Authored-By: Claude Fable 5 <[email protected]>
…as not met — one org-level lake_migrate when no dataset rows exist yet Co-Authored-By: Claude Fable 5 <[email protected]>
This was referenced Nov 2, 2026
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.
PR 5 of the datasets program (after #380/#381/#383/#392). This is the rung that actually unlocks concurrent datasets — and ships with the cap at 1, so nothing changes until an operator raises it.
What
dataset_id IS NULL: provision) conflict with everything of their org, in both directions. Fixup 0003 retires the superseded per-org indexes and thetenant_schema_states UNIQUE(org_id)in-table constraint (looked up inpg_constraint— Postgres named it, and names are the fragile part).tenant_schema_statesbecomes one row per dataset via two partial uniques (a plainUNIQUE(dataset_id)would let NULL org-level rows accumulate), with split upsert statements.orgs.max_concurrent_jobs, defaulting toER_ORG_JOB_CAP(ships as 1 — the exact pre-dataset profile). A COUNT can't be index-enforced, sopg::claimserializes claims under an advisory lock; the per-dataset partial unique stays the database-level backstop.PATCH /resources, the lexicon path) fan their patch out to every dataset env — the convergence sweep deliberately never rewrites an existing dataset, so explicit mutations must.Profile::plan_dataset(local: nested dirs; postgres:ER_LAKE_CATALOG_SCHEMA=ds_<name>in the org's shared metadata DB,{dataset}substitution in the data template andenv_extra);POST /datasetswithout aconfig_pathbecomes the tenant-admin auto path (workspace + starter config v1 + aprovisioningrow + thedataset_provisionjob — BYO stays operator-only); the new dispatcher arm reconciles the lake into existence and flipsprovisioning→active.lake_migrateper ACTIVE DATASET, reported asorg/dataset.Proof
pg_dataset_concurrency(new): cap 1 behaves exactly as before datasets; cap 2 runs two datasets at once while each stays strictly single-writer; an org-level job waits for everything and blocks everything, through the full claim/mark sequence.pg_approvalmirrors its raw env swap onto the dataset rows — the job it enqueues carries the default dataset now, which is the point. Full pg suite green locally (49/49);make checkgreen.🤖 Generated with Claude Code