pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pg_upgrade with large pg_largeobject table
4+ messages / 2 participants
[nested] [flat]

* pg_upgrade with large pg_largeobject table
@ 2018-08-14 17:41 Mate Varga <m@matevarga.net>
  2018-08-14 17:58 ` Re: pg_upgrade with large pg_largeobject table Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Mate Varga @ 2018-08-14 17:41 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Hi.

hanks in advance for any advice.

We have a PSQL 9.5 DB with 16G physical RAM and ~ 1 TB data mostly stored
in the pg_largeobject system table. This table has 250M rows at the moment.
We're trying to upgrade this to 10.x with an in-place upgrade. The command
I'm using is:sudo -u postgres /usr/lib/postgresql/10/bin/pg_upgrade -b
/usr/lib/postgresql/9.5/bin -B /usr/lib/postgresql/10/bin -p 5433 -P 5434
-d /etc/postgresql/9.5/test -D /etc/postgresql/10/test --linkThis command
fails because of an OOM. Logs say:

command: "/usr/lib/postgresql/10/bin/pg_dump" --host
/var/log/postgresql/pg_upgradecluster-9.5-10-test.wjNi --port 5433
--username postgres --schema-only --quote-all-identifiers --binary-upgrade
--format=custom  --file="pg_upgrade_dump_31803.custom" 'dbname=tolven' >>
"pg_upgrade_dump_31803.log" 2>&1
pg_dump: [archiver (db)] query failed: out of memory for query result
pg_dump: [archiver (db)] query was: SELECT oid, (SELECT rolname FROM
pg_catalog.pg_roles WHERE oid = lomowner) AS rolname, lomacl, NULL AS
rlomacl, NULL AS initlomacl, NULL AS initrlomacl  FROM
pg_largeobject_metadata

Any ideas about how could we make this work on a server with only 16G RAM
(possibly a few dozens of gigabytes of swap)?Thanks.
Would it help if we'd inline these largeobjects as e.g. text cols (instead
of storing them as lobs)?
Thanks,
Mate

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pg_upgrade with large pg_largeobject table
  2018-08-14 17:41 pg_upgrade with large pg_largeobject table Mate Varga <m@matevarga.net>
@ 2018-08-14 17:58 ` Tom Lane <tgl@sss.pgh.pa.us>
  2018-08-14 18:06   ` Re: pg_upgrade with large pg_largeobject table Mate Varga <m@matevarga.net>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2018-08-14 17:58 UTC (permalink / raw)
  To: Mate Varga <m@matevarga.net>; +Cc: pgsql-general@lists.postgresql.org

Mate Varga <m@matevarga.net> writes:
> We have a PSQL 9.5 DB with 16G physical RAM and ~ 1 TB data mostly stored
> in the pg_largeobject system table. This table has 250M rows at the moment.

You mean 250M rows in pg_largeobject itself, or 250M large objects
(that is, 250M rows in pg_largeobject_metadata)?

> This command
> fails because of an OOM. Logs say:
> pg_dump: [archiver (db)] query failed: out of memory for query result
> pg_dump: [archiver (db)] query was: SELECT oid, (SELECT rolname FROM
> pg_catalog.pg_roles WHERE oid = lomowner) AS rolname, lomacl, NULL AS
> rlomacl, NULL AS initlomacl, NULL AS initrlomacl  FROM
> pg_largeobject_metadata

The selected rows shouldn't be very wide here, so I'm a bit surprised
you are hitting OOM, even if there are 250M rows to read.  Are you sure
you're using a 64-bit build of pg_dump?

> Would it help if we'd inline these largeobjects as e.g. text cols (instead
> of storing them as lobs)?

Yes, because then they'd not have their own ownership and permissions
for pg_dump to keep track of.  (You might want bytea instead of text,
depending on what the data is.)

Using the large-object API for things that tend to not actually be very
large (which they aren't, if you've got hundreds of millions of 'em)
is an antipattern, I'm afraid.  You could get away with it before we
added per-largeobject permissions, but now it's a problem for pg_dump.

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pg_upgrade with large pg_largeobject table
  2018-08-14 17:41 pg_upgrade with large pg_largeobject table Mate Varga <m@matevarga.net>
  2018-08-14 17:58 ` Re: pg_upgrade with large pg_largeobject table Tom Lane <tgl@sss.pgh.pa.us>
@ 2018-08-14 18:06   ` Mate Varga <m@matevarga.net>
  2018-08-14 18:16     ` Re: pg_upgrade with large pg_largeobject table Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Mate Varga @ 2018-08-14 18:06 UTC (permalink / raw)
  To: tgl@sss.pgh.pa.us; +Cc: pgsql-general@lists.postgresql.org

Thanks.

> You mean 250M rows in pg_largeobject itself, or 250M large objects
(that is, 250M rows in pg_largeobject_metadata)?

250M large objects.

> Are you sure you're using a 64-bit build of pg_dump?

 file /usr/lib/postgresql/10/bin/pg_dump
/usr/lib/postgresql/10/bin/pg_dump: ELF 64-bit LSB  shared object, x86-64,
version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux
2.6.24, BuildID[sha1]=4ff6bf0dd628d151481256723994dd50785e54e9, stripped
Also it really eats all the memory.

> Using the large-object API for things that tend to not actually be very
large (which they aren't, if you've got hundreds of millions of 'em)  is an
antipattern, I'm afraid.

I know :( So maybe I need to do some refactoring in the application and
inline the lobs. The data is binary data with very high entropy (encrypted
stuff). Would you recommend bytea for that?

Thanks again.
Mate



On Tue, Aug 14, 2018 at 7:58 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Mate Varga <m@matevarga.net> writes:
> > We have a PSQL 9.5 DB with 16G physical RAM and ~ 1 TB data mostly stored
> > in the pg_largeobject system table. This table has 250M rows at the
> moment.
>
> You mean 250M rows in pg_largeobject itself, or 250M large objects
> (that is, 250M rows in pg_largeobject_metadata)?
>
> > This command
> > fails because of an OOM. Logs say:
> > pg_dump: [archiver (db)] query failed: out of memory for query result
> > pg_dump: [archiver (db)] query was: SELECT oid, (SELECT rolname FROM
> > pg_catalog.pg_roles WHERE oid = lomowner) AS rolname, lomacl, NULL AS
> > rlomacl, NULL AS initlomacl, NULL AS initrlomacl  FROM
> > pg_largeobject_metadata
>
> The selected rows shouldn't be very wide here, so I'm a bit surprised
> you are hitting OOM, even if there are 250M rows to read.  Are you sure
> you're using a 64-bit build of pg_dump?
>
> > Would it help if we'd inline these largeobjects as e.g. text cols
> (instead
> > of storing them as lobs)?
>
> Yes, because then they'd not have their own ownership and permissions
> for pg_dump to keep track of.  (You might want bytea instead of text,
> depending on what the data is.)
>
> Using the large-object API for things that tend to not actually be very
> large (which they aren't, if you've got hundreds of millions of 'em)
> is an antipattern, I'm afraid.  You could get away with it before we
> added per-largeobject permissions, but now it's a problem for pg_dump.
>
>                         regards, tom lane
>

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pg_upgrade with large pg_largeobject table
  2018-08-14 17:41 pg_upgrade with large pg_largeobject table Mate Varga <m@matevarga.net>
  2018-08-14 17:58 ` Re: pg_upgrade with large pg_largeobject table Tom Lane <tgl@sss.pgh.pa.us>
  2018-08-14 18:06   ` Re: pg_upgrade with large pg_largeobject table Mate Varga <m@matevarga.net>
@ 2018-08-14 18:16     ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2018-08-14 18:16 UTC (permalink / raw)
  To: Mate Varga <m@matevarga.net>; +Cc: pgsql-general@lists.postgresql.org

Mate Varga <m@matevarga.net> writes:
>> Using the large-object API for things that tend to not actually be very
>> large (which they aren't, if you've got hundreds of millions of 'em) is an
>> antipattern, I'm afraid.

> I know :( So maybe I need to do some refactoring in the application and
> inline the lobs. The data is binary data with very high entropy (encrypted
> stuff). Would you recommend bytea for that?

Yeah, it'd likely be less of a pain-in-the-neck than text.  You would need
some sort of encoding anyway to deal with zero bytes and sequences that
aren't valid per your encoding, so you might as well go with bytea's
solution.

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2018-08-14 18:16 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-08-14 17:41 pg_upgrade with large pg_largeobject table Mate Varga <m@matevarga.net>
2018-08-14 17:58 ` Tom Lane <tgl@sss.pgh.pa.us>
2018-08-14 18:06   ` Mate Varga <m@matevarga.net>
2018-08-14 18:16     ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox