Commit 916d589a authored by Magnus Hagander's avatar Magnus Hagander

Make "unexpected EOF" messages DEBUG1 unless in an open transaction

"Unexpected EOF on client connection" without an open transaction
is mostly noise, so turn it into DEBUG1. With an open transaction it's
still indicating a problem, so keep those as ERROR, and change the message
to indicate that it happened in a transaction.
parent 65b11070
...@@ -547,7 +547,7 @@ CopyGetData(CopyState cstate, void *databuf, int minread, int maxread) ...@@ -547,7 +547,7 @@ CopyGetData(CopyState cstate, void *databuf, int minread, int maxread)
/* Only a \. terminator is legal EOF in old protocol */ /* Only a \. terminator is legal EOF in old protocol */
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_CONNECTION_FAILURE), (errcode(ERRCODE_CONNECTION_FAILURE),
errmsg("unexpected EOF on client connection"))); errmsg("unexpected EOF on client connection with an open transaction")));
} }
bytesread = minread; bytesread = minread;
break; break;
...@@ -566,11 +566,11 @@ CopyGetData(CopyState cstate, void *databuf, int minread, int maxread) ...@@ -566,11 +566,11 @@ CopyGetData(CopyState cstate, void *databuf, int minread, int maxread)
if (mtype == EOF) if (mtype == EOF)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_CONNECTION_FAILURE), (errcode(ERRCODE_CONNECTION_FAILURE),
errmsg("unexpected EOF on client connection"))); errmsg("unexpected EOF on client connection with an open transaction")));
if (pq_getmessage(cstate->fe_msgbuf, 0)) if (pq_getmessage(cstate->fe_msgbuf, 0))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_CONNECTION_FAILURE), (errcode(ERRCODE_CONNECTION_FAILURE),
errmsg("unexpected EOF on client connection"))); errmsg("unexpected EOF on client connection with an open transaction")));
switch (mtype) switch (mtype)
{ {
case 'd': /* CopyData */ case 'd': /* CopyData */
......
...@@ -285,9 +285,22 @@ HandleFunctionRequest(StringInfo msgBuf) ...@@ -285,9 +285,22 @@ HandleFunctionRequest(StringInfo msgBuf)
{ {
if (GetOldFunctionMessage(msgBuf)) if (GetOldFunctionMessage(msgBuf))
{ {
ereport(COMMERROR, if (IsTransactionState())
(errcode(ERRCODE_PROTOCOL_VIOLATION), ereport(COMMERROR,
errmsg("unexpected EOF on client connection"))); (errcode(ERRCODE_CONNECTION_FAILURE),
errmsg("unexpected EOF on client connection with an open transaction")));
else
{
/*
* Can't send DEBUG log messages to client at this point.
* Since we're disconnecting right away, we don't need to
* restore whereToSendOutput.
*/
whereToSendOutput = DestNone;
ereport(DEBUG1,
(errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST),
errmsg("unexpected EOF on client connection")));
}
return EOF; return EOF;
} }
} }
......
...@@ -343,9 +343,22 @@ SocketBackend(StringInfo inBuf) ...@@ -343,9 +343,22 @@ SocketBackend(StringInfo inBuf)
if (qtype == EOF) /* frontend disconnected */ if (qtype == EOF) /* frontend disconnected */
{ {
ereport(COMMERROR, if (IsTransactionState())
(errcode(ERRCODE_PROTOCOL_VIOLATION), ereport(COMMERROR,
errmsg("unexpected EOF on client connection"))); (errcode(ERRCODE_CONNECTION_FAILURE),
errmsg("unexpected EOF on client connection with an open transaction")));
else
{
/*
* Can't send DEBUG log messages to client at this point.
* Since we're disconnecting right away, we don't need to
* restore whereToSendOutput.
*/
whereToSendOutput = DestNone;
ereport(DEBUG1,
(errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST),
errmsg("unexpected EOF on client connection")));
}
return qtype; return qtype;
} }
...@@ -366,9 +379,22 @@ SocketBackend(StringInfo inBuf) ...@@ -366,9 +379,22 @@ SocketBackend(StringInfo inBuf)
/* old style without length word; convert */ /* old style without length word; convert */
if (pq_getstring(inBuf)) if (pq_getstring(inBuf))
{ {
ereport(COMMERROR, if (IsTransactionState())
(errcode(ERRCODE_PROTOCOL_VIOLATION), ereport(COMMERROR,
errmsg("unexpected EOF on client connection"))); (errcode(ERRCODE_CONNECTION_FAILURE),
errmsg("unexpected EOF on client connection with an open transaction")));
else
{
/*
* Can't send DEBUG log messages to client at this
* point.Since we're disconnecting right away, we
* don't need to restore whereToSendOutput.
*/
whereToSendOutput = DestNone;
ereport(DEBUG1,
(errcode(ERRCODE_CONNECTION_DOES_NOT_EXIST),
errmsg("unexpected EOF on client connection")));
}
return EOF; return EOF;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment