Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit916d589

Browse files
committed
Make "unexpected EOF" messages DEBUG1 unless in an open transaction
"Unexpected EOF on client connection" without an open transactionis mostly noise, so turn it into DEBUG1. With an open transaction it'sstill indicating a problem, so keep those as ERROR, and change the messageto indicate that it happened in a transaction.
1 parent65b1107 commit916d589

File tree

3 files changed

+51
-12
lines changed

3 files changed

+51
-12
lines changed

‎src/backend/commands/copy.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ CopyGetData(CopyState cstate, void *databuf, int minread, int maxread)
547547
/* Only a \. terminator is legal EOF in old protocol */
548548
ereport(ERROR,
549549
(errcode(ERRCODE_CONNECTION_FAILURE),
550-
errmsg("unexpected EOF on client connection")));
550+
errmsg("unexpected EOF on client connection with an open transaction")));
551551
}
552552
bytesread=minread;
553553
break;
@@ -566,11 +566,11 @@ CopyGetData(CopyState cstate, void *databuf, int minread, int maxread)
566566
if (mtype==EOF)
567567
ereport(ERROR,
568568
(errcode(ERRCODE_CONNECTION_FAILURE),
569-
errmsg("unexpected EOF on client connection")));
569+
errmsg("unexpected EOF on client connection with an open transaction")));
570570
if (pq_getmessage(cstate->fe_msgbuf,0))
571571
ereport(ERROR,
572572
(errcode(ERRCODE_CONNECTION_FAILURE),
573-
errmsg("unexpected EOF on client connection")));
573+
errmsg("unexpected EOF on client connection with an open transaction")));
574574
switch (mtype)
575575
{
576576
case'd':/* CopyData */

‎src/backend/tcop/fastpath.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,22 @@ HandleFunctionRequest(StringInfo msgBuf)
285285
{
286286
if (GetOldFunctionMessage(msgBuf))
287287
{
288-
ereport(COMMERROR,
289-
(errcode(ERRCODE_PROTOCOL_VIOLATION),
290-
errmsg("unexpected EOF on client connection")));
288+
if (IsTransactionState())
289+
ereport(COMMERROR,
290+
(errcode(ERRCODE_CONNECTION_FAILURE),
291+
errmsg("unexpected EOF on client connection with an open transaction")));
292+
else
293+
{
294+
/*
295+
* Can't send DEBUG log messages to client at this point.
296+
* Since we're disconnecting right away, we don't need to
297+
* restore whereToSendOutput.
298+
*/
299+
whereToSendOutput=DestNone;
300+
ereport(DEBUG1,
301+
(errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST),
302+
errmsg("unexpected EOF on client connection")));
303+
}
291304
returnEOF;
292305
}
293306
}

‎src/backend/tcop/postgres.c

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,22 @@ SocketBackend(StringInfo inBuf)
343343

344344
if (qtype==EOF)/* frontend disconnected */
345345
{
346-
ereport(COMMERROR,
347-
(errcode(ERRCODE_PROTOCOL_VIOLATION),
348-
errmsg("unexpected EOF on client connection")));
346+
if (IsTransactionState())
347+
ereport(COMMERROR,
348+
(errcode(ERRCODE_CONNECTION_FAILURE),
349+
errmsg("unexpected EOF on client connection with an open transaction")));
350+
else
351+
{
352+
/*
353+
* Can't send DEBUG log messages to client at this point.
354+
* Since we're disconnecting right away, we don't need to
355+
* restore whereToSendOutput.
356+
*/
357+
whereToSendOutput=DestNone;
358+
ereport(DEBUG1,
359+
(errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST),
360+
errmsg("unexpected EOF on client connection")));
361+
}
349362
returnqtype;
350363
}
351364

@@ -366,9 +379,22 @@ SocketBackend(StringInfo inBuf)
366379
/* old style without length word; convert */
367380
if (pq_getstring(inBuf))
368381
{
369-
ereport(COMMERROR,
370-
(errcode(ERRCODE_PROTOCOL_VIOLATION),
371-
errmsg("unexpected EOF on client connection")));
382+
if (IsTransactionState())
383+
ereport(COMMERROR,
384+
(errcode(ERRCODE_CONNECTION_FAILURE),
385+
errmsg("unexpected EOF on client connection with an open transaction")));
386+
else
387+
{
388+
/*
389+
* Can't send DEBUG log messages to client at this
390+
* point.Since we're disconnecting right away, we
391+
* don't need to restore whereToSendOutput.
392+
*/
393+
whereToSendOutput=DestNone;
394+
ereport(DEBUG1,
395+
(errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST),
396+
errmsg("unexpected EOF on client connection")));
397+
}
372398
returnEOF;
373399
}
374400
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp