fix(coprocessor): reduce 0.12 migration lock time#2365
Draft
Eikix wants to merge 2 commits intorelease/0.12.xfrom
Draft
fix(coprocessor): reduce 0.12 migration lock time#2365Eikix wants to merge 2 commits intorelease/0.12.xfrom
Eikix wants to merge 2 commits intorelease/0.12.xfrom
Conversation
Changed Lines CoverageCoverage of added/modified lines: N/A Per-file breakdownDiff CoverageDiff: origin/release/0.12.x...HEAD, staged and unstaged changesNo lines with coverage information in this diff. |
5000745 to
2f9a986
Compare
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.
What
Backport a safer 0.12 coprocessor DB migration for large testnet-sized databases.
Changes:
tenant_iddoes not match the single tenant before deriving host-chain/key defaultshost_chain_id/key_id_gwasNOT NULL DEFAULTconstants instead of full-table backfillsCHECKconstraints asNOT VALID-- no-transactionmigrations using retry-safeDROP INDEX CONCURRENTLY IF EXISTS+CREATE UNIQUE INDEX CONCURRENTLYWhy
The previous migration performed non-concurrent index builds, full-table updates,
SET NOT NULL, and constraint validation inside one long migration. On the testnet snapshot this held strong locks for hours and generated heavy IO/WAL pressure.This keeps the physical index work, but avoids the full-table rewrites for
host_chain_id/key_id_gwand moves unique-index builds into concurrent index migrations.Operational caveats
20260128095635. Any environment that already applied the previous 0.12.x version must be reset/rebased or have explicit_sqlx_migrationshandling before running this image.CREATE UNIQUE INDEX CONCURRENTLY, so they avoid longACCESS EXCLUSIVEtable locks but can still wait behind long-running transactions.CHECKconstraints areNOT VALID. Existing rows receive non-negative constant defaults in this migration; constraint validation can be done in a follow-up migration if needed.Validation
cargo fmt --checkcargo checkcargo-audit audit --ignore RUSTSEC-2026-0098 --ignore RUSTSEC-2026-0099 --ignore RUSTSEC-2026-0104cargo update -w --lockedSQLX_OFFLINE=true cargo check -p tfhe-workerSQLX_OFFLINE=true cargo test -p tfhe-worker migrations -- --nocapturecompiled, then failed because the local Docker/Postgres test harness was unavailable (Connection refused).