Skip to content

Commit 29c625a

Browse files
committed
yugabyte#4813 [YSQL] Suppress 'incomplete startup packet' log message
Summary: Postgres logs each failed connection attempt ``` 2019-11-28 13:24:26.501 UTC [15168] LOG: incomplete startup packet ``` Different monitoring tools may scans opened ports without sending any data. Postgres log file will be flooded with above message in this case. Solution is to avoid logging in case connection has no data. Additional details can be found here: https://www.percona.com/blog/2019/12/03/postgresql-12-improvement-benign-log-entries-incomplete-startup-packet/ Vanilla postgres patch: https://git.postgresql.org/gitweb/?p=postgresql.git;a=patch;h=342cb650e Test Plan: Manual: - start YB cluster with ysql enabled - run simple port monitoring `for i in {1..100}; do nc -zv localhost 5433 ; done` - check absence of `incomplete startup packet` log `cd ~/yugabyte-data && grep -e "incomplete startup packet" -R` Reviewers: alex, neha Reviewed By: neha Subscribers: mihnea, mikhail, yql Differential Revision: https://phabricator.dev.yugabyte.com/D8722
1 parent d5f208a commit 29c625a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/postgres/src/backend/postmaster/postmaster.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,6 +1940,23 @@ ProcessStartupPacket(Port *port, bool SSLdone)
19401940
MemoryContext oldcontext;
19411941

19421942
pq_startmsgread();
1943+
1944+
/* Check we have no data at all. */
1945+
if (pq_peekbyte() == EOF)
1946+
{
1947+
/*
1948+
* If we get no data at all, don't clutter the log with a complaint;
1949+
* such cases often occur for legitimate reasons. An example is that
1950+
* we might be here after responding to NEGOTIATE_SSL_CODE, and if the
1951+
* client didn't like our response, it'll probably just drop the
1952+
* connection. Service-monitoring software also often just opens and
1953+
* closes a connection without sending anything. (So do port
1954+
* scanners, which may be less benign, but it's not really our job to
1955+
* notice those.)
1956+
*/
1957+
return STATUS_ERROR;
1958+
}
1959+
19431960
if (pq_getbytes((char *) &len, 4) == EOF)
19441961
{
19451962
/*

0 commit comments

Comments
 (0)