Skip to content

fix(models): model versions are keyed per dataset, so a second dataset can upload and activate its own default (#1444) - #1447

Merged
athvin merged 1 commit into
mainfrom
fix/1444-model-key-per-dataset
Nov 29, 2026
Merged

athvin merged 1 commit into
mainfrom
fix/1444-model-key-per-dataset

Conversation

@athvin

@athvin athvin commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

Closes #1444

Post-merge is part of this pull request. The ledger below records whether
the follow-up work actually happened. /land-pr closes it.

What

Model versions are keyed per dataset.

  • matching_models' two uniques are re-scoped to (dataset_id, name, version) and (dataset_id, name) WHERE active.
  • Fixup 0007_per_dataset_model_keys drops the org-scoped originals on live stores.
  • A unique violation on upload (now only a racing concurrent upload) is a 409 rather than a raw 500.

Why

A second dataset's first model under the default name returned a 500 with the raw constraint text (found live setting up #558). Activating its default would have collided with the first dataset's active model. Choice: the fixup is Safe, like 0006, because it only loosens and every model statement was already dataset-scoped.

Proof

make check exit 0. New pg_model_per_dataset: two datasets each get default v1, and activating v2 in one leaves the other at v1. The store carries only the per-dataset keys. pg_model_registry (constraint-name assertion renamed) and pg_schema_replay pass.

Risk & rollback

The boot creates two unique indexes and drops two. Existing rows are unique per org, so they're unique per dataset and the new indexes can't fail to build. Rollback: git revert <merge-sha>; the dropped org-scoped indexes are not recreated, which only loosens.

Post-merge ledger

Closed by: agent · session Claude Code:24d16c2e-fec6-49d8-9797-060338df4848 on brians-MacBook-Pro · 2026-11-29T16:34:50Z

  • main is green with this change on it — 6273157ce0c092c93713584f0fd281f28f9ef2b9 passed Rust, frontend and infra.
  • images — both multi-architecture image builds passed.
  • deploy — production passed. In staging er-server migrate-tenants reported one active tenant enqueued for catalog 5820e10ad626. The post-upgrade hook was still waiting after 20 minutes. Staging cutover and convergence require verification. — run 46278535844: attempts 1 and 2 timed out in the post-upgrade er-tenant-migrate hook behind 10M-scale spill run without eviction #558's running 10M job (the one-writer trap, not this diff). Attempt 3, after the job was cancelled at 16:21Z, succeeded: DEPLOY_SHA 6273157, web-api-green logged 'er-server listening' at 16:32:03Z with p3live holding two datasets
  • the push-only surface no pull request can pre-test (deploy, drift,
    kind's nightly leg) is green, or knowingly red for a reason that is not
    this change: — infra, devcontainer success on 6273157
  • Board card — fix(models): a second dataset's first model upload 500s — matching_models' unique key is org-scoped, not dataset-scoped #1444 closed at squash merge. Its Product Roadmap and Duck Fleet Product Roadmap cards both reached Done through automation.
  • follow-ups are open for everything deferred here — numbers: — none
  • what was learned is written down where the next session will find it
    (a skill, a reference, memory) — or nothing new was learned: — a rollback restores the previous colour's image, so an old image can crash-loop on newer data; that is the rollback, not the new build

Specific to this change

Context — plan, discoveries, measurements, files

Plan

Discoveries

Measurements

Files

🤖 Generated with Claude Code

…t can upload and activate its own default (#1444)

matching_models carried two org-scoped uniques: (org_id, name, version)
and (org_id, name) WHERE active. Every model statement allocates,
activates and reads per dataset, so a second dataset's first upload
under the default name hit a unique violation, served as a 500 with the
raw constraint text. Found live on er-dev setting up #558. Activating a
second dataset's default would have collided the same way.

- The indexes are re-scoped to (dataset_id, name, version) and
  (dataset_id, name) WHERE active.
- Fixup 0007_per_dataset_model_keys drops the org-scoped originals on
  live stores. Safe, like 0006: it only loosens, and no release relied
  on org-wide uniqueness.
- create_model_version maps a unique violation (now only a racing
  concurrent upload) to 409 instead of a raw 500.

pg_model_per_dataset: two datasets each get their own default v1, and
activating v2 in one leaves the other's v1 active. The store carries
only the per-dataset keys. pg_model_registry's constraint-name
assertion follows the rename; it and pg_schema_replay pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

The marketing preview was removed because this PR is closed or merged.

This branch was previously deployed

1 inactive deployment
marketing-preview — 740a2058 Deployed Nov 29, 2026 by athvin via remove closed PR previews #171
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.

fix(models): a second dataset's first model upload 500s — matching_models' unique key is org-scoped, not dataset-scoped

2 participants