supporting --panic-flag-file
; when it exists - app panics and exits without cleanup
This commit is contained in:
parent
2b0f7af84b
commit
94f311ec7b
2
build.sh
2
build.sh
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
RELEASE_VERSION="0.9.3"
|
RELEASE_VERSION="0.9.4"
|
||||||
|
|
||||||
buildpath=/tmp/gh-ost
|
buildpath=/tmp/gh-ost
|
||||||
target=gh-ost
|
target=gh-ost
|
||||||
|
@ -70,6 +70,7 @@ type MigrationContext struct {
|
|||||||
maxLoadMutex *sync.Mutex
|
maxLoadMutex *sync.Mutex
|
||||||
PostponeCutOverFlagFile string
|
PostponeCutOverFlagFile string
|
||||||
SwapTablesTimeoutSeconds int64
|
SwapTablesTimeoutSeconds int64
|
||||||
|
PanicFlagFile string
|
||||||
|
|
||||||
ServeSocketFile string
|
ServeSocketFile string
|
||||||
ServeTCPPort int64
|
ServeTCPPort int64
|
||||||
|
@ -76,6 +76,7 @@ func main() {
|
|||||||
flag.StringVar(&migrationContext.ThrottleFlagFile, "throttle-flag-file", "", "operation pauses when this file exists; hint: use a file that is specific to the table being altered")
|
flag.StringVar(&migrationContext.ThrottleFlagFile, "throttle-flag-file", "", "operation pauses when this file exists; hint: use a file that is specific to the table being altered")
|
||||||
flag.StringVar(&migrationContext.ThrottleAdditionalFlagFile, "throttle-additional-flag-file", "/tmp/gh-ost.throttle", "operation pauses when this file exists; hint: keep default, use for throttling multiple gh-ost operations")
|
flag.StringVar(&migrationContext.ThrottleAdditionalFlagFile, "throttle-additional-flag-file", "/tmp/gh-ost.throttle", "operation pauses when this file exists; hint: keep default, use for throttling multiple gh-ost operations")
|
||||||
flag.StringVar(&migrationContext.PostponeCutOverFlagFile, "postpone-cut-over-flag-file", "", "while this file exists, migration will postpone the final stage of swapping tables, and will keep on syncing the ghost table. Cut-over/swapping would be ready to perform the moment the file is deleted.")
|
flag.StringVar(&migrationContext.PostponeCutOverFlagFile, "postpone-cut-over-flag-file", "", "while this file exists, migration will postpone the final stage of swapping tables, and will keep on syncing the ghost table. Cut-over/swapping would be ready to perform the moment the file is deleted.")
|
||||||
|
flag.StringVar(&migrationContext.PanicFlagFile, "panic-flag-file", "", "when this file is created, gh-ost will immediately terminate, without cleanup")
|
||||||
|
|
||||||
flag.StringVar(&migrationContext.ServeSocketFile, "serve-socket-file", "", "Unix socket file to serve on. Default: auto-determined and advertised upon startup")
|
flag.StringVar(&migrationContext.ServeSocketFile, "serve-socket-file", "", "Unix socket file to serve on. Default: auto-determined and advertised upon startup")
|
||||||
flag.Int64Var(&migrationContext.ServeTCPPort, "serve-tcp-port", 0, "TCP port to serve on. Default: disabled")
|
flag.Int64Var(&migrationContext.ServeTCPPort, "serve-tcp-port", 0, "TCP port to serve on. Default: disabled")
|
||||||
|
@ -99,6 +99,15 @@ func (this *Migrator) acceptSignals() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *Migrator) shouldThrottle() (result bool, reason string) {
|
func (this *Migrator) shouldThrottle() (result bool, reason string) {
|
||||||
|
|
||||||
|
// Regardless of throttle, we take opportunity to check for panic-abort
|
||||||
|
if this.migrationContext.PanicFlagFile != "" {
|
||||||
|
if base.FileExists(this.migrationContext.PanicFlagFile) {
|
||||||
|
this.panicAbort <- fmt.Errorf("Found panic-file %s. Aborting without cleanup", this.migrationContext.PanicFlagFile)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Back to throttle considerations
|
||||||
|
|
||||||
// User-based throttle
|
// User-based throttle
|
||||||
if atomic.LoadInt64(&this.migrationContext.ThrottleCommandedByUser) > 0 {
|
if atomic.LoadInt64(&this.migrationContext.ThrottleCommandedByUser) > 0 {
|
||||||
return true, "commanded by user"
|
return true, "commanded by user"
|
||||||
@ -295,6 +304,7 @@ func (this *Migrator) listenOnPanicAbort() {
|
|||||||
err := <-this.panicAbort
|
err := <-this.panicAbort
|
||||||
log.Fatale(err)
|
log.Fatale(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Migrator) validateStatement() (err error) {
|
func (this *Migrator) validateStatement() (err error) {
|
||||||
if this.parser.HasNonTrivialRenames() && !this.migrationContext.SkipRenamedColumns {
|
if this.parser.HasNonTrivialRenames() && !this.migrationContext.SkipRenamedColumns {
|
||||||
this.migrationContext.ColumnRenameMap = this.parser.GetNonTrivialRenames()
|
this.migrationContext.ColumnRenameMap = this.parser.GetNonTrivialRenames()
|
||||||
@ -606,12 +616,14 @@ func (this *Migrator) onServerCommand(command string, writer *bufio.Writer) (err
|
|||||||
if len(tokens) > 1 {
|
if len(tokens) > 1 {
|
||||||
arg = strings.TrimSpace(tokens[1])
|
arg = strings.TrimSpace(tokens[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
switch command {
|
switch command {
|
||||||
case "help":
|
case "help":
|
||||||
{
|
{
|
||||||
fmt.Fprintln(writer, `available commands:
|
fmt.Fprintln(writer, `available commands:
|
||||||
status # Print a status message
|
status # Print a status message
|
||||||
chunk-size=<newsize> # Set a new chunk-size
|
chunk-size=<newsize> # Set a new chunk-size
|
||||||
|
max-load=<maxload> # Set a new set of max-load thresholds
|
||||||
throttle # Force throttling
|
throttle # Force throttling
|
||||||
no-throttle # End forced throttling (other throttling may still apply)
|
no-throttle # End forced throttling (other throttling may still apply)
|
||||||
help # This message
|
help # This message
|
||||||
@ -740,6 +752,16 @@ func (this *Migrator) printMigrationStatusHint(writers ...io.Writer) {
|
|||||||
this.migrationContext.ThrottleAdditionalFlagFile,
|
this.migrationContext.ThrottleAdditionalFlagFile,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
if this.migrationContext.PostponeCutOverFlagFile != "" {
|
||||||
|
fmt.Fprintln(w, fmt.Sprintf("# Postpone cut-over flag file: %+v",
|
||||||
|
this.migrationContext.PostponeCutOverFlagFile,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
if this.migrationContext.PanicFlagFile != "" {
|
||||||
|
fmt.Fprintln(w, fmt.Sprintf("# Panic flag file: %+v",
|
||||||
|
this.migrationContext.PanicFlagFile,
|
||||||
|
))
|
||||||
|
}
|
||||||
fmt.Fprintln(w, fmt.Sprintf("# Serving on unix socket: %+v",
|
fmt.Fprintln(w, fmt.Sprintf("# Serving on unix socket: %+v",
|
||||||
this.migrationContext.ServeSocketFile,
|
this.migrationContext.ServeSocketFile,
|
||||||
))
|
))
|
||||||
|
Loading…
Reference in New Issue
Block a user