Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o9WU6-0005CP-M6 for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Jul 2022 18:44:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o9WU5-0003Tl-83 for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Jul 2022 18:44:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o9WU4-0003Ta-Qh for pgsql-hackers@lists.postgresql.org; Thu, 07 Jul 2022 18:44:16 +0000 Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1o9WU1-0001YR-TV for pgsql-hackers@postgresql.org; Thu, 07 Jul 2022 18:44:16 +0000 Received: by mail-qk1-x72d.google.com with SMTP id o26so6970338qkl.6 for ; Thu, 07 Jul 2022 11:44:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=sMHxCGPocipJiTQXNSNRndK2JUHEEJD3uzqOnRVmMNI=; b=ITSTVH9djB86tCiM0rMrUck5TutJsU8jR7kqpgy+33cVFwyI6WHqGNlCNoznV5dFqQ U2H2J7sd1l9f1ua5FJxpKpx5tNN2RrEa1zNNk0Q+awxbA1XGCkB1QgUQWO6xxXXIw8K4 MwTllcu2V5rSw9alyrjgy3XY+9jLgAtEy2BL/kjFBJ1PbbPIxKNaFLKzoOwEfVgPwZ/h EaNWwRNeQVtDQpScFJ9f4vEW5wpw/cdCOWRcbR8Yuv/WlLyi37TF1SgmNaEZm7a6YCQS s9HEP2ssxEAcdHR9GwfctrHRiR+j5cabe4U2bab27sF1tZKU/8OlalQweHuK/mrJsXrF cE1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=sMHxCGPocipJiTQXNSNRndK2JUHEEJD3uzqOnRVmMNI=; b=4hOM4i7TrNEZlyCMQDFFL2jG9ZsfLfMDTOFOiFoOv2dYR16/2z/M3MUK3vHUtyRmCI UNWGDVtTyR9NqutUF0B8Amz4XFupD9ZRpyaEASEZ1tetUtz2W/du1L+8ljRaRekC1jet bK+iY+1zRbHb24M61HD41SOO5c4cQSFjmt2raTBP6v+u2V1aqMzdbK5t2zKTNglHUm3/ 9iEGhPfB6Y+d1KXO22yS/pMhoCz0TxdP3rmdcjPt/hOaGNUXoalmPOwJf6gug97WgRJG T2v2qYnfVuY1qBKrZA994OMCL6bEeJWdqMVjN2ENrCQg37etCrYb36XmgwxoBy/cVTE5 oPeQ== X-Gm-Message-State: AJIora9KACiHCamMjBR3VjvwxdC4Ep6LiUSIWcgZyTFLyYO0vKDDthaH nuIQ1cHQdI2bndfmJ16Rw5G6ag== X-Google-Smtp-Source: AGRyM1se4amCmIF2RClb3KSbItSL1Hw5hvoT1uQqNIz70ybFH6Ni/E6FDajYpCtHQ+rR1oegU6uElQ== X-Received: by 2002:a05:620a:46a2:b0:6b5:5998:17a1 with SMTP id bq34-20020a05620a46a200b006b5599817a1mr2072153qkb.208.1657219451889; Thu, 07 Jul 2022 11:44:11 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id q11-20020a05620a0d8b00b006a32bf19502sm31767410qkl.60.2022.07.07.11.44.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jul 2022 11:44:11 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 3BB61801141; Thu, 7 Jul 2022 13:44:10 -0500 (CDT) Date: Thu, 7 Jul 2022 13:44:10 -0500 From: Justin Pryzby To: Robert Haas Cc: Bruce Momjian , pgsql-hackers@postgresql.org, Shruthi Gowda Subject: Re: pg15b2: large objects lost on upgrade Message-ID: <20220707184410.GB13040@telsasoft.com> References: <20220702154917.GM13040@telsasoft.com> <20220705165605.GR13040@telsasoft.com> <20220706115600.GU13040@telsasoft.com> <20220707171019.GA13040@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Jul 07, 2022 at 02:38:44PM -0400, Robert Haas wrote: > On Thu, Jul 7, 2022 at 2:24 PM Bruce Momjian wrote: > > On Thu, Jul 7, 2022 at 01:38:44PM -0400, Robert Haas wrote: > > > On Thu, Jul 7, 2022 at 1:10 PM Justin Pryzby wrote: > > > > Maybe it's a good idea to check that the file is empty before unlinking... > > > > > > If we want to verify that there are no large objects in the cluster, > > > we could do that in check_new_cluster_is_empty(). However, even if > > > there aren't, the length of the file could still be more than 0, if > > > there were some large objects previously and then they were removed. > > > So it's not entirely obvious to me that we should refuse to remove a > > > non-empty file. > > > > Uh, that initdb-created pg_largeobject file should not have any data in > > it ever, as far as I know at that point in pg_upgrade. How would values > > have gotten in there? Via pg_dump? > > I was thinking if the user had done it manually before running pg_upgrade. We're referring to the new cluster which should have been initdb'd more or less immediately before running pg_upgrade [0]. It'd be weird to me if someone were to initdb a new cluster, then create some large objects, and then maybe delete them, and then run pg_upgrade. Why wouldn't they do their work on the old cluster before upgrading, or on the new cluster afterwards ? Does anybody actually do anything significant between initdb and pg_upgrade ? Is that considered to be supported ? It seems like pg_upgrade could itself run initdb, with the correct options for locale, checksum, block size, etc (although it probably has to support the existing way to handle "compatible encodings"). Actually, I think check_new_cluster_is_empty() ought to prohibit doing work between initdb and pg_upgrade by checking that no objects have *ever* been created in the new cluster, by checking that NextOid == 16384. But I have a separate thread about "pg-upgrade allows itself to be re-run", and this has more to do with that than about whether to check that the file is empty before removing it. -- Justin