Skip to content

Commit

Permalink
mysqlctl: Error out on stale socket (#14650)
Browse files Browse the repository at this point in the history
Signed-off-by: Dirkjan Bussink <[email protected]>
  • Loading branch information
dbussink authored Nov 30, 2023
1 parent 5655236 commit fabc23c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions go/vt/mysqlctl/mysqld.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,13 +461,13 @@ func cleanupLockfile(socket string, ts string) error {
if err == nil {
// If the process still exists, it's not safe to
// remove the lock file, so we have to keep it around.
log.Warningf("%v: not removing socket lock file: %v", ts, lockPath)
return nil
log.Errorf("%v: not removing socket lock file: %v with pid %v", ts, lockPath, p)
return fmt.Errorf("process %v is still running", p)
}
if !errors.Is(err, os.ErrProcessDone) {
// Any errors except for the process being done
// is unexpected here.
log.Errorf("%v: error checking process: %v", ts, err)
log.Errorf("%v: error checking process %v: %v", ts, p, err)
return err
}

Expand Down
2 changes: 1 addition & 1 deletion go/vt/mysqlctl/mysqld_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,6 @@ func TestCleanupLockfile(t *testing.T) {

// If the lockfile exists, and the process is found, we don't clean it up.
os.WriteFile("mysql.sock.lock", []byte(strconv.Itoa(os.Getpid())), 0o600)
assert.NoError(t, cleanupLockfile("mysql.sock", ts))
assert.Error(t, cleanupLockfile("mysql.sock", ts))
assert.FileExists(t, "mysql.sock.lock")
}

0 comments on commit fabc23c

Please sign in to comment.