pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Nathan Bossart <nathandbossart@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Euler Taveira <euler@eulerto.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: improve performance of pg_dump with many sequences
Date: Mon, 29 Dec 2025 12:26:01 -0500
Message-ID: <2885944.1767029161@sss.pgh.pa.us> (raw)
In-Reply-To: <ZqpV5Sb7YWauwYnx@nathan>
References: <Zpc5HGb7yDfTNDy5@nathan>
	<ZpgR4OMpbekeja_n@nathan>
	<3578088.1721242766@sss.pgh.pa.us>
	<ZpgV32NTM0ADvJop@nathan>
	<3585715.1721243507@sss.pgh.pa.us>
	<ZpiP3I6UVcgsCCWf@nathan>
	<3640163.1721275101@sss.pgh.pa.us>
	<ZpldUoP0XjHszExF@nathan>
	<Zpl7HywbF2qAkTVf@nathan>
	<ZqFJspSbieuTE4X0@nathan>
	<ZqpV5Sb7YWauwYnx@nathan>

Nathan Bossart <nathandbossart@gmail.com> writes:
> Committed.

In the no-good-deed-goes-unpunished department: pg_dump's use
of pg_get_sequence_data() (nee pg_sequence_read_tuple()) is
evidently responsible for the complaint in bug #19365 [1]
that pg_dump can no longer survive concurrent sequence drops.

Given that that function already silently returns NULLs if the
sequence isn't readable for other reasons, I think it'd be
sane to make it silently return NULL if the sequence isn't
there anymore.  Unfortunately, that looks like it'd require
nontrivial restructuring of init_sequence().

Or maybe we could make it not use init_sequence()?  For the moment
a plain try_relation_open and check that it's a sequence should do,
but I'm not sure how that'd fit into people's plans for future
improvement of the sequence API.

There are other reasons not to like use of init_sequence in this
code path, too.  pg_dump's session will build a SeqTable entry for
every sequence in the database, which there could be a lot of,
and it will acquire RowExclusiveLock on every sequence and hold
that to the end of the dump, which seems likely to be troublesome
from a concurrency standpoint.  Since pg_get_sequence_data is a
read-only operation this lock level feels wrong.

BTW, I'm unconvinced that pg_dump behaves sanely when this function
does return nulls.  I think the ideal thing would be for it to skip
issuing setval(), but right now it looks like it will issue one with
garbage values.

			regards, tom lane

[1] https://www.postgresql.org/message-id/19365-6245240d8b926327%40postgresql.org





view thread (32+ messages)  latest in thread

Message-ID: <2885944.1767029161@sss.pgh.pa.us>
Permalink:  ../2885944.1767029161@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2885944.1767029161@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, nathandbossart@gmail.com, michael@paquier.xyz, euler@eulerto.com
  Subject: Re: improve performance of pg_dump with many sequences
  In-Reply-To: <2885944.1767029161@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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