案例说明:
在KingbaseES V8R3数据库的sys_log日志中,出现以下故障信息“不完整的启动包(incomplete startup packet)”日志信息。本案例复现此日志信息发生的原因。
如下图所示,日志信息:
适用版本: KingbaseES V8R3
1、查询PostgreSQL官方文档
In PostgreSQL, for each client connection request to Postmaster (listens on port 5432 by default), a backend process will be created.It then processes the startup packet from the client. Refer to src/backend/postmaster/postmaster.c for the source code.
Each client connection request is expected to send a startup message to the PostgreSQL server, and this information in the startup packet is used for setting up the backend process. But there are many more things happening when we deploy PostgreSQL in a datacenter. There could be different monitoring solutions, security scanners, port scanners, HA Solutions, etc hitting on PostgreSQL Port 5432.
PostgreSQL starts processing these incoming connections for establishing a client-server communication channel. But many of these tools may have a different intention and won’t be participating in a good client-server protocol.
Historically, PostgreSQL generates a log entry for each of these suspected/bad hits. This can result in log files growing to a huge size and can cause unwanted log-related IO.
收到到客户端连接请求,等待client startup package,但是不同的客户端连接目的不同(有的只是看看远端数据库端口是否联通),不会发送startup报文给数据库,这种情况下,PG12以前的版本,数据库就会打印incomplete startup packet错误日志。
PostgreSQL 12 不再打印某些监控探测数据库是否存活导致的日志。(incomplete startup packet)
从以上文档来看,“incomplete startup packet”日志信息是和客户端访问数据库服务器的访问连接有关系。
2、复现日志信息
通过系统工具nc执行对数据库端口(54321)的TCP扫描:
#测试脚本:
[kingbase@node101 ~]$ cat nc.sh
#!/bin/bash
for i in {1..100}; do
nc -zv localhost 54321 ;
done
执行脚本:
如下所示,client没有向Server端发送数据包。
查看数据库sys_log日志:
---如上图所示,在sys_log日志中出现了“incomplete startup packet”的日志信息,client向Server端(数据库服务器)发送连接的请求,Server端收到client的request,但是client没有发送startup packet包,在Server端的日志信息就会显示“incomplete startup packet”。
如下图所示libpq的通讯流程图:
3、总结
1、对于“incomplete startup packet”日志信息,和数据库启动无关,只是与client和server的通讯有关。
2、此日志信息在Kingbase V8R3版本数据库中会出现,在KingbaseES V8R6数据库中一般已经不再记录此类型日志。