warning instead of error for unix socket address already in use when starting sql server (#4697)

This commit is contained in:
jennifersp
2022-11-07 19:55:18 -08:00
committed by GitHub
parent 130744b9d7
commit 9bd2a889b6
4 changed files with 20 additions and 13 deletions

View File

@@ -17,6 +17,7 @@ package sqlserver
import (
"context"
"crypto/tls"
"errors"
"fmt"
"net"
"net/http"
@@ -202,12 +203,13 @@ func Serve(
)
}
if startError != nil {
if errors.Is(startError, server.UnixSocketInUseError) {
lgr.Warn("unix socket set up failed: file already in use: ", serverConf.Socket)
} else if startError != nil {
cli.PrintErr(startError)
return
} else {
sqlserver.SetRunningServer(mySQLServer)
}
sqlserver.SetRunningServer(mySQLServer)
var metSrv *http.Server
if serverConfig.MetricsHost() != "" && serverConfig.MetricsPort() > 0 {

View File

@@ -56,7 +56,7 @@ require (
require (
github.com/aliyun/aliyun-oss-go-sdk v2.2.5+incompatible
github.com/cenkalti/backoff/v4 v4.1.3
github.com/dolthub/go-mysql-server v0.14.1-0.20221107185732-4efc4b1f7724
github.com/dolthub/go-mysql-server v0.14.1-0.20221108001905-5ceb955e33f2
github.com/google/flatbuffers v2.0.6+incompatible
github.com/kch42/buzhash v0.0.0-20160816060738-9bdec3dec7c6
github.com/mitchellh/go-ps v1.0.0

View File

@@ -178,8 +178,8 @@ github.com/dolthub/flatbuffers v1.13.0-dh.1 h1:OWJdaPep22N52O/0xsUevxJ6Qfw1M2txC
github.com/dolthub/flatbuffers v1.13.0-dh.1/go.mod h1:CorYGaDmXjHz1Z7i50PYXG1Ricn31GcA2wNOTFIQAKE=
github.com/dolthub/fslock v0.0.3 h1:iLMpUIvJKMKm92+N1fmHVdxJP5NdyDK5bK7z7Ba2s2U=
github.com/dolthub/fslock v0.0.3/go.mod h1:QWql+P17oAAMLnL4HGB5tiovtDuAjdDTPbuqx7bYfa0=
github.com/dolthub/go-mysql-server v0.14.1-0.20221107185732-4efc4b1f7724 h1:Ly7H36BgYCv+vt//Lkp/AcG/PktIT3R+QZTnDqJR1pA=
github.com/dolthub/go-mysql-server v0.14.1-0.20221107185732-4efc4b1f7724/go.mod h1:KtpU4Sf7J+SIat/nxoA733QTn3tdL34NtoGxEBFcTsA=
github.com/dolthub/go-mysql-server v0.14.1-0.20221108001905-5ceb955e33f2 h1:RPJfRjz+AfWy1m9o+mNUw6CMLfkSBHqdlGHiCMC7fig=
github.com/dolthub/go-mysql-server v0.14.1-0.20221108001905-5ceb955e33f2/go.mod h1:KtpU4Sf7J+SIat/nxoA733QTn3tdL34NtoGxEBFcTsA=
github.com/dolthub/ishell v0.0.0-20220112232610-14e753f0f371 h1:oyPHJlzumKta1vnOQqUnfdz+pk3EmnHS3Nd0cCT0I2g=
github.com/dolthub/ishell v0.0.0-20220112232610-14e753f0f371/go.mod h1:dhGBqcCEfK5kuFmeO5+WOx3hqc1k3M29c1oS/R7N4ms=
github.com/dolthub/jsonpath v0.0.0-20210609232853-d49537a30474 h1:xTrR+l5l+1Lfq0NvhiEsctylXinUMFhhsqaEcl414p8=

View File

@@ -1492,7 +1492,7 @@ databases:
rm /tmp/mysql.sock
}
@test "sql-server: server fails to start up if there is already a file in the socket file path" {
@test "sql-server: the second server starts without unix socket set up if there is already a file in the socket file path" {
skiponwindows "unix socket is not available on Windows"
cd repo2
touch mysql.sock
@@ -1500,15 +1500,20 @@ databases:
run pwd
REPO_NAME=$output
PORT=$( definePORT )
dolt sql-server --port=$PORT --socket="$REPO_NAME/mysql.sock" --user dolt > log.txt 2>&1 &
SERVER_PID=$!
run wait_for_connection $PORT 5000
[ "$status" -eq 1 ]
secondPORT=$( definePORT )
dolt sql-server --port=$secondPORT --socket="$REPO_NAME/mysql.sock" --user dolt > log.txt 2>&1 &
SECOND_SERVER_PID=$!
run wait_for_connection $secondPORT 5000
[ "$status" -eq 0 ]
run grep 'address already in use' log.txt
run grep 'unix socket set up failed: file already in use:' log.txt
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 1 ]
# killing the second server should not affect the socket file.
kill $SECOND_SERVER_PID
[ -f mysql.sock ]
}
@test "sql-server: start server with yaml config with socket file path defined" {