Repository navigation
fix(server): drop the V1 tables V2 never reads - #20946
Closed
derektrimm wants to merge 1 commit into
Closed
derektrimm wants to merge 1 commit into
derektrimm wants to merge 1 commit into
Conversation
The V2 database starts as a backup of the V1 one, so every V1 table came along. The legacy importer reads only V1 threads, messages and pull request links; the activity, turn, proposed plan, pending approval, projection state and checkpoint diff tables stayed for good, 5.9 GiB of activities on one long-lived install. Fixes pingdotgg#20922
Contributor
ApprovabilityVerdict: Needs Human Approval Macroscope's review found this PR requires human approval — This PR adds a production migration that irreversibly removes six persisted tables and may substantially increase first-boot migration time for large databases. Although tests support the unused-table rationale and the other changes are limited to fixtures and documentation, the destructive schema change warrants human review. You can add or adjust custom eligibility rules. Learn more. |
Member
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.
Fixes #20922
The V2 database starts as a full backup of the V1
state.sqlite, so every V1 table comes along. The legacy importer reads only V1 threads, messages and pull request links, and nothing else onmainreadsprojection_thread_activities,projection_turns,projection_thread_proposed_plans,projection_pending_approvals,projection_stateorcheckpoint_diff_blobs. They stayed instatev2.sqlitefor good, andt3 doctor --fixcopied them into the rebuilt file.Migration 063 drops those six tables. Their pages join the free list, which the Storage status already counts as reclaimable and
t3 doctor --fixreturns to disk.scripts/mobile-showcase-environment.tsstops seeding them; per its own comment, V2 clients never read those rows. The screenshot doc no longer lists activities among the seeded data.Checked on a
VACUUM INTOcopy of a real 0.0.45 database (14.1 GiB, 351 threads, 1.63M V1 events, about 1.0M activities). Each arm booted its own copy until the transcript import finished (importedThreadCount: 351, importedMessageCount: 48255), then rant3 doctor --fix:main(133f57a)statev2.sqliteaftert3 doctor --fixprojection_thread_activities, 5.7 GiBprojection_thread_messages, 109 MiBt3 doctor --fixdurationrunMigrationson first bootThe cost is on first boot. Dropping a 5.9 GiB table means SQLite reads every overflow page to free it. In the server that added 44 s to migrations on this machine (SATA SSD, NTFS). On its own, the drop took 52 to 54 s on an NVMe btrfs box, 31 s of it kernel time.
mmap_sizedid not change that, and a 256 MiB page cache brought it to 38 s. It runs once and scales with the size of the activities table. The upgrade it joins already backs up the whole V1 database first.The new
063_DropUnreadV1Projectionstest fails when the migration does nothing. The migration list tests, the legacy importer, cutover andinitializeV2Databasetests,DatabaseMaintenanceandmobile-showcasetests pass. Typecheck, lint and format pass forapps/serverandscripts.Not checked: running the mobile showcase end to end, since it needs the mobile build. A V2 preview database migrated by
reconcileV2PreviewMigrationtakes the same migration, and its test passes.Made with Claude Opus 5.5 in Claude Code, running in T3 Code.