cockroach: Index | Files | Directories

package sqlmigrations

import ""


Package Files



var SettingsDefaultOverrides = map[string]string{
    "diagnostics.reporting.enabled": "true",
    "cluster.secret":                "<random>",

SettingsDefaultOverrides documents the effect of several migrations that add an explicit value for a setting, effectively changing the "default value" from what was defined in code.

func ExpectedDescriptorIDs Uses

func ExpectedDescriptorIDs(
    ctx context.Context,
    db db,
    codec keys.SQLCodec,
    defaultZoneConfig *zonepb.ZoneConfig,
    defaultSystemZoneConfig *zonepb.ZoneConfig,
) (sqlbase.IDs, error)

ExpectedDescriptorIDs returns the list of all expected system descriptor IDs, including those added by completed migrations. This is needed for certain tests, which check the number of ranges and system tables at node startup.

NOTE: This value may be out-of-date if another node is actively running migrations, and so should only be used in test code where the migration lifecycle is tightly controlled.

type Manager Uses

type Manager struct {
    // contains filtered or unexported fields

Manager encapsulates the necessary functionality for handling migrations of data in the cluster.

func NewManager Uses

func NewManager(
    stopper *stop.Stopper,
    db *kv.DB,
    codec keys.SQLCodec,
    executor *sql.InternalExecutor,
    clock *hlc.Clock,
    testingKnobs MigrationManagerTestingKnobs,
    clientID string,
    settings *cluster.Settings,
    registry *jobs.Registry,
) *Manager

NewManager initializes and returns a new Manager object.

func (*Manager) EnsureMigrations Uses

func (m *Manager) EnsureMigrations(ctx context.Context, bootstrapVersion roachpb.Version) error

EnsureMigrations should be run during node startup to ensure that all required migrations have been run (and running all those that are definitely safe to run).

func (*Manager) StartSchemaChangeJobMigration Uses

func (m *Manager) StartSchemaChangeJobMigration(ctx context.Context) error

StartSchemaChangeJobMigration starts an async task to run the migration that upgrades 19.2-style jobs to the 20.1 job format, so that the jobs can be adopted by the job registry. The task first waits until the upgrade to 20.1 is finalized before running the migration. The migration is retried until it succeeds (on any node).

func (*Manager) StartSystemNamespaceMigration Uses

func (m *Manager) StartSystemNamespaceMigration(
    ctx context.Context, bootstrapVersion roachpb.Version,
) error

StartSystemNamespaceMigration starts an async task to run the migration that migrates entries from system.namespace (descriptor 2) to system.namespace2 (descriptor 30). The task first waits until the upgrade to 20.1 is finalized before running the migration. The migration is retried until it succeeds (on any node).

type MigrationManagerTestingKnobs Uses

type MigrationManagerTestingKnobs struct {
    // DisableBackfillMigrations stops applying migrations once
    // a migration with 'doesBackfill == true' is encountered.
    // TODO(mberhault): we could skip only backfill migrations and dependencies
    // if we had some concept of migration dependencies.
    DisableBackfillMigrations bool
    AfterJobMigration         func()
    // AlwaysRunJobMigration controls whether to always run the schema change job
    // migration regardless of whether it has been marked as complete.
    AlwaysRunJobMigration bool

MigrationManagerTestingKnobs contains testing knobs.

func (*MigrationManagerTestingKnobs) ModuleTestingKnobs Uses

func (*MigrationManagerTestingKnobs) ModuleTestingKnobs()

ModuleTestingKnobs is part of the base.ModuleTestingKnobs interface.


leasemanagerPackage leasemanager provides functionality for acquiring and managing leases via the kv api for use during sqlmigrations.

Package sqlmigrations imports 30 packages (graph) and is imported by 28 packages. Updated 2020-08-05. Refresh now. Tools for package owners.