Re: Patch: dumping tables data in multiple chunks in pg_dump

From: Hannu Krosing <hannuk(at)google(dot)com>
To: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, David Rowley <dgrowleyml(at)gmail(dot)com>, Michael Banck <mbanck(at)gmx(dot)net>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Nathan Bossart <nathandbossart(at)gmail(dot)com>
Subject: Re: Patch: dumping tables data in multiple chunks in pg_dump
Date: 2026-08-06 12:56:47
Message-ID: CAMT0RQTCipoCSHVZ7UamMZ9JnF-prN37hZNqrDwzQr5CpgJrzw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Zsolt,

I had finally time to return to this

Please find the latest patch attached

This commit fixes two critical issues :

1. Fixes dependency tracking during parallel restore. The original patch
modified dependencies (adding chunks) after depCount was initialized,
leading to early scheduling of dependent objects (constraints/indexes)
before all data chunks were loaded. This is fixed by moving the
depCount initialization loop to the end of fix_dependencies().

2. Fixes inserts mode. The previous patch missed adding ctid range clauses
to dumpTableData_insert(), causing the entire table to be dumped for
each chunk when using --inserts. This is fixed by adding the segment
ctid filtering logic to dumpTableData_insert() as well.
Also added TAP tests to verify chunked dump/restore in insert mode.

On Mon, Mar 30, 2026 at 11:32 PM Zsolt Parragi
<zsolt(dot)parragi(at)percona(dot)com> wrote:
>
> Hello!
>
> A simple test causes an assertion failure in my testing, dependency
> counting still doesn't seem to work correctly:
>
> pg_restore: >...>/pg_backup_archiver.c:5207: reduce_dependencies:
> Assertion `otherte->depCount > 0' failed.
>
> Without assertions it results in data loss.
>
> 004_pg_dump_parallel also showcases the issue in my testing.
>
> But simple manual testing also confirms it:
>
> 1. create some data
>
> CREATE TABLE tplain (id int UNIQUE);
> INSERT INTO tplain SELECT x FROM generate_series(1,1000) x;
>
> 2. create a dump
>
> dump with --max-table-segment-pages=2
>
> 3. try to restore
>
> restore with --jobs=3

Attachment Content-Type Size
v17--0001-Add-max-table-segment-pages-option-to-pg_dump-fo.patch application/x-patch 32.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Hannu Krosing 2026-08-06 13:10:14 Re: [PATCH] Extending FK check skipping on replicas to ADD FK and TRUNCATE
Previous Message Bertrand Drouvot 2026-08-06 12:47:12 Re: pgstat: Flush some statistics within running transactions, take 2