Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: filter the EOF error for normal closed at handshake #31081

Merged
merged 7 commits into from
Dec 31, 2021
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
knull-cn marked this conversation as resolved.
Show resolved Hide resolved
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())
jackysp marked this conversation as resolved.
Show resolved Hide resolved
return
}

Expand Down