Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xUS12-00000000ye8-33Uy for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Nov 2026 17:03:13 +0000 Received: from localhost ([127.0.0.1]:48504 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xUS11-0000000ARMF-3eHU for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Nov 2026 17:03:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]:53186) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xUS11-0000000ARM2-1ouZ for pgsql-hackers@lists.postgresql.org; Fri, 20 Nov 2026 17:03:11 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xUS0z-00000000hST-0b3y for pgsql-hackers@postgresql.org; Fri, 20 Nov 2026 17:03:10 +0000 Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-c50933bdf4bso259930266b.1 for ; Fri, 20 Nov 2026 09:03:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795194188; x=1795798988; darn=postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=ByBgK8qR7nuwu1SEJvSpvE+52uGuIhiya7cAHfjjRaw=; b=uQgsIM7MRw5649Q8MVJXReoKbdrykrpoxEk6Bit1QSxSTevr11QG+Y/sOXg+1ZX2jz LhmocnYIs0IFmkymQI8JMV5c0AIF4h/yN4lE1l6xzT7Gf4dTa5CBdQowNFfF9W17mrul J01Fw8OV6+UxHfzWmlJy9WV3Lr5w9ojrygf2UdMpBalbP+MtzbsR5D6XpYpUAKktmduv ARJJxP2Yat0JtzVDma67I4w9F3m04Y8Bd8rHjpU7nqICiufKkZ49gwqMNw3QaeK1u+SZ LfrEDx/aWwCyHPeMsv84pdlFhFaYy2H4bvcw2ioJQkhrzz6/4hxgStQGxgFkU5yjo4se QfSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795194188; x=1795798988; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=ByBgK8qR7nuwu1SEJvSpvE+52uGuIhiya7cAHfjjRaw=; b=NcaP9rKOwhTQS9WmmuPZIJg6mOISXSbBWLWJPJMoZVzgUxrw+c/6XJolewNnrL1IBR aFj+Zhk7Zdz0+orvIbed4kFOMKzVbVjObD3wy3lUVefkUkjOoA3DHs1bItL6756cCkeq qqO1k3hs59JSkXlggaiR/xRSYy4klZr4uA5w8TDZWrCXcgdxnEvHCi6Ea8d/7h8AyTYY cqJn2IwiaLIR7XgqL3MEBzcZda3vnA0v7fwLMnfHGLn6xDwEHh7QzNp1bxiz9KUWRELN z75pryOEipzndlVw0GyTtuvUTJsdDtVbcM7U6ntFuyO6/u08wHZDo6VCyOJIHnubxWwL 6rDg== X-Gm-Message-State: APuU4Z/DCrFzOIjBMViHcWMHuVnxgi3Ck+IBqpl/hkJJc+uT61wdCmR2 I5VSH4clLV1wCR7WMu0RBGEjRXoVVWgWqIH3MfIuqYrTWI5QIszE6bLC X-Gm-Gg: AYBFou0gPMuVF6Sn9y7CiwwWXCEcu7F1n9SffSzjXe25UJtcuVYzByNfl1oH+4tmFQl 7U5nwa689Qb5r+3VIw7KaLAneOI8bdK/Nx7HCkqvV5kN4UP8dA9Py5r0L1C0qCZqmB9KxO+dEao 50OfL4DHkHqGPy38ri05P8KUnP2msmpWZOsCmOACb3qxcBXhxx0YNLKMNeEBiKo0cGDUnREWd1P WSY30J0AMOIJt11BjvvhJ+CpAg6DEzdM9+nMggSIK8iD9XinNtvJkz2BuI5//wVREh6qGeQclo3 EwLTmA4Rior1nnOuMpbyze0vLS/YW1IJm8zO921iNTYX2jXTqp0G5cbqk5SyYbDZDpdT2KoPCcq cu+x+N+ekMMhei7GTecrPr3yW42LkGp6yA8Ja53iQLVMJKZCISlU0rCJT7wfn+GqHCzS7CGiOU9 T/awb3UhLraU9Ryh6RqYayC76elBtiEn3xGA19V6y5+ahGxIx6ZStQIaHLnyUcHOR5citPE9qBG OUmuiZLjyJEbj+aMsVQdc73JF0BQKx4BEipUGc7qyWRNnDhGfskM9sW7Jfbf47tHU4cXWau9Mon OOaTbaNTmL6StmxGAUxmeTxHB9ObkYeoCMPirwB+dHzXshRWbc2uujlU7fa5U7HjVVtXExTcfsQ okknQORzMBX9t12YIOFZ/+/iZQoL+lKtOvf6kPKvTmPqJvLNSH2m9zT3C X-Received: by 2002:a17:907:ec09:b0:c2d:c6e7:9e9a with SMTP id a640c23a62f3a-c513a816ce5mr380864366b.11.1795194187954; Fri, 20 Nov 2026 09:03:07 -0800 (PST) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c513afc316bsm113828766b.56.2026.11.20.09.03.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Nov 2026 09:03:07 -0800 (PST) Date: Fri, 20 Nov 2026 11:03:04 -0600 From: Nathan Bossart To: Bertrand Drouvot Cc: pgsql-hackers@postgresql.org Subject: Re: pg_restore fails on extracted tar archives with large objects Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="KLs7pBG4sTm2P5SC" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --KLs7pBG4sTm2P5SC Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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 --KLs7pBG4sTm2P5SC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0001-pg_restore-Fix-incompatibilities-with-extracted-t.patch From 2a67852ccf1c07bd7e0c017d5d9250f6a01789f3 Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Fri, 20 Nov 2026 11:01:07 -0600 Subject: [PATCH v2 1/1] pg_restore: Fix incompatibilities with extracted tar dumps. Extracting a tar-format archive is supposed to produce a valid directory-format archive. Each BLOBS entry in the archive's table of contents (TOC) names a file that lists the large objects to restore, but the tar format puts the wrong file name into these entries. As a result, pg_restore fails to restore large objects from an extracted tar archive, and parallel restore can't estimate their size. To fix, construct the file name instead of using the one in the TOC entry, as commit 166b4f4560 did for directory-format archives made by versions before v12. This commit doesn't change the name recorded by the tar format, as that wouldn't help with existing archives. Reviewed-by: Sami Imseih Reviewed-by: Bertrand Drouvot Discussion: https://postgr.es/m/av9o1Fi3PQ-jqmGO%40nathan Backpatch-through: 15 --- src/bin/pg_dump/pg_backup_directory.c | 29 +++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/bin/pg_dump/pg_backup_directory.c b/src/bin/pg_dump/pg_backup_directory.c index 34b3b6ba7d7..ddd162ece3d 100644 --- a/src/bin/pg_dump/pg_backup_directory.c +++ b/src/bin/pg_dump/pg_backup_directory.c @@ -399,7 +399,6 @@ _LoadLOs(ArchiveHandle *AH, TocEntry *te) { Oid oid; lclContext *ctx = (lclContext *) AH->formatData; - lclTocEntry *tctx = (lclTocEntry *) te->formatData; CompressFileHandle *CFH; char tocfname[MAXPGPATH]; char line[MAXPGPATH]; @@ -409,14 +408,23 @@ _LoadLOs(ArchiveHandle *AH, TocEntry *te) /* * Note: before archive v16, there was always only one BLOBS TOC entry, * now there can be multiple. Furthermore, although the actual filename - * was always "blobs.toc" before v16, the value of tctx->filename did not + * was always "blobs.toc" before v16, the TOC entry's filename did not * match that before commit 548e50976 fixed it. For simplicity we assume * it must be "blobs.toc" in all archives before v16. + * + * Likewise, the tar format puts the wrong filename into the TOC entry, + * which matters when reading an extracted tar archive. For simplicity we + * assume it must be "blobs_.toc" in all newer archives. */ if (AH->version < K_VERS_1_16) setFilePath(AH, tocfname, "blobs.toc"); else - setFilePath(AH, tocfname, tctx->filename); + { + char tmp[MAXPGPATH]; + + snprintf(tmp, MAXPGPATH, "blobs_%d.toc", te->dumpId); + setFilePath(AH, tocfname, tmp); + } CFH = ctx->LOsTocFH = InitDiscoverCompressFileHandle(tocfname, PG_BINARY_R); @@ -735,8 +743,21 @@ _PrepParallelRestore(ArchiveHandle *AH) * using compression, the physical file size might not be a very good * guide to the amount of work involved in restoring the file, but we * only need an approximate indicator of that. + * + * Note that we can't rely on tctx->filename for BLOBS entries (see + * _LoadLOs()). */ - setFilePath(AH, fname, tctx->filename); + if (strcmp(te->desc, "BLOBS") != 0) + setFilePath(AH, fname, tctx->filename); + else if (AH->version < K_VERS_1_16) + setFilePath(AH, fname, "blobs.toc"); + else + { + char tmp[MAXPGPATH]; + + snprintf(tmp, MAXPGPATH, "blobs_%d.toc", te->dumpId); + setFilePath(AH, fname, tmp); + } if (stat(fname, &st) == 0) te->dataLength = st.st_size; -- 2.55.0 --KLs7pBG4sTm2P5SC--