pg_restore fails on extracted tar archives with large objects
The following commands produce an error:
createdb src
createdb dst
psql src -c "select lo_from_bytea(1, '\xff')"
pg_dump -Ft -f d.tar src
mkdir ex
tar xf d.tar -C ex
pg_restore -Fd -d dst ex
pg_restore: error: could not open large object TOC file "ex/2966.dat" for input: No such file or directory
This is because the tar format puts NNN.dat instead of blobs_NNN.toc into
the BLOBS TOC entry. That was harmless until commit a45c78e328 (v17)
taught the directory format's restore code to use the file name in the TOC
entry. Commit 166b4f4560 fixed a similar problem for directory-format
dumps made by versions before v12.
The attached patch fixes it by constructing the file name instead of using
the one in the TOC entry. Given the lack of reports, I'm guessing few
users are using extracted tar archives like this, or even using the tar
format at all. IMHO we should seriously consider putting the tar format on
a path to deprecation, but I'll save that discussion for later.
--
nathan
Hi,
The attached patch fixes it by constructing the file name instead of using
the one in the TOC entry.
I was able to reproduce this, and the patch fixes it for me. For
completeness I also tried multiple BLOBS batches and -j2, though I
didn't expect any problems, and directory-format dumps with large
objects still restore fine too. LGTM.
Maybe we could add a small test to 011_restore.pl, which already
pg_dumps and unpacks a tar archive, though if tar is headed for
deprecation it may not be worth the trouble atm.
--
Sami
Hi,
On Thu, Nov 19, 2026 at 03:23:32PM -0600, Nathan Bossart wrote:
The following commands produce an error:
createdb src
createdb dst
psql src -c "select lo_from_bytea(1, '\xff')"
pg_dump -Ft -f d.tar src
mkdir ex
tar xf d.tar -C ex
pg_restore -Fd -d dst expg_restore: error: could not open large object TOC file "ex/2966.dat" for input: No such file or directory
This is because the tar format puts NNN.dat instead of blobs_NNN.toc into
the BLOBS TOC entry. That was harmless until commit a45c78e328 (v17)
taught the directory format's restore code to use the file name in the TOC
entry. Commit 166b4f4560 fixed a similar problem for directory-format
dumps made by versions before v12.The attached patch fixes it by constructing the file name instead of using
the one in the TOC entry.
It looks like _PrepParallelRestore() is affected by the same issue. The stat()
fails, leaving the BLOBS entry’s dataLength at zero, so the parallel scheduler
cannot use the intended size estimate. Should this use the same filename
construction as _LoadLOs()?
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
On Fri, Nov 20, 2026 at 08:04:19AM +0000, Bertrand Drouvot wrote:
It looks like _PrepParallelRestore() is affected by the same issue. The stat()
fails, leaving the BLOBS entry’s dataLength at zero, so the parallel scheduler
cannot use the intended size estimate. Should this use the same filename
construction as _LoadLOs()?
Good catch. Here's an updated patch.
--
nathan
Hi,
On Fri, Nov 20, 2026 at 11:03:04AM -0600, Nathan Bossart wrote:
On Fri, Nov 20, 2026 at 08:04:19AM +0000, Bertrand Drouvot wrote:
It looks like _PrepParallelRestore() is affected by the same issue. The stat()
fails, leaving the BLOBS entry’s dataLength at zero, so the parallel scheduler
cannot use the intended size estimate. Should this use the same filename
construction as _LoadLOs()?Good catch. Here's an updated patch.
Thanks for the new patch version! LGTM.
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com