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.96) (envelope-from ) id 1vnfOn-00A0d7-2y for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Feb 2026 16:06:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vnfOm-00CN3R-3B for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Feb 2026 16:06:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vnfOm-00CN3H-2E for pgsql-hackers@lists.postgresql.org; Wed, 04 Feb 2026 16:06:36 +0000 Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vnfOk-000000013LJ-0TKK for pgsql-hackers@lists.postgresql.org; Wed, 04 Feb 2026 16:06:35 +0000 Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-45f0c1f1b54so538658b6e.1 for ; Wed, 04 Feb 2026 08:06:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770221192; x=1770825992; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=O1qBGO31gA2jBWahL/x5VznreUyJ3CAtAXyz5+J9k00=; b=DM5O9pa2jUwsNXHIpl55RAMGiS+N/RDyiV8QkM0VQCWe2pUZSfJ9My4WPOk4fgRqVR GrgU6yVO6BCHs6yiFJ7Bj/eDxRh5s329g1z/W1orp3BRz8INaXp6SoEV45ETodN66ITk FY0vBRgBnE9zuCkau0dWvB1/rDkjPbqFDO4ofQCA6NHuD+B/tg5D1XgfC0WObIG6gd49 KdG/8Z8RFJFWM4zmB03rYR9bnmTwAS1x+17a2g/HzzhoB9jVh3T8xRMH/jD/NTf5rKdO KeSQ7AZ6x5kAcWP8NyAQXYNtfqw+RZcltvG9Qa9wVrpUPT0dIUCZ8rvtaFsqYvZ0TekE MeWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770221192; x=1770825992; h=in-reply-to:content-disposition: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; bh=O1qBGO31gA2jBWahL/x5VznreUyJ3CAtAXyz5+J9k00=; b=bmu0c++c7dU+rkSKlu/2QtxCiR278p2YHLXpYc42S2v0RQWzNReESCiZjbvk1VUxOh G7P351gFG8yNWOux6upAHE09nO+6In2h4lgGXfbHsDmCiBmCwV7FxBqOR7S/92YsNBqk Im1qEb5MnmQ+gO5aCKV7KjY/nTxtAEjP1mm4QbJCXbovxI7IVhaM4Jm12NkqQD3UVSiE JpFzchJhONReJJk/r44f1qvhj6YhpCodawI25ZbT2lVOWYvePVGG4bFXgxok/p2+L0SK w0ioK7DIqsBTvLIAg8dzqZjZZTSZwoqgKCxFNlytSq0R3QmgKHC7es52LVteSYDouRA0 AKog== X-Forwarded-Encrypted: i=1; AJvYcCXT8FGSDvj1/GbnUtaX86QFoPZgZn7QTCyUyRYQKK2tiJODl+zOE1PsugVp71+2MKdtj1+zOfFjPnryvKxI@lists.postgresql.org X-Gm-Message-State: AOJu0YwmfQtPS1m924SwHuWw3KTRb2A5e47gfoejIggp8bIW1myM+78W p8B2YBeRVhiajLf1a9cMP3ItFgaWKo43W9Jihi7TXd2fc2OM92vU1vsu X-Gm-Gg: AZuq6aLO/qj8RlylLGI2BwDZ+DmQ1U73xZAZ0ygW1InaIkdbJn0U6yuPw4z2Fr5BFze ltoZaAvVRuvQt8Kl3lzy4J4J5ypCjhGWiSdU9rISoRJ30DLacyzpYjL5AJuqhaf1NBNkpjcOm7d pCunAycy1hy2Rkk7X2dL0kEvnfaHkd0GtW8CcAyC3UBP6fQx3awEKbwJoQrtcw1ybppfrNzCXhv PaUiObTWf3gN6jUDaWAu3VHev/kOqPGnybcxfPoaLbLw9ZSLRXEXF6HZElQOcHfLniDr5tcuewD iBvlnCmexEtm+bg5Ol50bn0PUY9PNR0tjTybL98KTBnEUbsWmWYu988YRVJ3XwnRVoBBIDN2odP kZSLTUxPEY8NL2Qy+BkqdrozE8ofWo2iJyySvxV3Ujav0CaWSi1Ed7Eyk5gkI0vPS940Ofg3Zz2 DR5P49hGUIqSKFngemF1t0xHacZAIRw3RIM+3d6TvLItEppzAm8eQPk21Gmgrv6Rbiq333TaVMk oDe X-Received: by 2002:a05:6808:4f5f:b0:44f:775b:729f with SMTP id 5614622812f47-462d58c6a24mr1593910b6e.28.1770221191912; Wed, 04 Feb 2026 08:06:31 -0800 (PST) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 5614622812f47-462d67cf798sm1545596b6e.18.2026.02.04.08.06.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Feb 2026 08:06:31 -0800 (PST) Date: Wed, 4 Feb 2026 10:06:29 -0600 From: Nathan Bossart To: Andres Freund Cc: Michael Paquier , Tom Lane , Nitin Motiani , Hannu Krosing , PostgreSQL Hackers Subject: Re: pg_upgrade: transfer pg_largeobject_metadata's files when possible Message-ID: References: <3yd2ss6n7xywo6pmhd7jjh3bqwgvx35bflzgv3ag4cnzfkik7m@hiyadppqxx6w> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Feb 03, 2026 at 06:46:25PM -0500, Andres Freund wrote: >> The reason, I think, is that the COPY is happening into a relfilenode that >> will be overwritten later, it doesn't yet contain the contents of the old >> cluster. >> >> Presumably we do this because we need the temporary pg_largeobject_metadata to >> make COMMENT ON and security label commands not fail. >> >> If this is the reasoning / how it works, shouldn't there be a comment in the >> code or the commit message explaining that? Because it sure seems non-obvious >> to me. Right, the COPY for LOs with comments and security labels is solely meant to avoid failure when restoring the comments and security labels, since we won't have transferred the relation files yet. This was the case before commit 12a53c732c, where we had this comment in getBlobs(): * We *do* dump out the definition of the blob because we need that to * make the restoration of the comments, and anything else, work since * pg_upgrade copies the files behind pg_largeobject and * pg_largeobject_metadata after the dump is restored. Commit 3bcfcd815e (mine) added this one to pg_dump.c: * If upgrading from v16 or newer, only dump large objects with * comments/seclabels. For these upgrades, pg_upgrade can copy/link * pg_largeobject_metadata's files (which is usually faster) but we * still need to dump LOs with comments/seclabels here so that the * subsequent COMMENT and SECURITY LABEL commands work. pg_upgrade * can't copy/link the files from older versions because aclitem * (needed by pg_largeobject_metadata.lomacl) changed its storage * format in v16. IIUC your critique is that this doesn't explain the overwriting behavior like the older comment does. I'll work on adding that. >> It's also not entirely obvious to me that this is safe - after all >> (bbe08b8869bd, revised in 0e758ae89) appeared to have taken some pains to >> ensure that the file gets unlinked immediately during the "binary upgrade >> mode" TRUNCATE. But now we are actually filling that file again, after the >> relation had been truncated? > > An example of what could go wrong: > > [... examples of what could go wrong ...] I'm considering a couple of options here, but it seems like the easiest thing to do is to move the TRUNCATE commands to the end of the dump file. At least, that seems to be sufficient for our existing tests. If that seems okay to you, I can work on putting together a patch. -- nathan