Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UCXjY-0002iL-Ee for pgsql-bugs@arkaria.postgresql.org; Mon, 04 Mar 2013 15:55:24 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UCXjX-0002V3-Oo for pgsql-bugs@arkaria.postgresql.org; Mon, 04 Mar 2013 15:55:23 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UCTUG-0007pC-6g for pgsql-bugs@postgresql.org; Mon, 04 Mar 2013 11:23:20 +0000 Received: from mahout.postgresql.org ([2001:4800:7903:4::123]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UCTUE-0004al-Ng for pgsql-bugs@postgresql.org; Mon, 04 Mar 2013 11:23:19 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UCTUD-0002u3-JK for pgsql-bugs@postgresql.org; Mon, 04 Mar 2013 11:23:18 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1UCTUD-0000L3-C1 for pgsql-bugs@postgresql.org; Mon, 04 Mar 2013 11:23:17 +0000 Date: Mon, 04 Mar 2013 11:23:17 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #7914: pg_dump aborts occasionally To: pgsql-bugs@postgresql.org From: s-morita@beingcorp.co.jp X-Pg-Spam-Score: -2.5 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 7914 Logged by: Shin-ichi MORITA Email address: s-morita@beingcorp.co.jp PostgreSQL version: 8.4.16 Operating system: Windows Server 2012 Description:=20=20=20=20=20=20=20=20 Hi great team, I encountered a strange error during pg_dump as below: ---- pg_dump: Dumping the contents of table "t_file_data" failed: PQgetCopyData() failed. pg_dump: Error message from server: lost synchronization with server: got message type "d", length 21861 pg_dump: The command was: COPY public.t_file_data (c_file_info_id, c_page_no, c_data) TO stdout; pg_dump: *** aborted because of error ---- It seems that large tables tend to cause this to happen. In order to figure out what happens, I looked into src/interfaces/libpq/fe-protocol3.c. Then I have found that it is possible that PGconn::inBuffer is unintentionally enlarging during execution of getCopyDataMessage(). Please look at fe-protocol3.c:1432: 1425: avail =3D conn->inEnd - conn->inCursor; 1426: if (avail < msgLength - 4) 1427: { : 1432: if (pqCheckInBufferSpace(conn->inCursor + (size_t) msgLength - 4, When several messages have been already proccessed and avail < msgLength - 4, inBuffer will be enlarged without left-justification. I think that pqCheckInBufferSpace() should be called only when inBuffer is left-justified like this: 1432: if (conn->inStart =3D=3D 0 && pqCheckInBufferSpace(conn->inCurso= r + (size_t) msgLength - 4, When inBuffer was not left-justified at that moment, the line 1432 will be executed again after inBuffer is left-justified in pqReadData() called by pqGetCopyData3(). Please check this out. Sorry if I have mistaken. Note that I did not consider the async case. Thanks and best regards, --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs