Обсуждение: pg_dump: Error message from server: lost synchronization with server: got messag e type "d",

Поиск
Список
Период
Сортировка
I am trying to backup  a database  products with pg_Dump. The total size of
the database is 1.6 gb. One of the table in the database is product_image
which is 1gb in size. When I run the pg_dump on the database the database
backup fails with this error.

##pg_dump: Dumping the contents of table "product_image" failed:
PQgetCopyData
() failed.
pg_dump: Error message from server: lost synchronization with server:
got messag
e type "d", length 6036499
pg_dump: The command was: COPY public.product_image (id, username,
projectid, session, filename, filetype, filesize, filedata, uploadedon,
"timestamp") T

If I try to backup the database by excluding the product_image table, the
backup succeeds. I tried increasing the shared_buffer in the postgres.conf
to 1.5gb from 128MB , but the issue still persists. How can this issue be
resolved?



--
View this message in context:
http://postgresql.nabble.com/pg-dump-Error-message-from-server-lost-synchronization-with-server-got-messag-e-type-d-tp5854831.html
Sent from the PostgreSQL - admin mailing list archive at Nabble.com.


sveera <sveera@oration.com> writes:
> I am trying to backup  a database  products with pg_Dump. The total size of
> the database is 1.6 gb. One of the table in the database is product_image
> which is 1gb in size. When I run the pg_dump on the database the database
> backup fails with this error.

> ##pg_dump: Dumping the contents of table "product_image" failed:
> PQgetCopyData() failed.
> pg_dump: Error message from server: lost synchronization with server:
> got message type "d", length 6036499
> pg_dump: The command was: COPY public.product_image (id, username,
> projectid, session, filename, filetype, filesize, filedata, uploadedon,
> "timestamp") T

Hm.  Given that the message type and length seem perfectly reasonable,
I suspect this must actually represent an out-of-memory condition within
pg_dump (*not* on the server end).  But you'd have to be running it on a
toy box, or with a rather silly ulimit, for 6MB to be a problem...

            regards, tom lane


I wrote:
> Hm.  Given that the message type and length seem perfectly reasonable,
> I suspect this must actually represent an out-of-memory condition within
> pg_dump (*not* on the server end).  But you'd have to be running it on a
> toy box, or with a rather silly ulimit, for 6MB to be a problem...

BTW, how old is your pg_dump (or really, libpq)?  I wonder if you are
hitting this bug in some form:

Author: Tom Lane <tgl@sss.pgh.pa.us>
Branch: master Release: REL9_4_BR [2f557167b] 2014-05-07 21:39:13 -0400
Branch: REL9_3_STABLE Release: REL9_3_5 [b4f9c93ce] 2014-05-07 21:38:38 -0400
Branch: REL9_2_STABLE Release: REL9_2_9 [f7672c8ce] 2014-05-07 21:38:41 -0400
Branch: REL9_1_STABLE Release: REL9_1_14 [86888054a] 2014-05-07 21:38:44 -0400
Branch: REL9_0_STABLE Release: REL9_0_18 [77e662827] 2014-05-07 21:38:47 -0400
Branch: REL8_4_STABLE Release: REL8_4_22 [664ac3de7] 2014-05-07 21:38:50 -0400

    Avoid buffer bloat in libpq when server is consistently faster than client.

    If the server sends a long stream of data, and the server + network are
    consistently fast enough to force the recv() loop in pqReadData() to
    iterate until libpq's input buffer is full, then upon processing the last
    incomplete message in each bufferload we'd usually double the buffer size,
    due to supposing that we didn't have enough room in the buffer to finish
    collecting that message.  After filling the newly-enlarged buffer, the
    cycle repeats, eventually resulting in an out-of-memory situation (which
    would be reported misleadingly as "lost synchronization with server").
    Of course, we should not enlarge the buffer unless we still need room
    after discarding already-processed messages.

    This bug dates back quite a long time: pqParseInput3 has had the behavior
    since perhaps 2003, getCopyDataMessage at least since commit 70066eb1a1ad
    in 2008.  Probably the reason it's not been isolated before is that in
    common environments the recv() loop would always be faster than the server
    (if on the same machine) or faster than the network (if not); or at least
    it wouldn't be slower consistently enough to let the buffer ramp up to a
    problematic size.  The reported cases involve Windows, which perhaps has
    different timing behavior than other platforms.

    Per bug #7914 from Shin-ichi Morita, though this is different from his
    proposed solution.  Back-patch to all supported branches.

            regards, tom lane


I noted this part of the bug:

> The reported cases involve Windows, which perhaps has
>    different timing behavior than other platforms.

Many years ago, I move some code from UNIX to Windows (XP). On UNIX, I'd just made sure that I was making network write
callswith decent-sized buffers of at least a few multiples of packet size, and it would come pretty close to saturating
thenetwork. On windows, the same approach with same buffer sizes had 1/10th the network performance. 

So, yeah, Windows had "different timing behavior" to say the least.

--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
https://www.linkedin.com/in/scottribe/
(303) 722-0567 voice







Re: pg_dump: Error message from server: lost synchronization with server: got messag e type "d",

От
Sanjay Veeramachaneni
Дата:
Hi Tom,
Please see below
pg_dump (PostgreSQL) 9.3.9


On Tue, Jun 23, 2015 at 7:44 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
I wrote:
> Hm.  Given that the message type and length seem perfectly reasonable,
> I suspect this must actually represent an out-of-memory condition within
> pg_dump (*not* on the server end).  But you'd have to be running it on a
> toy box, or with a rather silly ulimit, for 6MB to be a problem...

BTW, how old is your pg_dump (or really, libpq)?  I wonder if you are
hitting this bug in some form:

Author: Tom Lane <tgl@sss.pgh.pa.us>
Branch: master Release: REL9_4_BR [2f557167b] 2014-05-07 21:39:13 -0400
Branch: REL9_3_STABLE Release: REL9_3_5 [b4f9c93ce] 2014-05-07 21:38:38 -0400
Branch: REL9_2_STABLE Release: REL9_2_9 [f7672c8ce] 2014-05-07 21:38:41 -0400
Branch: REL9_1_STABLE Release: REL9_1_14 [86888054a] 2014-05-07 21:38:44 -0400
Branch: REL9_0_STABLE Release: REL9_0_18 [77e662827] 2014-05-07 21:38:47 -0400
Branch: REL8_4_STABLE Release: REL8_4_22 [664ac3de7] 2014-05-07 21:38:50 -0400

    Avoid buffer bloat in libpq when server is consistently faster than client.

    If the server sends a long stream of data, and the server + network are
    consistently fast enough to force the recv() loop in pqReadData() to
    iterate until libpq's input buffer is full, then upon processing the last
    incomplete message in each bufferload we'd usually double the buffer size,
    due to supposing that we didn't have enough room in the buffer to finish
    collecting that message.  After filling the newly-enlarged buffer, the
    cycle repeats, eventually resulting in an out-of-memory situation (which
    would be reported misleadingly as "lost synchronization with server").
    Of course, we should not enlarge the buffer unless we still need room
    after discarding already-processed messages.

    This bug dates back quite a long time: pqParseInput3 has had the behavior
    since perhaps 2003, getCopyDataMessage at least since commit 70066eb1a1ad
    in 2008.  Probably the reason it's not been isolated before is that in
    common environments the recv() loop would always be faster than the server
    (if on the same machine) or faster than the network (if not); or at least
    it wouldn't be slower consistently enough to let the buffer ramp up to a
    problematic size.  The reported cases involve Windows, which perhaps has
    different timing behavior than other platforms.

    Per bug #7914 from Shin-ichi Morita, though this is different from his
    proposed solution.  Back-patch to all supported branches.

                        regards, tom lane



--
Best Regards,
Sanjay Veeramachaneni
Devops Engineer
989 E. Hillsdale Blvd., Suite 450, Foster City, CA 94404
 
Oration logo

Re: pg_dump: Error message from server: lost synchronization with server: got messag e type "d",

От
Sanjay Veeramachaneni
Дата:
Here is the version for libpq

###########
Package: libpq-dev
Priority: optional
Section: libdevel
Installed-Size: 724
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Debian PostgreSQL Maintainers <pkg-postgresql-public@lists.                                                                                                                                                             alioth.debian.org>
Architecture: amd64
Source: postgresql-9.3
Version: 9.3.8-0ubuntu0.4.04
Depends: libc6 (>= 2.4), libpq5 (= 9.3.8-0ubuntu0.4.04), libssl-dev, krb5-multid                                                                                                                                                             ev, comerr-dev
Suggests: postgresql-doc-9.3
Filename: pool/main/p/postgresql-9.3/libpq-dev_9.3.8-0ubuntu0.4.04_amd64.deb
Size: 139652
MD5sum: 35758649b8688c4126a6b15bf8664dac
SHA1: f77498099374832be4a92c63f23dcc681a57c9dd
SHA256: fb64325c76bb1b435d80e3edc635d75e2febee2fb4fc606734a5afd7d2461962
Description-en: header files for libpq5 (PostgreSQL library)
 Header files and static library for compiling C programs to link
 with the libpq library in order to communicate with a PostgreSQL
 database backend.
 .
 PostgreSQL is an object-relational SQL database management system.
Description-md5: 7f4362b106aae6b219ccc880faa1f04c
Origin: Ubuntu
Supported: 9m

Package: libpq-dev
Priority: optional
Section: libdevel
Installed-Size: 728
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Debian PostgreSQL Maintainers <pkg-postgresql-public@lists.                                                                                                                                                             alioth.debian.org>
Architecture: amd64
Source: postgresql-9.3
Version: 9.3.7-0ubuntu0.14.04
Depends: libc6 (>= 2.4), libpq5 (= 9.3.7-0ubuntu0.14.04), libssl-dev, krb5-multi                                                                                                                                                             dev, comerr-dev
Suggests: postgresql-doc-9.3
Filename: pool/main/p/postgresql-9.3/libpq-dev_9.3.7-0ubuntu0.14.04_amd64.deb
Size: 139954
MD5sum: 28d32f1ad1e5080c97bce2d46c434aee
SHA1: 73c2d36a1054241cfea0612f7e34388f106bd98a
SHA256: 042770afe0a71be9bf5ca30ac49579e829b15cff0495da7d09224f9c635446a8
Description-en: header files for libpq5 (PostgreSQL library)
 Header files and static library for compiling C programs to link
 with the libpq library in order to communicate with a PostgreSQL
 database backend.
 .
 PostgreSQL is an object-relational SQL database management system.
Description-md5: 7f4362b106aae6b219ccc880faa1f04c
Origin: Ubuntu
Supported: 9m

Package: libpq-dev
Priority: optional
Section: libdevel
Installed-Size: 720
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Debian PostgreSQL Maintainers <pkg-postgresql-public@lists.                                                                                                                                                             alioth.debian.org>
Architecture: amd64
Source: postgresql-9.3
Version: 9.3.4-1
Depends: libc6 (>= 2.4), libpq5 (= 9.3.4-1), libssl-dev, krb5-multidev, comerr-d                                                                                                                                                             ev
Suggests: postgresql-doc-9.3
Filename: pool/main/p/postgresql-9.3/libpq-dev_9.3.4-1_amd64.deb
Size: 138888
MD5sum: 56d8b168cd059c17ce29211ba8610111
SHA1: 28fb61e9b8791c7934e28f7ffe604ef2875e69b9
SHA256: e03839622bba3c67a876894aa9863b1be11f50c104a3e1582005393c4278c585
Description-en: header files for libpq5 (PostgreSQL library)
 Header files and static library for compiling C programs to link
 with the libpq library in order to communicate with a PostgreSQL
 database backend.
 .
 PostgreSQL is an object-relational SQL database management system.
Description-md5: 7f4362b106aae6b219ccc880faa1f04c
Origin: Ubuntu
##################

On Tue, Jun 23, 2015 at 7:44 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
I wrote:
> Hm.  Given that the message type and length seem perfectly reasonable,
> I suspect this must actually represent an out-of-memory condition within
> pg_dump (*not* on the server end).  But you'd have to be running it on a
> toy box, or with a rather silly ulimit, for 6MB to be a problem...

BTW, how old is your pg_dump (or really, libpq)?  I wonder if you are
hitting this bug in some form:

Author: Tom Lane <tgl@sss.pgh.pa.us>
Branch: master Release: REL9_4_BR [2f557167b] 2014-05-07 21:39:13 -0400
Branch: REL9_3_STABLE Release: REL9_3_5 [b4f9c93ce] 2014-05-07 21:38:38 -0400
Branch: REL9_2_STABLE Release: REL9_2_9 [f7672c8ce] 2014-05-07 21:38:41 -0400
Branch: REL9_1_STABLE Release: REL9_1_14 [86888054a] 2014-05-07 21:38:44 -0400
Branch: REL9_0_STABLE Release: REL9_0_18 [77e662827] 2014-05-07 21:38:47 -0400
Branch: REL8_4_STABLE Release: REL8_4_22 [664ac3de7] 2014-05-07 21:38:50 -0400

    Avoid buffer bloat in libpq when server is consistently faster than client.

    If the server sends a long stream of data, and the server + network are
    consistently fast enough to force the recv() loop in pqReadData() to
    iterate until libpq's input buffer is full, then upon processing the last
    incomplete message in each bufferload we'd usually double the buffer size,
    due to supposing that we didn't have enough room in the buffer to finish
    collecting that message.  After filling the newly-enlarged buffer, the
    cycle repeats, eventually resulting in an out-of-memory situation (which
    would be reported misleadingly as "lost synchronization with server").
    Of course, we should not enlarge the buffer unless we still need room
    after discarding already-processed messages.

    This bug dates back quite a long time: pqParseInput3 has had the behavior
    since perhaps 2003, getCopyDataMessage at least since commit 70066eb1a1ad
    in 2008.  Probably the reason it's not been isolated before is that in
    common environments the recv() loop would always be faster than the server
    (if on the same machine) or faster than the network (if not); or at least
    it wouldn't be slower consistently enough to let the buffer ramp up to a
    problematic size.  The reported cases involve Windows, which perhaps has
    different timing behavior than other platforms.

    Per bug #7914 from Shin-ichi Morita, though this is different from his
    proposed solution.  Back-patch to all supported branches.

                        regards, tom lane



--
Best Regards,
Sanjay Veeramachaneni
Devops Engineer
989 E. Hillsdale Blvd., Suite 450, Foster City, CA 94404
 
Oration logo

Sanjay Veeramachaneni <sveera@oration.com> writes:
> Here is the version for libpq

Well, that list is pretty opaque, because you've got several different
entries for libpq-dev and nothing for libpq proper ... but at least one
of those is a version that would contain the bug I mentioned.

Having said that, we've never seen a report of this bug visibly
manifesting on Linux, only on Windows.  So if that is what's biting you
there must be something unusual about your environment.

            regards, tom lane


Please see below for libpq5

Package: libpq5
Source: postgresql-9.4
Version: 9.4.4-1.pgdg14.04+1
Architecture: amd64
Maintainer: Debian PostgreSQL Maintainers <[hidden email]                                                                                                                                                             bian.org>
Installed-Size: 604
Pre-Depends: multiarch-support
Depends: libc6 (>= 2.14), libgssapi-krb5-2 (>= 1.10+dfsg~), libldap-2.4-2 (>= 2.                                                                                                                                                             4.7), libssl1.0.0 (>= 1.0.0)
Multi-Arch: same
Priority: optional
Section: libs
Filename: pool/main/p/postgresql-9.4/libpq5_9.4.4-1.pgdg14.04+1_amd64.deb
Size: 120780
SHA256: a1ad2f0a1bcea4f6fe7c568c1cdfded0aa0e9ee68ee1c90bf1d47e32576b645f
SHA1: c3279e7f3bfd59029330cfceff6a665f841bec28
MD5sum: aea2cebc7ddfb74c9bbad591b074e952
Description-en: PostgreSQL C client library
 libpq is a C library that enables user programs to communicate with
 the PostgreSQL database server.  The server can be on another machine
 and accessed through TCP/IP.  This version of libpq is compatible
 with servers from PostgreSQL 8.2 or later.
 .
 This package contains the run-time library, needed by packages using
 libpq.
 .
 PostgreSQL is an object-relational SQL database management system.
Description-md5: 4109d08c168c8058d09c0cc8bf8b18b1

Package: libpq5
Priority: optional
Section: libs
Installed-Size: 268
Maintainer: Ubuntu Developers <[hidden email]>
Original-Maintainer: Debian PostgreSQL Maintainers <pkg-postgresql-public@lists.                                                                                                                                                             alioth.debian.org>
Architecture: amd64
Source: postgresql-9.3
Version: 9.3.8-0ubuntu0.4.04
Depends: libc6 (>= 2.14), libcomerr2 (>= 1.01), libgssapi-krb5-2 (>= 1.10+dfsg~)                                                                                                                                                             , libkrb5-3 (>= 1.6.dfsg.2), libldap-2.4-2 (>= 2.4.7), libssl1.0.0 (>= 1.0.0)
Filename: pool/main/p/postgresql-9.3/libpq5_9.3.8-0ubuntu0.4.04_amd64.deb
Size: 81480
MD5sum: 9dc127771008386d3a69b19115038dfb
SHA1: eba5b22df720521b868c788dced32b04fc64f8fe
SHA256: e176c6690be694f9127ac4a8e9c1604341318a66a0e5e8326f3c21320695ba5a
Description-en: PostgreSQL C client library
 libpq is a C library that enables user programs to communicate with
 the PostgreSQL database server.  The server can be on another machine
 and accessed through TCP/IP.  This version of libpq is compatible
 with servers from PostgreSQL 8.2 or later.
 .
 This package contains the run-time library, needed by packages using
 libpq.
 .
 PostgreSQL is an object-relational SQL database management system.
Description-md5: 4109d08c168c8058d09c0cc8bf8b18b1
Origin: Ubuntu
Supported: 5y
Task: postgresql-server

Package: libpq5
Priority: optional
Section: libs
Installed-Size: 268
Maintainer: Ubuntu Developers <[hidden email]>
Original-Maintainer: Debian PostgreSQL Maintainers <pkg-postgresql-public@lists.                                                                                                                                                             alioth.debian.org>
Architecture: amd64
Source: postgresql-9.3
Version: 9.3.7-0ubuntu0.14.04
Depends: libc6 (>= 2.14), libcomerr2 (>= 1.01), libgssapi-krb5-2 (>= 1.10+dfsg~)                                                                                                                                                             , libkrb5-3 (>= 1.6.dfsg.2), libldap-2.4-2 (>= 2.4.7), libssl1.0.0 (>= 1.0.0)
Filename: pool/main/p/postgresql-9.3/libpq5_9.3.7-0ubuntu0.14.04_amd64.deb
Size: 80916
MD5sum: d11e150a1e982dbdf51af7c5f268ef13
SHA1: f4f41b9fcdadab8051950abb1bdda9622c40e72c
SHA256: a83bd9c08c5edf9b512e46eb72b22f36e70d838c983fe03e7125d729ec65869f
Description-en: PostgreSQL C client library
 libpq is a C library that enables user programs to communicate with
 the PostgreSQL database server.  The server can be on another machine
 and accessed through TCP/IP.  This version of libpq is compatible
 with servers from PostgreSQL 8.2 or later.
 .
 This package contains the run-time library, needed by packages using
 libpq.
 .
 PostgreSQL is an object-relational SQL database management system.
Description-md5: 4109d08c168c8058d09c0cc8bf8b18b1
Origin: Ubuntu
Supported: 5y
Task: postgresql-server

Package: libpq5
Priority: optional
Section: libs
Installed-Size: 264
Maintainer: Ubuntu Developers <[hidden email]>
Original-Maintainer: Debian PostgreSQL Maintainers <pkg-postgresql-public@lists.                                                                                                                                                             alioth.debian.org>
Architecture: amd64
Source: postgresql-9.3
Version: 9.3.4-1
Depends: libc6 (>= 2.14), libcomerr2 (>= 1.01), libgssapi-krb5-2 (>= 1.10+dfsg~)                                                                                                                                                             , libkrb5-3 (>= 1.6.dfsg.2), libldap-2.4-2 (>= 2.4.7), libssl1.0.0 (>= 1.0.0)
Filename: pool/main/p/postgresql-9.3/libpq5_9.3.4-1_amd64.deb
Size: 79936
MD5sum: 298d372dd5e131398ec75534a48c52ea
SHA1: 7fd0faaad3b9dbd174eb0e76e5281067dc408b32
SHA256: 1c7a14322e5e7f2a8fdf3beaf6ebb0f9a41fb2d3631b590b3f88e0158c1051f4
Description-en: PostgreSQL C client library
 libpq is a C library that enables user programs to communicate with
 the PostgreSQL database server.  The server can be on another machine
 and accessed through TCP/IP.  This version of libpq is compatible
 with servers from PostgreSQL 8.2 or later.
 .
 This package contains the run-time library, needed by packages using
 libpq.
 .
 PostgreSQL is an object-relational SQL database management system.
Description-md5: 4109d08c168c8058d09c0cc8bf8b18b1
Origin: Ubuntu
Supported: 5y
Task: postgresql-server


On Tue, Jun 23, 2015 at 11:02 AM, Tom Lane-2 [via PostgreSQL] <[hidden email]> wrote:
Sanjay Veeramachaneni <[hidden email]> writes:
> Here is the version for libpq

Well, that list is pretty opaque, because you've got several different
entries for libpq-dev and nothing for libpq proper ... but at least one
of those is a version that would contain the bug I mentioned.

Having said that, we've never seen a report of this bug visibly
manifesting on Linux, only on Windows.  So if that is what's biting you
there must be something unusual about your environment.

                        regards, tom lane


--
Sent via pgsql-admin mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin



To unsubscribe from pg_dump: Error message from server: lost synchronization with server: got messag e type "d",, click here.
NAML



--
Best Regards,
Sanjay Veeramachaneni
Devops Engineer
989 E. Hillsdale Blvd., Suite 450, Foster City, CA 94404
 
Oration logo



View this message in context: Re: pg_dump: Error message from server: lost synchronization with server: got messag e type "d",
Sent from the PostgreSQL - admin mailing list archive at Nabble.com.