initial support for --resurrect flag
This commit is contained in:
parent
4c6f42f2f1
commit
c72851e1f6
@ -82,6 +82,7 @@ type MigrationContext struct {
|
|||||||
SkipRenamedColumns bool
|
SkipRenamedColumns bool
|
||||||
IsTungsten bool
|
IsTungsten bool
|
||||||
DiscardForeignKeys bool
|
DiscardForeignKeys bool
|
||||||
|
Resurrect bool
|
||||||
|
|
||||||
config ContextConfig
|
config ContextConfig
|
||||||
configMutex *sync.Mutex
|
configMutex *sync.Mutex
|
||||||
@ -161,6 +162,7 @@ type MigrationContext struct {
|
|||||||
UserCommandedUnpostponeFlag int64
|
UserCommandedUnpostponeFlag int64
|
||||||
CutOverCompleteFlag int64
|
CutOverCompleteFlag int64
|
||||||
InCutOverCriticalSectionFlag int64
|
InCutOverCriticalSectionFlag int64
|
||||||
|
IsResurrected bool
|
||||||
|
|
||||||
OriginalTableColumnsOnApplier *sql.ColumnList
|
OriginalTableColumnsOnApplier *sql.ColumnList
|
||||||
OriginalTableColumns *sql.ColumnList
|
OriginalTableColumns *sql.ColumnList
|
||||||
|
@ -58,6 +58,7 @@ func main() {
|
|||||||
flag.StringVar(&migrationContext.DatabaseName, "database", "", "database name (mandatory)")
|
flag.StringVar(&migrationContext.DatabaseName, "database", "", "database name (mandatory)")
|
||||||
flag.StringVar(&migrationContext.OriginalTableName, "table", "", "table name (mandatory)")
|
flag.StringVar(&migrationContext.OriginalTableName, "table", "", "table name (mandatory)")
|
||||||
flag.StringVar(&migrationContext.AlterStatement, "alter", "", "alter statement (mandatory)")
|
flag.StringVar(&migrationContext.AlterStatement, "alter", "", "alter statement (mandatory)")
|
||||||
|
|
||||||
flag.BoolVar(&migrationContext.CountTableRows, "exact-rowcount", false, "actually count table rows as opposed to estimate them (results in more accurate progress estimation)")
|
flag.BoolVar(&migrationContext.CountTableRows, "exact-rowcount", false, "actually count table rows as opposed to estimate them (results in more accurate progress estimation)")
|
||||||
flag.BoolVar(&migrationContext.ConcurrentCountTableRows, "concurrent-rowcount", true, "(with --exact-rowcount), when true (default): count rows after row-copy begins, concurrently, and adjust row estimate later on; when false: first count rows, then start row copy")
|
flag.BoolVar(&migrationContext.ConcurrentCountTableRows, "concurrent-rowcount", true, "(with --exact-rowcount), when true (default): count rows after row-copy begins, concurrently, and adjust row estimate later on; when false: first count rows, then start row copy")
|
||||||
flag.BoolVar(&migrationContext.AllowedRunningOnMaster, "allow-on-master", false, "allow this migration to run directly on master. Preferably it would run on a replica")
|
flag.BoolVar(&migrationContext.AllowedRunningOnMaster, "allow-on-master", false, "allow this migration to run directly on master. Preferably it would run on a replica")
|
||||||
@ -68,6 +69,7 @@ func main() {
|
|||||||
flag.BoolVar(&migrationContext.IsTungsten, "tungsten", false, "explicitly let gh-ost know that you are running on a tungsten-replication based topology (you are likely to also provide --assume-master-host)")
|
flag.BoolVar(&migrationContext.IsTungsten, "tungsten", false, "explicitly let gh-ost know that you are running on a tungsten-replication based topology (you are likely to also provide --assume-master-host)")
|
||||||
flag.BoolVar(&migrationContext.DiscardForeignKeys, "discard-foreign-keys", false, "DANGER! This flag will migrate a table that has foreign keys and will NOT create foreign keys on the ghost table, thus your altered table will have NO foreign keys. This is useful for intentional dropping of foreign keys")
|
flag.BoolVar(&migrationContext.DiscardForeignKeys, "discard-foreign-keys", false, "DANGER! This flag will migrate a table that has foreign keys and will NOT create foreign keys on the ghost table, thus your altered table will have NO foreign keys. This is useful for intentional dropping of foreign keys")
|
||||||
flag.BoolVar(&migrationContext.SkipForeignKeyChecks, "skip-foreign-key-checks", false, "set to 'true' when you know for certain there are no foreign keys on your table, and wish to skip the time it takes for gh-ost to verify that")
|
flag.BoolVar(&migrationContext.SkipForeignKeyChecks, "skip-foreign-key-checks", false, "set to 'true' when you know for certain there are no foreign keys on your table, and wish to skip the time it takes for gh-ost to verify that")
|
||||||
|
flag.BoolVar(&migrationContext.Resurrect, "resurrect", false, "resume previously crashed migration")
|
||||||
|
|
||||||
executeFlag := flag.Bool("execute", false, "actually execute the alter & migrate the table. Default is noop: do some tests and exit")
|
executeFlag := flag.Bool("execute", false, "actually execute the alter & migrate the table. Default is noop: do some tests and exit")
|
||||||
flag.BoolVar(&migrationContext.TestOnReplica, "test-on-replica", false, "Have the migration run on a replica, not on the master. At the end of migration replication is stopped, and tables are swapped and immediately swap-revert. Replication remains stopped and you can compare the two tables for building trust")
|
flag.BoolVar(&migrationContext.TestOnReplica, "test-on-replica", false, "Have the migration run on a replica, not on the master. At the end of migration replication is stopped, and tables are swapped and immediately swap-revert. Replication remains stopped and you can compare the two tables for building trust")
|
||||||
@ -178,6 +180,12 @@ func main() {
|
|||||||
if *cliMasterPassword != "" && migrationContext.AssumeMasterHostname == "" {
|
if *cliMasterPassword != "" && migrationContext.AssumeMasterHostname == "" {
|
||||||
log.Fatalf("--master-password requires --assume-master-host")
|
log.Fatalf("--master-password requires --assume-master-host")
|
||||||
}
|
}
|
||||||
|
if migrationContext.InitiallyDropGhostTable && migrationContext.Resurrect {
|
||||||
|
log.Fatalf("--initially-drop-ghost-table and --resurrect are mutually exclusive")
|
||||||
|
}
|
||||||
|
if migrationContext.InitiallyDropOldTable && migrationContext.Resurrect {
|
||||||
|
log.Fatalf("--initially-drop-old-table and --resurrect are mutually exclusive")
|
||||||
|
}
|
||||||
|
|
||||||
switch *cutOver {
|
switch *cutOver {
|
||||||
case "atomic", "default", "":
|
case "atomic", "default", "":
|
||||||
|
@ -1043,11 +1043,14 @@ func (this *Migrator) executeWriteFuncs() error {
|
|||||||
case <-contextDumpTick:
|
case <-contextDumpTick:
|
||||||
{
|
{
|
||||||
this.migrationContext.SetStreamerBinlogCoordinates(this.eventsStreamer.GetCurrentBinlogCoordinates())
|
this.migrationContext.SetStreamerBinlogCoordinates(this.eventsStreamer.GetCurrentBinlogCoordinates())
|
||||||
|
if !this.migrationContext.Resurrect || this.migrationContext.IsResurrected {
|
||||||
if jsonString, err := this.migrationContext.ToJSON(); err == nil {
|
if jsonString, err := this.migrationContext.ToJSON(); err == nil {
|
||||||
this.applier.WriteChangelog("context", jsonString)
|
this.applier.WriteChangelog("context", jsonString)
|
||||||
log.Debugf("Context dumped")
|
log.Debugf("Context dumped")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// If we're about to resurrect (resurrect requested) but haven't done so yet, do not wrtie resurrect info.
|
||||||
|
}
|
||||||
case applyEventFunc := <-this.applyEventsQueue:
|
case applyEventFunc := <-this.applyEventsQueue:
|
||||||
{
|
{
|
||||||
if err := this.retryOperation(applyEventFunc); err != nil {
|
if err := this.retryOperation(applyEventFunc); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user