Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UCtR9-0004eL-5Q for pgsql-bugs@arkaria.postgresql.org; Tue, 05 Mar 2013 15:05:51 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UCtR8-000081-2x for pgsql-bugs@arkaria.postgresql.org; Tue, 05 Mar 2013 15:05:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UCpYY-0004yI-O2 for pgsql-bugs@postgresql.org; Tue, 05 Mar 2013 10:57:14 +0000 Received: from tbt-26-028.beingcorp.co.jp ([211.8.42.156] helo=24a021.beingcorp.co.jp) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UCpYT-0004Bu-4W for pgsql-bugs@postgresql.org; Tue, 05 Mar 2013 10:57:12 +0000 Received: from 25a038note (p11038-ipngnfx01sasajima.aichi.ocn.ne.jp [114.179.105.38]) by 24a021.beingcorp.co.jp (MOS 3.10.10a-GA) with SMTP id BRI43254; Tue, 5 Mar 2013 19:56:53 +0900 (JST) Message-ID: <2528D0D4784443EB95A0752179B0C0CE@25a038note> From: "Shin-ichi MORITA" To: "Tom Lane" Cc: References: <17113.1362429434@sss.pgh.pa.us> In-Reply-To: <17113.1362429434@sss.pgh.pa.us> Subject: Re: BUG #7914: pg_dump aborts occasionally Date: Tue, 5 Mar 2013 19:56:16 +0900 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-2022-jp"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Windows Mail 6.0.6002.18197 X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6002.18463 X-Pg-Spam-Score: -2.1 (--) 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 Hi Tom, > s-morita@beingcorp.co.jp writes: >> 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 > > Hm. Can you create a reproducible test case for this? This issue does not always happen. It seems to depend on the environment and the load. My test environment is actually a virual one as follows: Hypervisor: VMware vSphere Hypervisor 5.1 Allocated vCPUs: 1 Allocated Memory: 4GB OS: Windows Server 2012 1. Create test data using the script below. 2. Run pg_dump: pg_dump --host localhost --port 5432 --username postgres --format custom --verbose --file "..." --table public.t_data test_db ---- CREATE TABLE t_data ( c_id integer NOT NULL, c_data bytea, CONSTRAINT t_data_pkey PRIMARY KEY (c_id) ) WITH ( OIDS=FALSE ); CREATE LANGUAGE plpgsql; CREATE FUNCTION create_data(n INT) RETURNS VOID AS $$ BEGIN FOR i IN 1..n LOOP INSERT INTO t_data VALUES (i, rpad('', 20000, 'x')::bytea); END LOOP; END; $$ LANGUAGE plpgsql; SELECT create_data(300000); ---- >> I think that pqCheckInBufferSpace() should be called only when inBuffer >> is >> left-justified like this: >> 1432: if (conn->inStart == 0 && pqCheckInBufferSpace(conn->inCursor >> + >> (size_t) msgLength - 4, > > I think changing that code that way would break the considerations > mentioned in pqParseInput3; nor is it clear why this would help, anyway. > It doesn't seem likely that the buffer is so large that it can't be > enlarged by another 20K. I think this issue happens when pg_dump is slower than the backend for some reason. Actually, pg_dump's memory consumption glows over 500MB when this issue is happening. If pg_dump is slower than the backend for some reason and each message is not exactly 8K, inBuffer will frequently overflow in getCopyDataMessage(). This will cause frequent calls to pqCheckInBufferSpace() without left-justification. Each call will double inBuffer and inBuffer will rapidly glow even if each message is 20K. > regards, tom lane Regards, Shin-ichi MORITA -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs