]> granicus.if.org Git - postgresql/commitdiff
Make "unexpected EOF" messages DEBUG1 unless in an open transaction
authorMagnus Hagander <magnus@hagander.net>
Mon, 7 May 2012 16:39:37 +0000 (18:39 +0200)
committerMagnus Hagander <magnus@hagander.net>
Mon, 7 May 2012 16:50:44 +0000 (18:50 +0200)
"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.

src/backend/commands/copy.c
src/backend/tcop/fastpath.c
src/backend/tcop/postgres.c

index 15f43fd3d6a0d938ef8e119a6e75a18b4a74f102..1d1eacd3fbd53cfa1564ee2830007cf969631e4f 100644 (file)
@@ -547,7 +547,7 @@ CopyGetData(CopyState cstate, void *databuf, int minread, int maxread)
                                /* Only a \. terminator is legal EOF in old protocol */
                                ereport(ERROR,
                                                (errcode(ERRCODE_CONNECTION_FAILURE),
-                                                errmsg("unexpected EOF on client connection")));
+                                                errmsg("unexpected EOF on client connection with an open transaction")));
                        }
                        bytesread = minread;
                        break;
@@ -566,11 +566,11 @@ CopyGetData(CopyState cstate, void *databuf, int minread, int maxread)
                                        if (mtype == EOF)
                                                ereport(ERROR,
                                                                (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))
                                                ereport(ERROR,
                                                                (errcode(ERRCODE_CONNECTION_FAILURE),
-                                                        errmsg("unexpected EOF on client connection")));
+                                                        errmsg("unexpected EOF on client connection with an open transaction")));
                                        switch (mtype)
                                        {
                                                case 'd':               /* CopyData */
index 8506b1d60f2ae05a2fa4b6bc9c2d93baea5dfe41..5c0620689e39dc3c1cbde1f618cf0ff16b31c205 100644 (file)
@@ -285,9 +285,22 @@ HandleFunctionRequest(StringInfo msgBuf)
        {
                if (GetOldFunctionMessage(msgBuf))
                {
-                       ereport(COMMERROR,
-                                       (errcode(ERRCODE_PROTOCOL_VIOLATION),
-                                        errmsg("unexpected EOF on client connection")));
+                       if (IsTransactionState())
+                               ereport(COMMERROR,
+                                               (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;
                }
        }
index 6a745997c55b71ccdf0bf93fa9d5be297988d6ac..89de154bc609829dd3ea9395575b1cd7c0679a68 100644 (file)
@@ -343,9 +343,22 @@ SocketBackend(StringInfo inBuf)
 
        if (qtype == EOF)                       /* frontend disconnected */
        {
-               ereport(COMMERROR,
-                               (errcode(ERRCODE_PROTOCOL_VIOLATION),
-                                errmsg("unexpected EOF on client connection")));
+               if (IsTransactionState())
+                       ereport(COMMERROR,
+                                       (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;
        }
 
@@ -366,9 +379,22 @@ SocketBackend(StringInfo inBuf)
                                /* old style without length word; convert */
                                if (pq_getstring(inBuf))
                                {
-                                       ereport(COMMERROR,
-                                                       (errcode(ERRCODE_PROTOCOL_VIOLATION),
-                                                        errmsg("unexpected EOF on client connection")));
+                                       if (IsTransactionState())
+                                               ereport(COMMERROR,
+                                                               (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;
                                }
                        }