From 74804559c8d7be6503a0c9647b2acede952c199f Mon Sep 17 00:00:00 2001 From: Shlomi Noach Date: Fri, 22 Jul 2016 17:34:18 +0200 Subject: [PATCH] supporting --initially-drop-socket-file - by default gh-ost will not delete an existing socket file and thus, will fail running if socket file exists. This is the desired behavior. - The flag --initially-drop-socket-file indicates we take responsibility and wish gh-ost to delete this file on startup --- build.sh | 2 +- go/base/context.go | 1 + go/cmd/gh-ost/main.go | 1 + go/logic/server.go | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index b834412..5303130 100644 --- a/build.sh +++ b/build.sh @@ -1,7 +1,7 @@ #!/bin/bash # # -RELEASE_VERSION="1.0.2" +RELEASE_VERSION="1.0.3" buildpath=/tmp/gh-ost target=gh-ost diff --git a/go/base/context.go b/go/base/context.go index 00a5ad7..ebfcd85 100644 --- a/go/base/context.go +++ b/go/base/context.go @@ -72,6 +72,7 @@ type MigrationContext struct { CutOverLockTimeoutSeconds int64 PanicFlagFile string + DropServeSocket bool ServeSocketFile string ServeTCPPort int64 diff --git a/go/cmd/gh-ost/main.go b/go/cmd/gh-ost/main.go index ac4796b..b25e7c2 100644 --- a/go/cmd/gh-ost/main.go +++ b/go/cmd/gh-ost/main.go @@ -83,6 +83,7 @@ func main() { 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.BoolVar(&migrationContext.DropServeSocket, "initially-drop-socket-file", false, "Should gh-ost forcibly delete an existing socket file. Be careful: this might drop the socket file of a running migration!") 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") diff --git a/go/logic/server.go b/go/logic/server.go index 6d67859..f216af6 100644 --- a/go/logic/server.go +++ b/go/logic/server.go @@ -36,7 +36,7 @@ func (this *Server) BindSocketFile() (err error) { if this.migrationContext.ServeSocketFile == "" { return nil } - if base.FileExists(this.migrationContext.ServeSocketFile) { + if this.migrationContext.DropServeSocket && base.FileExists(this.migrationContext.ServeSocketFile) { os.Remove(this.migrationContext.ServeSocketFile) } this.unixListener, err = net.Listen("unix", this.migrationContext.ServeSocketFile)