From 971818b7976cafd549c600c2226330865d154513 Mon Sep 17 00:00:00 2001 From: Andrew Werner Date: Wed, 14 Jul 2021 08:09:30 -0400 Subject: [PATCH 1/2] startupmigrations: rename from sqlmigrations There was nothing particularly `sql` about these migrations except, maybe, that they had access to sql. Release note: None --- .github/CODEOWNERS | 2 +- pkg/BUILD.bazel | 4 +- pkg/base/testing_knobs.go | 38 +++++++-------- .../changefeedccl/helpers_tenant_shim_test.go | 48 +++++++++---------- pkg/cli/BUILD.bazel | 2 +- pkg/cli/gen.go | 4 +- pkg/migration/migrations/BUILD.bazel | 2 +- pkg/migration/migrations/join_tokens.go | 4 +- pkg/migration/migrations/sql_stats.go | 6 +-- pkg/server/BUILD.bazel | 4 +- pkg/server/migration_test.go | 4 +- pkg/server/server.go | 2 +- pkg/server/server_sql.go | 16 +++---- pkg/server/testserver.go | 10 ++-- pkg/sql/BUILD.bazel | 2 +- pkg/sql/catalog/lease/lease_internal_test.go | 2 +- pkg/sql/create_test.go | 4 +- pkg/sql/drop_test.go | 6 +-- pkg/sql/indexbackfiller_test.go | 4 +- pkg/sql/rowexec/BUILD.bazel | 2 +- pkg/sql/rowexec/backfiller_test.go | 4 +- pkg/sql/schema_changer_test.go | 42 ++++++++-------- .../BUILD.bazel | 13 +++-- .../leasemanager/BUILD.bazel | 4 +- .../leasemanager/lease.go | 2 +- .../leasemanager/lease.pb.go | 39 +++++++-------- .../leasemanager/lease.proto | 0 .../leasemanager/lease_test.go | 2 +- .../leasemanager/main_test.go | 0 .../main_test.go | 2 +- .../migrations.go | 4 +- .../migrations_test.go | 4 +- pkg/testutils/serverutils/test_server_shim.go | 4 +- 33 files changed, 143 insertions(+), 143 deletions(-) rename pkg/{sqlmigrations => startupmigrations}/BUILD.bazel (86%) rename pkg/{sqlmigrations => startupmigrations}/leasemanager/BUILD.bazel (89%) rename pkg/{sqlmigrations => startupmigrations}/leasemanager/lease.go (99%) rename pkg/{sqlmigrations => startupmigrations}/leasemanager/lease.pb.go (82%) rename pkg/{sqlmigrations => startupmigrations}/leasemanager/lease.proto (100%) rename pkg/{sqlmigrations => startupmigrations}/leasemanager/lease_test.go (98%) rename pkg/{sqlmigrations => startupmigrations}/leasemanager/main_test.go (100%) rename pkg/{sqlmigrations => startupmigrations}/main_test.go (96%) rename pkg/{sqlmigrations => startupmigrations}/migrations.go (99%) rename pkg/{sqlmigrations => startupmigrations}/migrations_test.go (99%) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 169a4c80b1b7..a14c5eba7e83 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -181,7 +181,7 @@ /pkg/security/ @cockroachdb/server-prs /pkg/settings/ @cockroachdb/server-prs /pkg/sql/ @cockroachdb/sql-queries-noreview -/pkg/sqlmigrations/ @cockroachdb/sql-queries-noreview +/pkg/startupmigrations/ @cockroachdb/sql-queries-noreview /pkg/streaming/ @cockroachdb/bulk-prs /pkg/testutils/ @cockroachdb/test-eng /pkg/ts/ @cockroachdb/kv diff --git a/pkg/BUILD.bazel b/pkg/BUILD.bazel index 077cd9887843..7e4ba4dca2e8 100644 --- a/pkg/BUILD.bazel +++ b/pkg/BUILD.bazel @@ -279,8 +279,8 @@ ALL_TESTS = [ "//pkg/sql/tests:tests_test", "//pkg/sql/types:types_test", "//pkg/sql:sql_test", - "//pkg/sqlmigrations/leasemanager:leasemanager_test", - "//pkg/sqlmigrations:sqlmigrations_test", + "//pkg/startupmigrations/leasemanager:leasemanager_test", + "//pkg/startupmigrations:startupmigrations_test", "//pkg/storage/cloud/amazon:amazon_test", "//pkg/storage/cloud/azure:azure_test", "//pkg/storage/cloud/gcp:gcp_test", diff --git a/pkg/base/testing_knobs.go b/pkg/base/testing_knobs.go index f41abfd9bedf..b760e6f4d6e3 100644 --- a/pkg/base/testing_knobs.go +++ b/pkg/base/testing_knobs.go @@ -19,23 +19,23 @@ type ModuleTestingKnobs interface { // TestingKnobs contains facilities for controlling various parts of the // system for testing. type TestingKnobs struct { - Store ModuleTestingKnobs - KVClient ModuleTestingKnobs - RangeFeed ModuleTestingKnobs - SQLExecutor ModuleTestingKnobs - SQLLeaseManager ModuleTestingKnobs - SQLSchemaChanger ModuleTestingKnobs - SQLNewSchemaChanger ModuleTestingKnobs - SQLTypeSchemaChanger ModuleTestingKnobs - GCJob ModuleTestingKnobs - PGWireTestingKnobs ModuleTestingKnobs - SQLMigrationManager ModuleTestingKnobs - DistSQL ModuleTestingKnobs - SQLEvalContext ModuleTestingKnobs - NodeLiveness ModuleTestingKnobs - Server ModuleTestingKnobs - TenantTestingKnobs ModuleTestingKnobs - JobsTestingKnobs ModuleTestingKnobs - BackupRestore ModuleTestingKnobs - MigrationManager ModuleTestingKnobs + Store ModuleTestingKnobs + KVClient ModuleTestingKnobs + RangeFeed ModuleTestingKnobs + SQLExecutor ModuleTestingKnobs + SQLLeaseManager ModuleTestingKnobs + SQLSchemaChanger ModuleTestingKnobs + SQLNewSchemaChanger ModuleTestingKnobs + SQLTypeSchemaChanger ModuleTestingKnobs + GCJob ModuleTestingKnobs + PGWireTestingKnobs ModuleTestingKnobs + StartupMigrationManager ModuleTestingKnobs + DistSQL ModuleTestingKnobs + SQLEvalContext ModuleTestingKnobs + NodeLiveness ModuleTestingKnobs + Server ModuleTestingKnobs + TenantTestingKnobs ModuleTestingKnobs + JobsTestingKnobs ModuleTestingKnobs + BackupRestore ModuleTestingKnobs + MigrationManager ModuleTestingKnobs } diff --git a/pkg/ccl/changefeedccl/helpers_tenant_shim_test.go b/pkg/ccl/changefeedccl/helpers_tenant_shim_test.go index 7bb8fa322d98..abc1a4b1b11b 100644 --- a/pkg/ccl/changefeedccl/helpers_tenant_shim_test.go +++ b/pkg/ccl/changefeedccl/helpers_tenant_shim_test.go @@ -51,30 +51,30 @@ func (t *testServerShim) ServingSQLAddr() string { return t.SQLAddr() } -func (t *testServerShim) Stopper() *stop.Stopper { panic(unsupportedShimMethod) } -func (t *testServerShim) Start(context.Context) error { panic(unsupportedShimMethod) } -func (t *testServerShim) Node() interface{} { panic(unsupportedShimMethod) } -func (t *testServerShim) NodeID() roachpb.NodeID { panic(unsupportedShimMethod) } -func (t *testServerShim) ClusterID() uuid.UUID { panic(unsupportedShimMethod) } -func (t *testServerShim) ServingRPCAddr() string { panic(unsupportedShimMethod) } -func (t *testServerShim) RPCAddr() string { panic(unsupportedShimMethod) } -func (t *testServerShim) DB() *kv.DB { panic(unsupportedShimMethod) } -func (t *testServerShim) RPCContext() *rpc.Context { panic(unsupportedShimMethod) } -func (t *testServerShim) LeaseManager() interface{} { panic(unsupportedShimMethod) } -func (t *testServerShim) InternalExecutor() interface{} { panic(unsupportedShimMethod) } -func (t *testServerShim) ExecutorConfig() interface{} { panic(unsupportedShimMethod) } -func (t *testServerShim) Tracer() interface{} { panic(unsupportedShimMethod) } -func (t *testServerShim) GossipI() interface{} { panic(unsupportedShimMethod) } -func (t *testServerShim) RangeFeedFactory() interface{} { panic(unsupportedShimMethod) } -func (t *testServerShim) Clock() *hlc.Clock { panic(unsupportedShimMethod) } -func (t *testServerShim) DistSenderI() interface{} { panic(unsupportedShimMethod) } -func (t *testServerShim) MigrationServer() interface{} { panic(unsupportedShimMethod) } -func (t *testServerShim) SQLServer() interface{} { panic(unsupportedShimMethod) } -func (t *testServerShim) SQLLivenessProvider() interface{} { panic(unsupportedShimMethod) } -func (t *testServerShim) SQLMigrationsManager() interface{} { panic(unsupportedShimMethod) } -func (t *testServerShim) NodeLiveness() interface{} { panic(unsupportedShimMethod) } -func (t *testServerShim) HeartbeatNodeLiveness() error { panic(unsupportedShimMethod) } -func (t *testServerShim) NodeDialer() interface{} { panic(unsupportedShimMethod) } +func (t *testServerShim) Stopper() *stop.Stopper { panic(unsupportedShimMethod) } +func (t *testServerShim) Start(context.Context) error { panic(unsupportedShimMethod) } +func (t *testServerShim) Node() interface{} { panic(unsupportedShimMethod) } +func (t *testServerShim) NodeID() roachpb.NodeID { panic(unsupportedShimMethod) } +func (t *testServerShim) ClusterID() uuid.UUID { panic(unsupportedShimMethod) } +func (t *testServerShim) ServingRPCAddr() string { panic(unsupportedShimMethod) } +func (t *testServerShim) RPCAddr() string { panic(unsupportedShimMethod) } +func (t *testServerShim) DB() *kv.DB { panic(unsupportedShimMethod) } +func (t *testServerShim) RPCContext() *rpc.Context { panic(unsupportedShimMethod) } +func (t *testServerShim) LeaseManager() interface{} { panic(unsupportedShimMethod) } +func (t *testServerShim) InternalExecutor() interface{} { panic(unsupportedShimMethod) } +func (t *testServerShim) ExecutorConfig() interface{} { panic(unsupportedShimMethod) } +func (t *testServerShim) Tracer() interface{} { panic(unsupportedShimMethod) } +func (t *testServerShim) GossipI() interface{} { panic(unsupportedShimMethod) } +func (t *testServerShim) RangeFeedFactory() interface{} { panic(unsupportedShimMethod) } +func (t *testServerShim) Clock() *hlc.Clock { panic(unsupportedShimMethod) } +func (t *testServerShim) DistSenderI() interface{} { panic(unsupportedShimMethod) } +func (t *testServerShim) MigrationServer() interface{} { panic(unsupportedShimMethod) } +func (t *testServerShim) SQLServer() interface{} { panic(unsupportedShimMethod) } +func (t *testServerShim) SQLLivenessProvider() interface{} { panic(unsupportedShimMethod) } +func (t *testServerShim) StartupMigrationsManager() interface{} { panic(unsupportedShimMethod) } +func (t *testServerShim) NodeLiveness() interface{} { panic(unsupportedShimMethod) } +func (t *testServerShim) HeartbeatNodeLiveness() error { panic(unsupportedShimMethod) } +func (t *testServerShim) NodeDialer() interface{} { panic(unsupportedShimMethod) } func (t *testServerShim) SetDistSQLSpanResolver(spanResolver interface{}) { panic(unsupportedShimMethod) } diff --git a/pkg/cli/BUILD.bazel b/pkg/cli/BUILD.bazel index e9cbbc02754d..b05bc9af5e8a 100644 --- a/pkg/cli/BUILD.bazel +++ b/pkg/cli/BUILD.bazel @@ -148,7 +148,7 @@ go_library( "//pkg/sql/row", "//pkg/sql/sem/builtins", "//pkg/sql/sem/tree", - "//pkg/sqlmigrations", + "//pkg/startupmigrations", "//pkg/storage", "//pkg/storage/cloud", "//pkg/storage/cloud/userfile", diff --git a/pkg/cli/gen.go b/pkg/cli/gen.go index a42dea891ca4..4a7d0ed09f47 100644 --- a/pkg/cli/gen.go +++ b/pkg/cli/gen.go @@ -23,7 +23,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/cli/clisqlclient" "github.com/cockroachdb/cockroach/pkg/settings" "github.com/cockroachdb/cockroach/pkg/settings/cluster" - "github.com/cockroachdb/cockroach/pkg/sqlmigrations" + "github.com/cockroachdb/cockroach/pkg/startupmigrations" "github.com/cockroachdb/errors/oserror" "github.com/spf13/cobra" "github.com/spf13/cobra/doc" @@ -234,7 +234,7 @@ Output the list of cluster settings known to this binary. defaultVal = sm.SettingsListDefault() } else { defaultVal = setting.String(&s.SV) - if override, ok := sqlmigrations.SettingsDefaultOverrides[name]; ok { + if override, ok := startupmigrations.SettingsDefaultOverrides[name]; ok { defaultVal = override } } diff --git a/pkg/migration/migrations/BUILD.bazel b/pkg/migration/migrations/BUILD.bazel index d476a11a97a2..134cb768fd16 100644 --- a/pkg/migration/migrations/BUILD.bazel +++ b/pkg/migration/migrations/BUILD.bazel @@ -28,7 +28,7 @@ go_library( "//pkg/sql/catalog/systemschema", "//pkg/sql/sem/tree", "//pkg/sql/sqlutil", - "//pkg/sqlmigrations", + "//pkg/startupmigrations", "//pkg/util/encoding", "//pkg/util/hlc", "//pkg/util/log", diff --git a/pkg/migration/migrations/join_tokens.go b/pkg/migration/migrations/join_tokens.go index 86f550faedc6..48995a61b845 100644 --- a/pkg/migration/migrations/join_tokens.go +++ b/pkg/migration/migrations/join_tokens.go @@ -16,13 +16,13 @@ import ( "github.com/cockroachdb/cockroach/pkg/clusterversion" "github.com/cockroachdb/cockroach/pkg/migration" "github.com/cockroachdb/cockroach/pkg/sql/catalog/systemschema" - "github.com/cockroachdb/cockroach/pkg/sqlmigrations" + "github.com/cockroachdb/cockroach/pkg/startupmigrations" ) func joinTokensTableMigration( ctx context.Context, _ clusterversion.ClusterVersion, d migration.TenantDeps, ) error { - return sqlmigrations.CreateSystemTable( + return startupmigrations.CreateSystemTable( ctx, d.DB, d.Codec, d.Settings, systemschema.JoinTokensTable, ) } diff --git a/pkg/migration/migrations/sql_stats.go b/pkg/migration/migrations/sql_stats.go index fd20ad584b19..94d9a129b6e7 100644 --- a/pkg/migration/migrations/sql_stats.go +++ b/pkg/migration/migrations/sql_stats.go @@ -16,13 +16,13 @@ import ( "github.com/cockroachdb/cockroach/pkg/clusterversion" "github.com/cockroachdb/cockroach/pkg/migration" "github.com/cockroachdb/cockroach/pkg/sql/catalog/systemschema" - "github.com/cockroachdb/cockroach/pkg/sqlmigrations" + "github.com/cockroachdb/cockroach/pkg/startupmigrations" ) func sqlStatementStatsTableMigration( ctx context.Context, _ clusterversion.ClusterVersion, d migration.TenantDeps, ) error { - return sqlmigrations.CreateSystemTable( + return startupmigrations.CreateSystemTable( ctx, d.DB, d.Codec, d.Settings, systemschema.StatementStatisticsTable, ) } @@ -30,7 +30,7 @@ func sqlStatementStatsTableMigration( func sqlTransactionStatsTableMigration( ctx context.Context, _ clusterversion.ClusterVersion, d migration.TenantDeps, ) error { - return sqlmigrations.CreateSystemTable( + return startupmigrations.CreateSystemTable( ctx, d.DB, d.Codec, d.Settings, systemschema.TransactionStatisticsTable, ) } diff --git a/pkg/server/BUILD.bazel b/pkg/server/BUILD.bazel index b7773905f827..8919ca0d6429 100644 --- a/pkg/server/BUILD.bazel +++ b/pkg/server/BUILD.bazel @@ -141,7 +141,7 @@ go_library( "//pkg/sql/stats", "//pkg/sql/stmtdiagnostics", "//pkg/sql/types", - "//pkg/sqlmigrations", + "//pkg/startupmigrations", "//pkg/storage", "//pkg/storage/cloud", "//pkg/storage/enginepb", @@ -323,7 +323,7 @@ go_test( "//pkg/sql/sem/tree", "//pkg/sql/sqlstats", "//pkg/sql/tests", - "//pkg/sqlmigrations", + "//pkg/startupmigrations", "//pkg/storage", "//pkg/storage/enginepb", "//pkg/testutils", diff --git a/pkg/server/migration_test.go b/pkg/server/migration_test.go index e2e7124c8ba0..68c465326545 100644 --- a/pkg/server/migration_test.go +++ b/pkg/server/migration_test.go @@ -22,7 +22,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/roachpb" "github.com/cockroachdb/cockroach/pkg/server/serverpb" "github.com/cockroachdb/cockroach/pkg/settings/cluster" - "github.com/cockroachdb/cockroach/pkg/sqlmigrations" + "github.com/cockroachdb/cockroach/pkg/startupmigrations" "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" "github.com/cockroachdb/cockroach/pkg/testutils/sqlutils" @@ -254,7 +254,7 @@ func TestUpgradeHappensAfterMigrations(t *testing.T) { Server: &TestingKnobs{ BinaryVersionOverride: clusterversion.TestingBinaryMinSupportedVersion, }, - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ AfterEnsureMigrations: func() { // Try to encourage other goroutines to run. const N = 100 diff --git a/pkg/server/server.go b/pkg/server/server.go index 76999b55118c..e30d5231bbe4 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -1897,7 +1897,7 @@ func (s *Server) PreStart(ctx context.Context) error { s.ctSender.Run(ctx, state.nodeID) // Attempt to upgrade cluster version now that the sql server has been - // started. At this point we know that all sqlmigrations have successfully + // started. At this point we know that all startupmigrations have successfully // been run so it is safe to upgrade to the binary's current version. s.startAttemptUpgrade(ctx) diff --git a/pkg/server/server_sql.go b/pkg/server/server_sql.go index e0951d445f82..fdad8346a200 100644 --- a/pkg/server/server_sql.go +++ b/pkg/server/server_sql.go @@ -71,7 +71,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/sqlutil" "github.com/cockroachdb/cockroach/pkg/sql/stats" "github.com/cockroachdb/cockroach/pkg/sql/stmtdiagnostics" - "github.com/cockroachdb/cockroach/pkg/sqlmigrations" + "github.com/cockroachdb/cockroach/pkg/startupmigrations" "github.com/cockroachdb/cockroach/pkg/storage" "github.com/cockroachdb/cockroach/pkg/storage/cloud" "github.com/cockroachdb/cockroach/pkg/util/envutil" @@ -112,7 +112,7 @@ type SQLServer struct { // shared between the sql.Server and the statusServer. sessionRegistry *sql.SessionRegistry jobRegistry *jobs.Registry - sqlmigrationsMgr *sqlmigrations.Manager + startupMigrationsMgr *startupmigrations.Manager statsRefresher *stats.Refresher temporaryObjectCleaner *sql.TemporaryObjectCleaner internalMemMetrics sql.MemoryMetrics @@ -844,9 +844,9 @@ func (s *SQLServer) preStart( // in an acceptable form for this version of the software. // We have to do this after actually starting up the server to be able to // seamlessly use the kv client against other nodes in the cluster. - var mmKnobs sqlmigrations.MigrationManagerTestingKnobs - if migrationManagerTestingKnobs := knobs.SQLMigrationManager; migrationManagerTestingKnobs != nil { - mmKnobs = *migrationManagerTestingKnobs.(*sqlmigrations.MigrationManagerTestingKnobs) + var mmKnobs startupmigrations.MigrationManagerTestingKnobs + if migrationManagerTestingKnobs := knobs.StartupMigrationManager; migrationManagerTestingKnobs != nil { + mmKnobs = *migrationManagerTestingKnobs.(*startupmigrations.MigrationManagerTestingKnobs) } s.leaseMgr.RefreshLeases(ctx, stopper, s.execCfg.DB) @@ -869,7 +869,7 @@ func (s *SQLServer) preStart( DistSQLMode: sessiondata.DistSQLOff, }, }) - sqlmigrationsMgr := sqlmigrations.NewManager( + startupMigrationsMgr := startupmigrations.NewManager( stopper, s.execCfg.DB, s.execCfg.Codec, @@ -880,7 +880,7 @@ func (s *SQLServer) preStart( s.execCfg.Settings, s.jobRegistry, ) - s.sqlmigrationsMgr = sqlmigrationsMgr // only for testing via TestServer + s.startupMigrationsMgr = startupMigrationsMgr // only for testing via TestServer if err := s.jobRegistry.Start(ctx, stopper); err != nil { return err @@ -919,7 +919,7 @@ func (s *SQLServer) preStart( } // Run startup migrations (note: these depend on jobs subsystem running). - if err := sqlmigrationsMgr.EnsureMigrations(ctx, bootstrapVersion); err != nil { + if err := startupMigrationsMgr.EnsureMigrations(ctx, bootstrapVersion); err != nil { return errors.Wrap(err, "ensuring SQL migrations") } diff --git a/pkg/server/testserver.go b/pkg/server/testserver.go index 5325323c0d3b..4c4db300984f 100644 --- a/pkg/server/testserver.go +++ b/pkg/server/testserver.go @@ -50,7 +50,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/physicalplan" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" "github.com/cockroachdb/cockroach/pkg/sql/sessiondata" - "github.com/cockroachdb/cockroach/pkg/sqlmigrations" + "github.com/cockroachdb/cockroach/pkg/startupmigrations" "github.com/cockroachdb/cockroach/pkg/storage" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" "github.com/cockroachdb/cockroach/pkg/ts" @@ -351,10 +351,10 @@ func (ts *TestServer) JobRegistry() interface{} { return nil } -// SQLMigrationsManager returns the *sqlmigrations.Manager as an interface{}. -func (ts *TestServer) SQLMigrationsManager() interface{} { +// StartupMigrationsManager returns the *startupmigrations.Manager as an interface{}. +func (ts *TestServer) StartupMigrationsManager() interface{} { if ts != nil { - return ts.sqlServer.sqlmigrationsMgr + return ts.sqlServer.startupMigrationsMgr } return nil } @@ -628,7 +628,7 @@ func (ts *TestServer) ExpectedInitialRangeCount() (int, error) { func ExpectedInitialRangeCount( db *kv.DB, defaultZoneConfig *zonepb.ZoneConfig, defaultSystemZoneConfig *zonepb.ZoneConfig, ) (int, error) { - descriptorIDs, err := sqlmigrations.ExpectedDescriptorIDs( + descriptorIDs, err := startupmigrations.ExpectedDescriptorIDs( context.Background(), db, keys.SystemSQLCodec, defaultZoneConfig, defaultSystemZoneConfig, ) if err != nil { diff --git a/pkg/sql/BUILD.bazel b/pkg/sql/BUILD.bazel index 386f77550f32..2f9ca7570661 100644 --- a/pkg/sql/BUILD.bazel +++ b/pkg/sql/BUILD.bazel @@ -583,7 +583,7 @@ go_test( "//pkg/sql/stmtdiagnostics", "//pkg/sql/tests", "//pkg/sql/types", - "//pkg/sqlmigrations", + "//pkg/startupmigrations", "//pkg/storage", "//pkg/storage/cloudimpl", "//pkg/testutils", diff --git a/pkg/sql/catalog/lease/lease_internal_test.go b/pkg/sql/catalog/lease/lease_internal_test.go index 2c2e9a28a51a..d9b3c345c91e 100644 --- a/pkg/sql/catalog/lease/lease_internal_test.go +++ b/pkg/sql/catalog/lease/lease_internal_test.go @@ -865,7 +865,7 @@ func TestLeaseAcquireAndReleaseConcurrently(t *testing.T) { defer leaktest.AfterTest(t)() skip.WithIssue(t, 51798, "fails in the presence of migrations requiring backfill, "+ - "but cannot import sqlmigrations") + "but cannot import startupmigrations") // Result is a struct for moving results to the main result routine. type Result struct { diff --git a/pkg/sql/create_test.go b/pkg/sql/create_test.go index f9847c65a0f9..2370564e0cc4 100644 --- a/pkg/sql/create_test.go +++ b/pkg/sql/create_test.go @@ -26,7 +26,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/catalog/catalogkv" "github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb" "github.com/cockroachdb/cockroach/pkg/sql/tests" - "github.com/cockroachdb/cockroach/pkg/sqlmigrations" + "github.com/cockroachdb/cockroach/pkg/startupmigrations" "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" "github.com/cockroachdb/cockroach/pkg/testutils/sqlutils" @@ -96,7 +96,7 @@ func TestDatabaseDescriptor(t *testing.T) { if kvs, err := kvDB.Scan(ctx, start, start.PrefixEnd(), 0 /* maxRows */); err != nil { t.Fatal(err) } else { - descriptorIDs, err := sqlmigrations.ExpectedDescriptorIDs( + descriptorIDs, err := startupmigrations.ExpectedDescriptorIDs( ctx, kvDB, codec, &s.(*server.TestServer).Cfg.DefaultZoneConfig, &s.(*server.TestServer).Cfg.DefaultSystemZoneConfig, ) if err != nil { diff --git a/pkg/sql/drop_test.go b/pkg/sql/drop_test.go index d61fe89e0e18..e6fa0a105d81 100644 --- a/pkg/sql/drop_test.go +++ b/pkg/sql/drop_test.go @@ -39,7 +39,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/row" "github.com/cockroachdb/cockroach/pkg/sql/sqltestutils" "github.com/cockroachdb/cockroach/pkg/sql/tests" - "github.com/cockroachdb/cockroach/pkg/sqlmigrations" + "github.com/cockroachdb/cockroach/pkg/startupmigrations" "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/testutils/jobutils" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" @@ -852,7 +852,7 @@ func TestDropTableWhileUpgradingFormat(t *testing.T) { params, _ := tests.CreateTestServerParams() params.Knobs = base.TestingKnobs{ - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ DisableBackfillMigrations: true, }, } @@ -1147,7 +1147,7 @@ func TestDropNameReuse(t *testing.T) { params, _ := tests.CreateTestServerParams() params.Knobs = base.TestingKnobs{ - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ DisableBackfillMigrations: true, }, } diff --git a/pkg/sql/indexbackfiller_test.go b/pkg/sql/indexbackfiller_test.go index d44023dafa28..ba4c855f2af7 100644 --- a/pkg/sql/indexbackfiller_test.go +++ b/pkg/sql/indexbackfiller_test.go @@ -37,7 +37,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/sqlutil" "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/sql/types" - "github.com/cockroachdb/cockroach/pkg/sqlmigrations" + "github.com/cockroachdb/cockroach/pkg/startupmigrations" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" "github.com/cockroachdb/cockroach/pkg/testutils/sqlutils" "github.com/cockroachdb/cockroach/pkg/testutils/testcluster" @@ -81,7 +81,7 @@ func TestIndexBackfiller(t *testing.T) { }, }, // Disable backfill migrations, we still need the jobs table migration. - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ DisableBackfillMigrations: true, }, } diff --git a/pkg/sql/rowexec/BUILD.bazel b/pkg/sql/rowexec/BUILD.bazel index ae06939d1b1b..fbec9b7f5949 100644 --- a/pkg/sql/rowexec/BUILD.bazel +++ b/pkg/sql/rowexec/BUILD.bazel @@ -160,7 +160,7 @@ go_test( "//pkg/sql/sqlutil", "//pkg/sql/stats", "//pkg/sql/types", - "//pkg/sqlmigrations", + "//pkg/startupmigrations", "//pkg/storage", "//pkg/testutils", "//pkg/testutils/buildutil", diff --git a/pkg/sql/rowexec/backfiller_test.go b/pkg/sql/rowexec/backfiller_test.go index ba09e7c91513..9872cb6da4e2 100644 --- a/pkg/sql/rowexec/backfiller_test.go +++ b/pkg/sql/rowexec/backfiller_test.go @@ -26,7 +26,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/catalog/catalogkv" "github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb" "github.com/cockroachdb/cockroach/pkg/sql/rowexec" - "github.com/cockroachdb/cockroach/pkg/sqlmigrations" + "github.com/cockroachdb/cockroach/pkg/startupmigrations" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" "github.com/cockroachdb/cockroach/pkg/util/leaktest" "github.com/cockroachdb/cockroach/pkg/util/tracing" @@ -77,7 +77,7 @@ func TestWriteResumeSpan(t *testing.T) { }, }, // Disable backfill migrations, we still need the jobs table migration. - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ DisableBackfillMigrations: true, }, }, diff --git a/pkg/sql/schema_changer_test.go b/pkg/sql/schema_changer_test.go index 0a4b333a6c7a..e0f19d21dc21 100644 --- a/pkg/sql/schema_changer_test.go +++ b/pkg/sql/schema_changer_test.go @@ -45,7 +45,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/sqltestutils" "github.com/cockroachdb/cockroach/pkg/sql/stats" "github.com/cockroachdb/cockroach/pkg/sql/tests" - "github.com/cockroachdb/cockroach/pkg/sqlmigrations" + "github.com/cockroachdb/cockroach/pkg/startupmigrations" "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/testutils/jobutils" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" @@ -685,7 +685,7 @@ func TestDropWhileBackfill(t *testing.T) { }, }, // Disable backfill migrations, we still need the jobs table migration. - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ DisableBackfillMigrations: true, }, } @@ -934,7 +934,7 @@ func TestAbortSchemaChangeBackfill(t *testing.T) { BulkAdderFlushesEveryBatch: true, }, // Disable backfill migrations, we still need the jobs table migration. - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ DisableBackfillMigrations: true, }, } @@ -1271,7 +1271,7 @@ func TestSchemaChangeRetry(t *testing.T) { SerializeIndexBackfillCreationAndIngestion: make(chan struct{}, 1), }, // Disable backfill migrations, we still need the jobs table migration. - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ DisableBackfillMigrations: true, }, // Decrease the adopt loop interval so that retries happen quickly. @@ -1360,7 +1360,7 @@ func TestSchemaChangeRetryOnVersionChange(t *testing.T) { SerializeIndexBackfillCreationAndIngestion: make(chan struct{}, 1), }, // Disable backfill migrations, we still need the jobs table migration. - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ DisableBackfillMigrations: true, }, // Decrease the adopt loop interval so that retries happen quickly. @@ -1474,7 +1474,7 @@ func TestSchemaChangePurgeFailure(t *testing.T) { BulkAdderFlushesEveryBatch: true, }, // Disable backfill migrations, we still need the jobs table migration. - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ DisableBackfillMigrations: true, }, } @@ -1617,7 +1617,7 @@ func TestSchemaChangeFailureAfterCheckpointing(t *testing.T) { }, // Disable backfill migrations so it doesn't interfere with the // backfill in this test. - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ DisableBackfillMigrations: true, }, } @@ -1712,7 +1712,7 @@ func TestSchemaChangeReverseMutations(t *testing.T) { BackfillChunkSize: chunkSize, }, // Disable backfill migrations, we still need the jobs table migration. - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ DisableBackfillMigrations: true, }, } @@ -2097,7 +2097,7 @@ func TestAddColumnDuringColumnDrop(t *testing.T) { }, }, // Disable backfill migrations, we still need the jobs table migration. - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ DisableBackfillMigrations: true, }, } @@ -2184,7 +2184,7 @@ func TestSchemaUniqueColumnDropFailure(t *testing.T) { }, // Disable backfill migrations so it doesn't interfere with the // backfill in this test. - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ DisableBackfillMigrations: true, }, } @@ -3224,7 +3224,7 @@ func TestGrantRevokeWhileIndexBackfill(t *testing.T) { BulkAdderFlushesEveryBatch: true, }, // Disable backfill migrations, we still need the jobs table migration. - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ DisableBackfillMigrations: true, }, // Decrease the adopt loop interval so that retries happen quickly. @@ -3320,7 +3320,7 @@ func TestCRUDWhileColumnBackfill(t *testing.T) { }, }, // Disable backfill migrations, we still need the jobs table migration. - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ DisableBackfillMigrations: true, }, // Decrease the adopt loop interval so that retries happen quickly. @@ -5216,7 +5216,7 @@ func TestIndexBackfillValidation(t *testing.T) { BulkAdderFlushesEveryBatch: true, }, // Disable backfill migrations, we still need the jobs table migration. - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ DisableBackfillMigrations: true, }, } @@ -5287,7 +5287,7 @@ func TestInvertedIndexBackfillValidation(t *testing.T) { BulkAdderFlushesEveryBatch: true, }, // Disable backfill migrations, we still need the jobs table migration. - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ DisableBackfillMigrations: true, }, } @@ -5341,7 +5341,7 @@ func TestMultipleIndexBackfills(t *testing.T) { BackfillChunkSize: maxValue / 5, }, // Disable backfill migrations, we still need the jobs table migration. - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ DisableBackfillMigrations: true, }, } @@ -5480,7 +5480,7 @@ func TestTableValidityWhileAddingFK(t *testing.T) { }, }, // Disable backfill migrations, we still need the jobs table migration. - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ DisableBackfillMigrations: true, }, } @@ -5567,7 +5567,7 @@ func TestTableValidityWhileAddingUniqueConstraint(t *testing.T) { }, }, // Disable backfill migrations, we still need the jobs table migration. - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ DisableBackfillMigrations: true, }, } @@ -5652,7 +5652,7 @@ func TestWritesWithChecksBeforeDefaultColumnBackfill(t *testing.T) { }, }, // Disable backfill migrations, we still need the jobs table migration. - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ DisableBackfillMigrations: true, }, } @@ -5751,7 +5751,7 @@ func TestWritesWithChecksBeforeComputedColumnBackfill(t *testing.T) { }, }, // Disable backfill migrations, we still need the jobs table migration. - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ DisableBackfillMigrations: true, }, } @@ -5966,7 +5966,7 @@ func TestSchemaChangeJobRunningStatusValidation(t *testing.T) { }, }, // Disable backfill migrations, we still need the jobs table migration. - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ DisableBackfillMigrations: true, }, } @@ -6019,7 +6019,7 @@ func TestFKReferencesAddedOnlyOnceOnRetry(t *testing.T) { }, }, // Disable backfill migrations, we still need the jobs table migration. - SQLMigrationManager: &sqlmigrations.MigrationManagerTestingKnobs{ + StartupMigrationManager: &startupmigrations.MigrationManagerTestingKnobs{ DisableBackfillMigrations: true, }, // Decrease the adopt loop interval so that retries happen quickly. diff --git a/pkg/sqlmigrations/BUILD.bazel b/pkg/startupmigrations/BUILD.bazel similarity index 86% rename from pkg/sqlmigrations/BUILD.bazel rename to pkg/startupmigrations/BUILD.bazel index 8759309eaf4e..5ed3ae492629 100644 --- a/pkg/sqlmigrations/BUILD.bazel +++ b/pkg/startupmigrations/BUILD.bazel @@ -1,9 +1,9 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( - name = "sqlmigrations", + name = "startupmigrations", srcs = ["migrations.go"], - importpath = "github.com/cockroachdb/cockroach/pkg/sqlmigrations", + importpath = "github.com/cockroachdb/cockroach/pkg/startupmigrations", visibility = ["//visibility:public"], deps = [ "//pkg/base", @@ -23,7 +23,7 @@ go_library( "//pkg/sql/catalog/systemschema", "//pkg/sql/sem/tree", "//pkg/sql/sessiondata", - "//pkg/sqlmigrations/leasemanager", + "//pkg/startupmigrations/leasemanager", "//pkg/util/hlc", "//pkg/util/log", "//pkg/util/protoutil", @@ -35,13 +35,12 @@ go_library( ) go_test( - name = "sqlmigrations_test", - size = "small", + name = "startupmigrations_test", srcs = [ "main_test.go", "migrations_test.go", ], - embed = [":sqlmigrations"], + embed = [":startupmigrations"], deps = [ "//pkg/base", "//pkg/cli/exit", @@ -57,7 +56,7 @@ go_test( "//pkg/sql/catalog/descpb", "//pkg/sql/catalog/systemschema", "//pkg/sql/catalog/tabledesc", - "//pkg/sqlmigrations/leasemanager", + "//pkg/startupmigrations/leasemanager", "//pkg/testutils", "//pkg/testutils/serverutils", "//pkg/testutils/sqlutils", diff --git a/pkg/sqlmigrations/leasemanager/BUILD.bazel b/pkg/startupmigrations/leasemanager/BUILD.bazel similarity index 89% rename from pkg/sqlmigrations/leasemanager/BUILD.bazel rename to pkg/startupmigrations/leasemanager/BUILD.bazel index 2c6dcce3de10..71ee9e50c865 100644 --- a/pkg/sqlmigrations/leasemanager/BUILD.bazel +++ b/pkg/startupmigrations/leasemanager/BUILD.bazel @@ -6,7 +6,7 @@ go_library( name = "leasemanager", srcs = ["lease.go"], embed = [":leasemanager_go_proto"], - importpath = "github.com/cockroachdb/cockroach/pkg/sqlmigrations/leasemanager", + importpath = "github.com/cockroachdb/cockroach/pkg/startupmigrations/leasemanager", visibility = ["//visibility:public"], deps = [ "//pkg/kv", @@ -53,7 +53,7 @@ proto_library( go_proto_library( name = "leasemanager_go_proto", compilers = ["//pkg/cmd/protoc-gen-gogoroach:protoc-gen-gogoroach_compiler"], - importpath = "github.com/cockroachdb/cockroach/pkg/sqlmigrations/leasemanager", + importpath = "github.com/cockroachdb/cockroach/pkg/startupmigrations/leasemanager", proto = ":leasemanager_proto", visibility = ["//visibility:public"], deps = [ diff --git a/pkg/sqlmigrations/leasemanager/lease.go b/pkg/startupmigrations/leasemanager/lease.go similarity index 99% rename from pkg/sqlmigrations/leasemanager/lease.go rename to pkg/startupmigrations/leasemanager/lease.go index 9d48842439e2..07b81759cd99 100644 --- a/pkg/sqlmigrations/leasemanager/lease.go +++ b/pkg/startupmigrations/leasemanager/lease.go @@ -9,7 +9,7 @@ // licenses/APL.txt. // Package leasemanager provides functionality for acquiring and managing leases -// via the kv api for use during sqlmigrations. +// via the kv api for use during startupmigrations. package leasemanager import ( diff --git a/pkg/sqlmigrations/leasemanager/lease.pb.go b/pkg/startupmigrations/leasemanager/lease.pb.go similarity index 82% rename from pkg/sqlmigrations/leasemanager/lease.pb.go rename to pkg/startupmigrations/leasemanager/lease.pb.go index 5c1714567f60..b03a5c3c6f9d 100644 --- a/pkg/sqlmigrations/leasemanager/lease.pb.go +++ b/pkg/startupmigrations/leasemanager/lease.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: sqlmigrations/leasemanager/lease.proto +// source: startupmigrations/leasemanager/lease.proto package leasemanager @@ -36,7 +36,7 @@ func (m *LeaseVal) Reset() { *m = LeaseVal{} } func (m *LeaseVal) String() string { return proto.CompactTextString(m) } func (*LeaseVal) ProtoMessage() {} func (*LeaseVal) Descriptor() ([]byte, []int) { - return fileDescriptor_8c3535b3c1368b50, []int{0} + return fileDescriptor_d91df4d6e9c632c2, []int{0} } func (m *LeaseVal) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -66,25 +66,26 @@ func init() { } func init() { - proto.RegisterFile("sqlmigrations/leasemanager/lease.proto", fileDescriptor_8c3535b3c1368b50) + proto.RegisterFile("startupmigrations/leasemanager/lease.proto", fileDescriptor_d91df4d6e9c632c2) } -var fileDescriptor_8c3535b3c1368b50 = []byte{ - // 223 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2b, 0x2e, 0xcc, 0xc9, - 0xcd, 0x4c, 0x2f, 0x4a, 0x2c, 0xc9, 0xcc, 0xcf, 0x2b, 0xd6, 0xcf, 0x49, 0x4d, 0x2c, 0x4e, 0xcd, - 0x4d, 0xcc, 0x4b, 0x4c, 0x4f, 0x2d, 0x82, 0x70, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x04, - 0x92, 0xf3, 0x93, 0xb3, 0x8b, 0xf2, 0x13, 0x93, 0x33, 0xf4, 0x92, 0x73, 0x32, 0x53, 0xf3, 0x4a, - 0xa4, 0x24, 0x4a, 0x4b, 0x32, 0x73, 0xf4, 0x33, 0x72, 0x92, 0xf5, 0x4b, 0x32, 0x73, 0x53, 0x8b, - 0x4b, 0x12, 0x73, 0x0b, 0x20, 0x6a, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x4c, 0x7d, 0x10, - 0x0b, 0x22, 0xaa, 0x94, 0xcd, 0xc5, 0xe1, 0x03, 0x32, 0x30, 0x2c, 0x31, 0x47, 0x48, 0x8a, 0x8b, - 0x35, 0xbf, 0x3c, 0x2f, 0xb5, 0x48, 0x82, 0x51, 0x81, 0x51, 0x83, 0xd3, 0x89, 0xe5, 0xc4, 0x3d, - 0x79, 0x86, 0x20, 0x88, 0x90, 0x90, 0x33, 0x17, 0x57, 0x6a, 0x45, 0x41, 0x26, 0xc4, 0x45, 0x12, - 0x4c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0xb2, 0x7a, 0x08, 0xeb, 0x41, 0xd6, 0xea, 0x65, 0xe4, 0x24, - 0xeb, 0x85, 0xc0, 0xac, 0x85, 0xea, 0x47, 0xd2, 0xe6, 0xa4, 0x77, 0xe2, 0xa1, 0x1c, 0xc3, 0x89, - 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0xde, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, - 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xc5, 0x83, 0xec, - 0x55, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x31, 0xb7, 0xb2, 0xb1, 0x07, 0x01, 0x00, 0x00, +var fileDescriptor_d91df4d6e9c632c2 = []byte{ + // 227 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x2a, 0x2e, 0x49, 0x2c, + 0x2a, 0x29, 0x2d, 0xc8, 0xcd, 0x4c, 0x2f, 0x4a, 0x2c, 0xc9, 0xcc, 0xcf, 0x2b, 0xd6, 0xcf, 0x49, + 0x4d, 0x2c, 0x4e, 0xcd, 0x4d, 0xcc, 0x4b, 0x4c, 0x4f, 0x2d, 0x82, 0x70, 0xf4, 0x0a, 0x8a, 0xf2, + 0x4b, 0xf2, 0x85, 0x04, 0x92, 0xf3, 0x93, 0xb3, 0x8b, 0xf2, 0x13, 0x93, 0x33, 0xf4, 0x92, 0x73, + 0x32, 0x53, 0xf3, 0x4a, 0xa4, 0x24, 0x4a, 0x4b, 0x32, 0x73, 0xf4, 0x33, 0x72, 0x92, 0xf5, 0x4b, + 0x32, 0x73, 0x53, 0x8b, 0x4b, 0x12, 0x73, 0x0b, 0x20, 0x6a, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, + 0xc1, 0x4c, 0x7d, 0x10, 0x0b, 0x22, 0xaa, 0x94, 0xcd, 0xc5, 0xe1, 0x03, 0x32, 0x30, 0x2c, 0x31, + 0x47, 0x48, 0x8a, 0x8b, 0x35, 0xbf, 0x3c, 0x2f, 0xb5, 0x48, 0x82, 0x51, 0x81, 0x51, 0x83, 0xd3, + 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0x88, 0x90, 0x90, 0x33, 0x17, 0x57, 0x6a, 0x45, 0x41, + 0x26, 0xc4, 0x45, 0x12, 0x4c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0xb2, 0x7a, 0x08, 0xeb, 0x41, 0xd6, + 0xea, 0x65, 0xe4, 0x24, 0xeb, 0x85, 0xc0, 0xac, 0x85, 0xea, 0x47, 0xd2, 0xe6, 0xa4, 0x77, 0xe2, + 0xa1, 0x1c, 0xc3, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0xde, 0x78, 0x24, 0xc7, 0xf8, + 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, + 0x10, 0xc5, 0x83, 0xec, 0x55, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7e, 0x1a, 0x36, 0xc4, 0x0b, + 0x01, 0x00, 0x00, } func (m *LeaseVal) Marshal() (dAtA []byte, err error) { diff --git a/pkg/sqlmigrations/leasemanager/lease.proto b/pkg/startupmigrations/leasemanager/lease.proto similarity index 100% rename from pkg/sqlmigrations/leasemanager/lease.proto rename to pkg/startupmigrations/leasemanager/lease.proto diff --git a/pkg/sqlmigrations/leasemanager/lease_test.go b/pkg/startupmigrations/leasemanager/lease_test.go similarity index 98% rename from pkg/sqlmigrations/leasemanager/lease_test.go rename to pkg/startupmigrations/leasemanager/lease_test.go index ac35e6a97509..539e36416c64 100644 --- a/pkg/sqlmigrations/leasemanager/lease_test.go +++ b/pkg/startupmigrations/leasemanager/lease_test.go @@ -17,7 +17,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/base" "github.com/cockroachdb/cockroach/pkg/roachpb" - "github.com/cockroachdb/cockroach/pkg/sqlmigrations/leasemanager" + "github.com/cockroachdb/cockroach/pkg/startupmigrations/leasemanager" "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" "github.com/cockroachdb/cockroach/pkg/util/hlc" diff --git a/pkg/sqlmigrations/leasemanager/main_test.go b/pkg/startupmigrations/leasemanager/main_test.go similarity index 100% rename from pkg/sqlmigrations/leasemanager/main_test.go rename to pkg/startupmigrations/leasemanager/main_test.go diff --git a/pkg/sqlmigrations/main_test.go b/pkg/startupmigrations/main_test.go similarity index 96% rename from pkg/sqlmigrations/main_test.go rename to pkg/startupmigrations/main_test.go index b648088a9a8f..672941f66475 100644 --- a/pkg/sqlmigrations/main_test.go +++ b/pkg/startupmigrations/main_test.go @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -package sqlmigrations_test +package startupmigrations_test import ( "os" diff --git a/pkg/sqlmigrations/migrations.go b/pkg/startupmigrations/migrations.go similarity index 99% rename from pkg/sqlmigrations/migrations.go rename to pkg/startupmigrations/migrations.go index b3d5283a8999..3051d9478b9f 100644 --- a/pkg/sqlmigrations/migrations.go +++ b/pkg/startupmigrations/migrations.go @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -package sqlmigrations +package startupmigrations import ( "context" @@ -33,7 +33,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/catalog/systemschema" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" "github.com/cockroachdb/cockroach/pkg/sql/sessiondata" - "github.com/cockroachdb/cockroach/pkg/sqlmigrations/leasemanager" + "github.com/cockroachdb/cockroach/pkg/startupmigrations/leasemanager" "github.com/cockroachdb/cockroach/pkg/util/hlc" "github.com/cockroachdb/cockroach/pkg/util/log" "github.com/cockroachdb/cockroach/pkg/util/protoutil" diff --git a/pkg/sqlmigrations/migrations_test.go b/pkg/startupmigrations/migrations_test.go similarity index 99% rename from pkg/sqlmigrations/migrations_test.go rename to pkg/startupmigrations/migrations_test.go index a9a9e434a18a..8a520e5c070a 100644 --- a/pkg/sqlmigrations/migrations_test.go +++ b/pkg/startupmigrations/migrations_test.go @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -package sqlmigrations +package startupmigrations import ( "bytes" @@ -30,7 +30,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb" "github.com/cockroachdb/cockroach/pkg/sql/catalog/systemschema" "github.com/cockroachdb/cockroach/pkg/sql/catalog/tabledesc" - "github.com/cockroachdb/cockroach/pkg/sqlmigrations/leasemanager" + "github.com/cockroachdb/cockroach/pkg/startupmigrations/leasemanager" "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" "github.com/cockroachdb/cockroach/pkg/testutils/sqlutils" diff --git a/pkg/testutils/serverutils/test_server_shim.go b/pkg/testutils/serverutils/test_server_shim.go index 5c23bc70205f..919a09bdcce1 100644 --- a/pkg/testutils/serverutils/test_server_shim.go +++ b/pkg/testutils/serverutils/test_server_shim.go @@ -126,8 +126,8 @@ type TestServerInterface interface { // JobRegistry returns the *jobs.Registry as an interface{}. JobRegistry() interface{} - // SQLMigrationsManager returns the *sqlmigrations.Manager as an interface{}. - SQLMigrationsManager() interface{} + // StartupMigrationsManager returns the *startupmigrations.Manager as an interface{}. + StartupMigrationsManager() interface{} // NodeLiveness exposes the NodeLiveness instance used by the TestServer as an // interface{}. From d54cfc72a6d56103840bceb48ce8eb5bce360dea Mon Sep 17 00:00:00 2001 From: Andrew Werner Date: Wed, 14 Jul 2021 08:31:23 -0400 Subject: [PATCH 2/2] startupmigrations: add doc.go Release note: None --- pkg/startupmigrations/BUILD.bazel | 5 +++- pkg/startupmigrations/doc.go | 39 +++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 pkg/startupmigrations/doc.go diff --git a/pkg/startupmigrations/BUILD.bazel b/pkg/startupmigrations/BUILD.bazel index 5ed3ae492629..0f3257bf5653 100644 --- a/pkg/startupmigrations/BUILD.bazel +++ b/pkg/startupmigrations/BUILD.bazel @@ -2,7 +2,10 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "startupmigrations", - srcs = ["migrations.go"], + srcs = [ + "doc.go", + "migrations.go", + ], importpath = "github.com/cockroachdb/cockroach/pkg/startupmigrations", visibility = ["//visibility:public"], deps = [ diff --git a/pkg/startupmigrations/doc.go b/pkg/startupmigrations/doc.go new file mode 100644 index 000000000000..cde09544f68b --- /dev/null +++ b/pkg/startupmigrations/doc.go @@ -0,0 +1,39 @@ +// Copyright 2020 The Cockroach Authors. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +// Package startupmigrations provides a toolkit for running migrations upon +// startup. +// +// These migrations may be associated with a clusterversion which includes the +// relevant change in bootstrap or they may be permanent. Migrations +// associated with bootstrap state are said to be "baked in" to a certain +// version and thus can be deleted in the subsequent major release. +// +// +// Differences from migration package +// +// This package overlaps in functionality with the migration subsystem. The +// major differences are that the "long running" migrations in pkg/migration +// run only after all instances have been upgraded to run the new code as +// opposed to startup migrations which run upon the first instance to run +// the new code. Another difference is that startup migrations run before +// the instance will serve any traffic whereas the long-running migrations +// run only after startup. +// +// A key differentiator between the two migration frameworks is the +// possibility of "permanent" migrations. The long-running migrations +// are always anchored to a version and thus are always assumed to be +// "baked in" at that version. This is not the case for startupmigrations. +// An advantage to "permanent" migrations over baking some data into the +// cluster at bootstrap is that it may be easier to write given that you +// can execute sql and exercise code on a running cluster. +// +// In a future world, it may make sense to unify these two frameworks. +package startupmigrations