forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[wip] migration: onboard the first long-running migration
This PR onboards the first real long-running migration using the infrastructure we've been building up within pkg/migration. It adds in the final missing pieces described in our original RFC (cockroachdb#48843). These components were originally prototyped in cockroachdb#56107. The migration in question (which happens to be a below-Raft one, first attempted in cockroachdb#42822) now lets us do the following: i. Use the RangeAppliedState on all ranges ii. Use the unreplicated TruncatedState on all ranges The missing pieces we introduce along side this migration are: a. The `Migrate` KV request. This forces all ranges overlapping with the request spans to execute the (below-raft) migrations corresponding to the specific version, moving out of any legacy modes they may currently be in. KV waits for this command to durably apply on all the replicas before returning, guaranteeing to the caller that all pre-migration state has been completely purged from the system. b. `IterateRangeDescriptors`. This provides a handle on every range descriptor in the system, which callers can then use to send out arbitrary KV requests to in order to run arbitrary KV-level migrations. These requests will typically just be the `Migrate` request, with added code next to the `Migrate` command implementation to do the specific KV-level things intended for the specified version. c. The `system.migrations` table. We use it to store metadata about ongoing migrations for external visibility/introspection. The schema (listed below) is designed with an eye towards scriptability. We want operators to be able programmatically use this table to control their upgrade processes, if needed. CREATE TABLE public.migrations ( version STRING NOT NULL, status STRING NOT NULL, description STRING NOT NULL, start TIMESTAMP NOT NULL DEFAULT now():::TIMESTAMP, completed TIMESTAMP NULL, progress STRING NULL, CONSTRAINT "primary" PRIMARY KEY (version ASC), FAMILY "primary" (version, status, description, start, completed, progress) ) Release note(general change): Cluster version upgrades, as initiated by `SET CLUSTER SETTING version = <major>-<minor>`, now perform internal maintenance duties that will delay how long it takes for the command to complete. The delay is proportional to the amount of data currently stored in the cluster. The cluster will also experience a small amount of additional load during this period while the upgrade is being finalized. Release note(general change): We introduce a new `system.migrations` table for introspection into crdb internal data migrations. These migrations are the "maintenance duties" mentioned above. The table surfaces the currently ongoing migrations, the previously completed migrations, and in the case of failure, the errors from the last failed attempt.
- Loading branch information
1 parent
677f6f8
commit 45ce792
Showing
49 changed files
with
2,620 additions
and
1,403 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,4 +55,3 @@ ALTER TABLE partitioned_table_3 PARTITION BY RANGE (place) | |
|
||
statement ok | ||
SELECT * FROM crdb_internal.tables | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
doctor cluster | ||
---- | ||
debug doctor cluster | ||
Examining 34 descriptors and 35 namespace entries... | ||
Examining 35 descriptors and 36 namespace entries... | ||
Table 53: ParentID 50, ParentSchemaID 29, Name 'foo': not being dropped but no namespace entry found | ||
Examining 1 running jobs... | ||
ERROR: validation failed |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,7 @@ requesting goroutine files for node 1... writing: debug/nodes/1/goroutines.err.t | |
^- resulted in ... | ||
requesting log file ... | ||
requesting log file ... | ||
requesting ranges... 35 found | ||
requesting ranges... 36 found | ||
writing: debug/nodes/1/ranges/1.json | ||
writing: debug/nodes/1/ranges/2.json | ||
writing: debug/nodes/1/ranges/3.json | ||
|
@@ -94,6 +94,7 @@ writing: debug/nodes/1/ranges/32.json | |
writing: debug/nodes/1/ranges/33.json | ||
writing: debug/nodes/1/ranges/34.json | ||
writing: debug/nodes/1/ranges/35.json | ||
writing: debug/nodes/1/ranges/36.json | ||
writing: debug/nodes/2/status.json | ||
using SQL connection URL for node 2: postgresql://... | ||
retrieving SQL data for crdb_internal.feature_usage... writing: debug/nodes/2/crdb_internal.feature_usage.txt | ||
|
@@ -190,7 +191,7 @@ requesting goroutine files for node 3... writing: debug/nodes/3/goroutines.err.t | |
^- resulted in ... | ||
requesting log file ... | ||
requesting log file ... | ||
requesting ranges... 35 found | ||
requesting ranges... 36 found | ||
writing: debug/nodes/3/ranges/1.json | ||
writing: debug/nodes/3/ranges/2.json | ||
writing: debug/nodes/3/ranges/3.json | ||
|
@@ -226,13 +227,14 @@ writing: debug/nodes/3/ranges/32.json | |
writing: debug/nodes/3/ranges/33.json | ||
writing: debug/nodes/3/ranges/34.json | ||
writing: debug/nodes/3/ranges/35.json | ||
writing: debug/nodes/3/ranges/36.json | ||
requesting list of SQL databases... 3 found | ||
requesting database details for defaultdb... writing: debug/schema/[email protected] | ||
0 tables found | ||
requesting database details for postgres... writing: debug/schema/[email protected] | ||
0 tables found | ||
requesting database details for system... writing: debug/schema/[email protected] | ||
29 tables found | ||
30 tables found | ||
requesting table details for system.public.namespace... writing: debug/schema/system/public_namespace.json | ||
requesting table details for system.public.descriptor... writing: debug/schema/system/public_descriptor.json | ||
requesting table details for system.public.users... writing: debug/schema/system/public_users.json | ||
|
@@ -262,5 +264,6 @@ requesting table details for system.public.statement_diagnostics_requests... wri | |
requesting table details for system.public.statement_diagnostics... writing: debug/schema/system/public_statement_diagnostics.json | ||
requesting table details for system.public.scheduled_jobs... writing: debug/schema/system/public_scheduled_jobs.json | ||
requesting table details for system.public.sqlliveness... writing: debug/schema/system/public_sqlliveness.json | ||
requesting table details for system.public.migrations... writing: debug/schema/system/public_migrations.json | ||
writing: debug/pprof-summary.sh | ||
writing: debug/hot-ranges.sh |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,7 @@ requesting goroutine files for node 1... writing: debug/nodes/1/goroutines.err.t | |
^- resulted in ... | ||
requesting log file ... | ||
requesting log file ... | ||
requesting ranges... 35 found | ||
requesting ranges... 36 found | ||
writing: debug/nodes/1/ranges/1.json | ||
writing: debug/nodes/1/ranges/2.json | ||
writing: debug/nodes/1/ranges/3.json | ||
|
@@ -94,6 +94,7 @@ writing: debug/nodes/1/ranges/32.json | |
writing: debug/nodes/1/ranges/33.json | ||
writing: debug/nodes/1/ranges/34.json | ||
writing: debug/nodes/1/ranges/35.json | ||
writing: debug/nodes/1/ranges/36.json | ||
writing: debug/nodes/2.skipped | ||
writing: debug/nodes/3/status.json | ||
using SQL connection URL for node 3: postgresql://... | ||
|
@@ -124,7 +125,7 @@ requesting goroutine files for node 3... writing: debug/nodes/3/goroutines.err.t | |
^- resulted in ... | ||
requesting log file ... | ||
requesting log file ... | ||
requesting ranges... 35 found | ||
requesting ranges... 36 found | ||
writing: debug/nodes/3/ranges/1.json | ||
writing: debug/nodes/3/ranges/2.json | ||
writing: debug/nodes/3/ranges/3.json | ||
|
@@ -160,13 +161,14 @@ writing: debug/nodes/3/ranges/32.json | |
writing: debug/nodes/3/ranges/33.json | ||
writing: debug/nodes/3/ranges/34.json | ||
writing: debug/nodes/3/ranges/35.json | ||
writing: debug/nodes/3/ranges/36.json | ||
requesting list of SQL databases... 3 found | ||
requesting database details for defaultdb... writing: debug/schema/[email protected] | ||
0 tables found | ||
requesting database details for postgres... writing: debug/schema/[email protected] | ||
0 tables found | ||
requesting database details for system... writing: debug/schema/[email protected] | ||
29 tables found | ||
30 tables found | ||
requesting table details for system.public.namespace... writing: debug/schema/system/public_namespace.json | ||
requesting table details for system.public.descriptor... writing: debug/schema/system/public_descriptor.json | ||
requesting table details for system.public.users... writing: debug/schema/system/public_users.json | ||
|
@@ -196,5 +198,6 @@ requesting table details for system.public.statement_diagnostics_requests... wri | |
requesting table details for system.public.statement_diagnostics... writing: debug/schema/system/public_statement_diagnostics.json | ||
requesting table details for system.public.scheduled_jobs... writing: debug/schema/system/public_scheduled_jobs.json | ||
requesting table details for system.public.sqlliveness... writing: debug/schema/system/public_sqlliveness.json | ||
requesting table details for system.public.migrations... writing: debug/schema/system/public_migrations.json | ||
writing: debug/pprof-summary.sh | ||
writing: debug/hot-ranges.sh |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,7 @@ requesting goroutine files for node 1... writing: debug/nodes/1/goroutines.err.t | |
^- resulted in ... | ||
requesting log file ... | ||
requesting log file ... | ||
requesting ranges... 35 found | ||
requesting ranges... 36 found | ||
writing: debug/nodes/1/ranges/1.json | ||
writing: debug/nodes/1/ranges/2.json | ||
writing: debug/nodes/1/ranges/3.json | ||
|
@@ -94,6 +94,7 @@ writing: debug/nodes/1/ranges/32.json | |
writing: debug/nodes/1/ranges/33.json | ||
writing: debug/nodes/1/ranges/34.json | ||
writing: debug/nodes/1/ranges/35.json | ||
writing: debug/nodes/1/ranges/36.json | ||
writing: debug/nodes/3/status.json | ||
using SQL connection URL for node 3: postgresql://... | ||
retrieving SQL data for crdb_internal.feature_usage... writing: debug/nodes/3/crdb_internal.feature_usage.txt | ||
|
@@ -123,7 +124,7 @@ requesting goroutine files for node 3... writing: debug/nodes/3/goroutines.err.t | |
^- resulted in ... | ||
requesting log file ... | ||
requesting log file ... | ||
requesting ranges... 35 found | ||
requesting ranges... 36 found | ||
writing: debug/nodes/3/ranges/1.json | ||
writing: debug/nodes/3/ranges/2.json | ||
writing: debug/nodes/3/ranges/3.json | ||
|
@@ -159,13 +160,14 @@ writing: debug/nodes/3/ranges/32.json | |
writing: debug/nodes/3/ranges/33.json | ||
writing: debug/nodes/3/ranges/34.json | ||
writing: debug/nodes/3/ranges/35.json | ||
writing: debug/nodes/3/ranges/36.json | ||
requesting list of SQL databases... 3 found | ||
requesting database details for defaultdb... writing: debug/schema/[email protected] | ||
0 tables found | ||
requesting database details for postgres... writing: debug/schema/[email protected] | ||
0 tables found | ||
requesting database details for system... writing: debug/schema/[email protected] | ||
29 tables found | ||
30 tables found | ||
requesting table details for system.public.namespace... writing: debug/schema/system/public_namespace.json | ||
requesting table details for system.public.descriptor... writing: debug/schema/system/public_descriptor.json | ||
requesting table details for system.public.users... writing: debug/schema/system/public_users.json | ||
|
@@ -195,5 +197,6 @@ requesting table details for system.public.statement_diagnostics_requests... wri | |
requesting table details for system.public.statement_diagnostics... writing: debug/schema/system/public_statement_diagnostics.json | ||
requesting table details for system.public.scheduled_jobs... writing: debug/schema/system/public_scheduled_jobs.json | ||
requesting table details for system.public.sqlliveness... writing: debug/schema/system/public_sqlliveness.json | ||
requesting table details for system.public.migrations... writing: debug/schema/system/public_migrations.json | ||
writing: debug/pprof-summary.sh | ||
writing: debug/hot-ranges.sh |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ requesting table details for defaultdb.public."../system"... writing: debug/sche | |
requesting database details for postgres... writing: debug/schema/[email protected] | ||
0 tables found | ||
requesting database details for system... writing: debug/schema/[email protected] | ||
29 tables found | ||
30 tables found | ||
requesting table details for system.public.namespace... writing: debug/schema/system-1/public_namespace.json | ||
requesting table details for system.public.descriptor... writing: debug/schema/system-1/public_descriptor.json | ||
requesting table details for system.public.users... writing: debug/schema/system-1/public_users.json | ||
|
@@ -51,3 +51,4 @@ requesting table details for system.public.statement_diagnostics_requests... wri | |
requesting table details for system.public.statement_diagnostics... writing: debug/schema/system-1/public_statement_diagnostics.json | ||
requesting table details for system.public.scheduled_jobs... writing: debug/schema/system-1/public_scheduled_jobs.json | ||
requesting table details for system.public.sqlliveness... writing: debug/schema/system-1/public_sqlliveness.json | ||
requesting table details for system.public.migrations... writing: debug/schema/system-1/public_migrations.json |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,7 @@ requesting heap profile for node 1... writing: debug/nodes/1/heap.pprof | |
requesting heap files for node 1... ? found | ||
requesting goroutine files for node 1... 0 found | ||
requesting log file ... | ||
requesting ranges... 35 found | ||
requesting ranges... 36 found | ||
writing: debug/nodes/1/ranges/1.json | ||
writing: debug/nodes/1/ranges/2.json | ||
writing: debug/nodes/1/ranges/3.json | ||
|
@@ -93,13 +93,14 @@ writing: debug/nodes/1/ranges/32.json | |
writing: debug/nodes/1/ranges/33.json | ||
writing: debug/nodes/1/ranges/34.json | ||
writing: debug/nodes/1/ranges/35.json | ||
writing: debug/nodes/1/ranges/36.json | ||
requesting list of SQL databases... 3 found | ||
requesting database details for defaultdb... writing: debug/schema/[email protected] | ||
0 tables found | ||
requesting database details for postgres... writing: debug/schema/[email protected] | ||
0 tables found | ||
requesting database details for system... writing: debug/schema/[email protected] | ||
29 tables found | ||
30 tables found | ||
requesting table details for system.public.namespace... writing: debug/schema/system/public_namespace.json | ||
requesting table details for system.public.descriptor... writing: debug/schema/system/public_descriptor.json | ||
requesting table details for system.public.users... writing: debug/schema/system/public_users.json | ||
|
@@ -129,5 +130,6 @@ requesting table details for system.public.statement_diagnostics_requests... wri | |
requesting table details for system.public.statement_diagnostics... writing: debug/schema/system/public_statement_diagnostics.json | ||
requesting table details for system.public.scheduled_jobs... writing: debug/schema/system/public_scheduled_jobs.json | ||
requesting table details for system.public.sqlliveness... writing: debug/schema/system/public_sqlliveness.json | ||
requesting table details for system.public.migrations... writing: debug/schema/system/public_migrations.json | ||
writing: debug/pprof-summary.sh | ||
writing: debug/hot-ranges.sh |
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.