Skip to content

Commit

Permalink
server: filter the EOF error for normal closed at handshake (pingcap#…
Browse files Browse the repository at this point in the history
  • Loading branch information
knull-cn authored and elsa0520 committed Sep 11, 2023
1 parent f9b13b7 commit 4a4e7e9
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"context"
"crypto/tls"
"fmt"
"io"
"math/rand"
"net"
"net/http"
Expand Down Expand Up @@ -510,11 +511,17 @@ func (s *Server) onConn(conn *clientConn) {
})
terror.Log(err)
}
// Some keep alive services will send request to TiDB and disconnect immediately.
// So we only record metrics.
metrics.HandShakeErrorCounter.Inc()
terror.Log(errors.Trace(err))
terror.Log(errors.Trace(conn.Close()))
if errors.Cause(err) == io.EOF {
// `EOF` means the connection is closed normally, we do not treat it as a noticeable error and log it in 'DEBUG' level.
logutil.BgLogger().With(zap.Uint64("conn", conn.connectionID)).
Debug("EOF", zap.String("remote addr", conn.bufReadConn.RemoteAddr().String()))
} else {
metrics.HandShakeErrorCounter.Inc()
logutil.BgLogger().With(zap.Uint64("conn", conn.connectionID)).
Warn("Server.onConn handshake", zap.Error(err),
zap.String("remote addr", conn.bufReadConn.RemoteAddr().String()))
}
terror.Log(conn.Close())
return
}

Expand Down

0 comments on commit 4a4e7e9

Please sign in to comment.