Skip to content

server: do not report ["encountered error"] [error=EOF] for TCPConn alive detectors #31063

@bb7133

Description

@bb7133

Enhancement

After #27962, TiDB reports the handshake error if the connection is not successfully established, as a trivial bugfix. This change is released with v5.3.0

However, we found that some load balancers use the TCP connection for alive detectives, for example, the GCP and https://asktug.com/t/topic/273508.

We can easily reproduce the following error logs from TiDB:

#!/usr/bin/env python    
    
import socket    
    
TCP_IP = '127.0.0.1'    
TCP_PORT = 4000    
BUFFER_SIZE = 1024    
MESSAGE = ""    
    
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)    
s.connect((TCP_IP, TCP_PORT))    
s.close()    

You can see the following error logs from TiDB:

[ERROR] [terror.go:307] ["encountered error"] [error=EOF] [stack="github.com/pingcap/tidb/parser/terror.Log\n\t/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/parser/terror/terror.go:307\ngithub.com/pingcap/tidb/server.(*Server).onConn\n\t/home/bb7133/Projects/gopath/src/github.com/pingcap/tidb/server/server.go:519"]

The although harmless, the logs can be confusing to the users, so I think it's better to change the log level to 'DEBUG' when the io.EOF error is encountered:

// Some keep alive services will send request to TiDB and disconnect immediately.

BTW, MySQL reports the following logs for the case above:

2021-12-27T14:03:16.793444Z 12 [Note] Got an error reading communication packets

So the failed connection logs happened for MySQL, but it is better in Note level.

Metadata

Metadata

Assignees

Labels

affects-5.3This bug affects 5.3.x versions.affects-5.4This bug affects the 5.4.x(LTS) versions.help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.needs-cherry-pick-release-5.4Should cherry pick this PR to release-5.4 branch.sig/sql-infraSIG: SQL Infratype/enhancementThe issue or PR belongs to an enhancement.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions