From c61fbec763c4959fa676338849f6736a228f6b95 Mon Sep 17 00:00:00 2001 From: Simon Mudd Date: Mon, 18 Sep 2017 16:50:48 +0200 Subject: [PATCH] Ensure vttablet does not crash if not given all parameters it expects Specifically I managed to crash it when mycnf was empty and it tried to reference the socket name to talk to mysqld on. Even if that setting is not present the binary should not fail and given it's possible via the appropraite dbconfig-XXXX settings to configure access to a remote mysqld then the requirement for the socket should not be there. If you see a better fix then feel free to implement this. --- go/cmd/vttablet/vttablet.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/go/cmd/vttablet/vttablet.go b/go/cmd/vttablet/vttablet.go index e143f5e2017..510b2b9d4e4 100644 --- a/go/cmd/vttablet/vttablet.go +++ b/go/cmd/vttablet/vttablet.go @@ -84,7 +84,11 @@ func main() { log.Exitf("mycnf read failed: %v", err) } - dbcfgs, err := dbconfigs.Init(mycnf.SocketFile, dbconfigFlags) + var socketFile string + if mycnf != nil { + socketFile = mycnf.SocketFile + } + dbcfgs, err := dbconfigs.Init(socketFile, dbconfigFlags) if err != nil { log.Warning(err) }