feat(schema): retrofit storage_parameters onto existing partition children #160
All Vouch review confidence checks passed
Residual risk 0.43 = Change Risk (0.63) × (1 − Review Confidence (0.32)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.63 · 268 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 76% · Reviewer familiarity: 10%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.335
No Reviewer Assigned
no_reviewer_assigned
0.120
Rapid Merge
rapid_merge
0.100
Real PR Conversation Timeline
1 comments
"Review active on #160"
general
weight: 0.35
tthayer
What was broken
PR #159 (v0.12.2) made
storage_parametersreach partition children at creationtime. Nothing retrofitted children that already existed.
Which strategy that actually mattered for:
partitioned = true) — the real problem. They neverroll over. A child created before the model declared the option keeps the default
forever, silently.
are created with the declared
WITH (...).The change
At the end of
Migrations():Three deliberate properties:
1. Emitted last. The consumer (c1
pkg/postgres/xpgdb/schema.go) breaks out of atable's statement loop on the first
55P03lock_timeout. Putting child ALTERs lastmeans a contended tenant partition can only cost other child ALTERs — never the
column-adds and index statements ahead of them.
2. Capped at 50 per run (
maxPartitionChildStorageParamAlters), ordered by childname. Bounds lock churn on a many-tenant table — each
ALTER TABLE ... SET (...)takes a brief ACCESS EXCLUSIVE lock. Self-advancing: converged children render
nothing, so the next run's first 50 are the next 50 that actually drift.
3. Diff-driven. Reuses the existing per-key diff via a new
storageParams2alterTable(desc, tableName, existingParams);storageParams2alteris now a one-line wrapper, so
TestStorageParams2alteris unchanged and stillpasses. No blanket re-SET, no churn on already-correct children.
Also folds the duplicated
reloptionskey=valueparsing into a sharedparseReloptionsused by both the parent and the new child reader. The newpg_inheritsreader mirrors the existingreadStorageParametersshape (same goquparameterization, same
nspname = 'public'scoping).Only costs an extra catalog query when the model is a partitioned parent and
declares storage parameters.
Migrationsstill early-returnsCreateSchemawhen thetable does not exist, so the retrofit block never runs on a fresh table.
Tests
pgdb/v1/schema_sql_test.go—TestPartitionChildAlters: 120 drifted childrentruncate to exactly 50 in name order (first is
parent_000, lastparent_049); aconverged set emits nothing; a descriptor with no declaration emits nothing.
example/models/food/v1/food_test.go—TestPartitionChildStorageParamRetrofitsimulates the real case end to end against a live Postgres: create the tenant-list
partitioned
Pastatable (declaresfillfactor: 90) plus three tenant children,assert
Migrationsemits nothing while they are converged, thenALTER TABLE <child> RESET (fillfactor)on one of the three to look like apre-declaration child. Asserts exactly that child is retrofitted, applies the ALTER,
verifies
fillfactor = 90landed, and asserts a thirdMigrationscall emits nothing.Negative test confirmed: with the retrofit block disabled,
TestPartitionChildStorageParamRetrofitfails with"[]" should have 1 item(s), but. The test genuinely guards thehas 0 / only the stale child should be retrofitted
behaviour rather than passing vacuously.
Residual limitation
execReconcilein the consumer notes that a55P03skip is "not self-healingin-process" — it retries only on the next
EnsureSchema, i.e. a redeploy. So a largeretrofit converges across deploys rather than within one: at 50/run, a 5,000-tenant
table needs ~100 deploys. Related: because the consumer abandons the remainder of a
table's statements on the first lock_timeout, a perpetually contended child head-of-line
blocks the children after it in name order for that run. Both are inherent to the
consumer's break-on-lock_timeout semantics, and both are strictly better than the status
quo, where nothing converged at all.
maxPartitionChildStorageParamAltersis the knobif the deploy count ever matters.
Linear: IGA-3716
Note: the ticket's "route lock behaviour through reconcileLockTimeout / 55P03"
criterion required no code here — that machinery lives in the consumer, not this
library.
🤖 Generated with Claude Code