Skip to content

Avoid partition DDL on relay startup - #6230

Draft
bradseiler wants to merge 1 commit into
mainfrom
seiler/partition-double-check
Draft

Avoid partition DDL on relay startup#6230
bradseiler wants to merge 1 commit into
mainfrom
seiler/partition-double-check

Conversation

@bradseiler

Copy link
Copy Markdown
Contributor

Why

Relay pods currently run partition DDL on every startup even when every required monthly partition already exists. CREATE TABLE ... PARTITION OF takes an ACCESS EXCLUSIVE lock on the hot parent table, so routine pod churn can unnecessarily queue writes behind startup DDL.

What

  • Compute the expected monthly partition specifications up front and query PostgreSQL catalogs once for all expected partitions.
  • Return immediately when every partition exists, avoiding parent-table DDL locks on the normal startup path.
  • Run DDL only for missing partitions, retaining a second catalog check for races.
  • Apply a transaction-local 2-second lock_timeout on the same connection as the partition DDL.
  • Verify partition schema, parent, and range bounds before considering a partition ensured, including concurrent-creation and IF NOT EXISTS collision paths.
  • Add unit and live PostgreSQL coverage for the lock-free fast path, subset creation, concurrent creation, bounded lock timeout/recovery, and unsafe same-name collisions.

Validation

  • cargo test -p buzz-db partition::tests -- --nocapture
  • cargo test -p buzz-db partition::tests -- --ignored --nocapture
  • cargo test -p buzz-db
  • just fmt-check
  • just desktop-tauri-fmt-check
  • git diff --check origin/main...HEAD
  • Push hooks: branch-skew, file-size-check, rust-tests, desktop-tauri-checks

Generated with bb-expert

Co-authored-by: coder 0 <d97ebdbb198c7237c94f84ea8bb8a73583ea067407eebd0062abbb3962527fb1@buzz.block.builderlab.xyz>
Signed-off-by: coder 0 <d97ebdbb198c7237c94f84ea8bb8a73583ea067407eebd0062abbb3962527fb1@buzz.block.builderlab.xyz>
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.

1 participant