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 1x7ErL-00000000EJj-0P6l for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Sep 2026 16:21:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1x7ErK-00000005WFm-02hL for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Sep 2026 16:21:14 +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.98.2) (envelope-from ) id 1x7ErJ-00000005WFe-33Gu for pgsql-hackers@lists.postgresql.org; Thu, 17 Sep 2026 16:21:13 +0000 Received: from mail-pj2-x11.google.com ([2607:f8b0:4864:39::11]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x7ErG-00000001327-1fTv for pgsql-hackers@postgresql.org; Thu, 17 Sep 2026 16:21:13 +0000 Received: by mail-pj2-x11.google.com with SMTP id d9443c01a7336-2d747f05ffdso8806205ad.1 for ; Thu, 17 Sep 2026 09:21:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1789662069; x=1790266869; darn=postgresql.org; h=user-agent: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=Q6XD4VCOupRegpSLoQpQArq59W5imwHoGrNB04gDYYs=; b=atFWyX21W2K3A8okczr+8WxZL8dFbyx+B/J5mC1cFHmosrCfLifJgiZDHaahT37Lss 7N++J6Ym6sLLSf+4CvKc68ISKcGrsLbk4TFXrcKgDrID6dACOjKyelYOKpAa5jtk5r9V lIyXTj/z6+Je9He1qzu9rC372rQdfKaet4CII= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789662069; x=1790266869; h=user-agent: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=Q6XD4VCOupRegpSLoQpQArq59W5imwHoGrNB04gDYYs=; b=rB7LjIwR7TaUuUl8cPXd/jqt4qSsGsnCYp4ZxNzEESS9nyriekMZKXyknT8U8CG1+M L33Aa8zpOfeGiyxhUKVYDvoy3mANpeDkFS68bpI65o8ZJAGsxfyrlFhDPwWfugLHOxrF exgwTE5GFrfvsfXmCrpyLhGVyvFeHOzUP9+oU0KoL6yH3HexXFm4BS72IO05Z1g3mv6n aBG+pU0o77rzmahnZBe0jlzfBdeJb9inTalp0GHBVulM0SmO8+QEvGMTpX0hDL28QEug ohQ3Wmx/+ftRfX1JdRC2Tk6hLKt/yJEzhT0HZ43Y0K+YgsA6d/DPhCeEqzt4B3RrrUo6 e1Cg== X-Forwarded-Encrypted: i=1; AKwUvBzO9yz3XlBaR9JSt2ZF2PcsvrlQjOQkZb8icmvHFHb59RTlaKVRC/eqY2pRmJgERNxknI7E1z2KkMc4WLqv@postgresql.org X-Gm-Message-State: AFuF++nefLPMVp6zXw9zNYV5Nj0KWcDhzBV0/DryHV5iEOwpO5rrdoby 9lzmRjpeLd9Q7/mawydZhXmWImR8bEsVzHuStimtUpbEc6/HseWu9u7CQRnoPcDR+1plkPfihdm N8x9++g== X-Gm-Gg: AYBFou2ARnsmr5SglP/JmDo61Kld5iNPIqOGANp2GMvdMRbXG+JOnUlIcdXXy+RxwXs Blt8b7Tn2qdMBp5U3wj8vhv3Zgd6Cm0qDP8+sMUUlDxJcN+AvLrtDZ4ulrfl1fn1HCEHb6iHHdr OLxwWl1UY7EWswfBdCLD93KuFqtkEKF7NhBldAW0DKVcDnTPkSxMEM8Wbv0zAbCxtsQNuD7yanM QUQTfngJdXYOd9sbFNVLGVJYZ+SlkXDWEZjdyl21KnR1L4AVi71sjB2a55MYybYmqSXaLmB4l+y 0pqSNr3HlJMijdpeelj+LlIBMRgvPYdm1P9O9xR1OBcxAcVv7qcD1RC7Rz5VYTw/bXCuXMC9uZP PaR8nqLpAYXwTnVT9VCdMF3nUfn9NvvX92nVED+LF5DJOSeewZwn3CIafSvnmv4SMy7g4IRYdCe L9dZTYhH7v6+qUL9u2cxtsq9KWDFhYDXA0Jd5PXJ2r5YFZj6zBSU5NHX7vlqkRRcB+9qDoMxRrD kOrL9/resmzhUYc9npvS8a1XJbRUMo= X-Received: by 2002:a17:902:ec84:b0:2dd:ad74:ac29 with SMTP id d9443c01a7336-2ddad74ae47mr16160725ad.27.1789662069101; Thu, 17 Sep 2026 09:21:09 -0700 (PDT) Received: from microsoft.com (c-73-15-160-255.hsd1.ca.comcast.net. [73.15.160.255]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2dd89f244bdsm29537725ad.77.2026.09.17.09.21.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2026 09:21:08 -0700 (PDT) Date: Thu, 17 Sep 2026 09:21:05 -0700 From: Noah Misch To: Heikki Linnakangas Cc: orlovmg@gmail.com, pgsql-hackers@postgresql.org Subject: Re: 64-bit MultiXactOffset vs. 9.3->9.4 upgrade, pg_resetwal, "wraparound" msg Message-ID: <20260917162105.56.noahmisch@microsoft.com> References: <20260827231757.78.noahmisch@microsoft.com> <8fc26d4c-ff74-4cae-9c3d-db5c4f41d4ec@iki.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/2.3.0 (2026-01-25) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Sep 17, 2026 at 06:25:58PM +0300, Heikki Linnakangas wrote: > On 16/09/2026 14:33, Heikki Linnakangas wrote: > > On 28/08/2026 02:17, Noah Misch wrote: > > > commit bd8d9c9 wrote: > > > > Commit:     Heikki Linnakangas > > > > CommitDate: Tue Dec 9 13:53:03 2025 +0200 > > > > > > > >      Widen MultiXactOffset to 64 bits > > > > > > > --- a/src/bin/pg_upgrade/pg_upgrade.c > > > > +++ b/src/bin/pg_upgrade/pg_upgrade.c > > > > > > > +        nxtmulti = old_cluster.controldata.chkpnt_nxtmulti; > > > > +        if (old_cluster.controldata.cat_ver >= > > > > MULTIXACT_FORMATCHANGE_CAT_VER) > > > > +        { > > > > +            /* Versions 9.3 - 18: convert all multixids  */ > > > > +            oldstMulti = old_cluster.controldata.chkpnt_oldstMulti; > > > > > > If a cluster's upgrade history includes an upgrade from 9.3 to early > > > 9.4, it > > > may have a wrong value here.  Specifically, upgrades done before a61daa14 > > > (2014-07 commit) have that hazard.  We still have backend code to > > > detect such > > > cases and reduce damage: > > > > > >         ereport(LOG, > > >                 (errmsg("cannot truncate up to MultiXact %u because > > > it does not exist on disk, skipping truncation", > > >                         newOldestMulti))); > > > > > > However, the pg_upgrade side from the v19 commit lacks such > > > protection.  If > > > heap tuples still reference older multixacts than the faulty control data > > > suggests, pg_upgrade will copy too small a range, making affected tuples > > > unreadable. > > > > Thanks, I'll look into this. My first reaction is that I think if > > oldstMulti is incorrectly too old, the upgrade will fail because the > > conversion routine will fail to find it. If it's too new, i.e. "in the > > future", it will also fail to find it. Agreed, those cases fail cleanly. No concerns on those. > > The third possibility is that the bogus oldstMulti value is within the > > range of the "real" range. That's the only scenario I felt was at risk. For example, the range of MXIDs in tuple headers is [(unsigned)-100M,200M], but oldestMulti is 1. > > That can happen if multixid wraparound had > > already happened before the (broken) 9.3 -> 9.4 upgrade. In that case, > > even if the multixids are still readable on disk, you're one vacuum away > > from truncating them. In other words, the damage has already been done, > > or could be done at any minute. Okay. I briefly tried to verify how rapidly one can expect v18 to truncate the SLRUs in this scenario, but I didn't get very far. I will rely on your analysis. Thanks for studying it. > With the attached patch, you get an error message crafted specifically for > that case. > > > Converting pg_multixact files fatal > > > > Segment file containing multixid 1 does not exist. > > This can happen if an old version of pg_upgrade was used in the past > > to upgrade the cluster from version 9.3 to 9.4. If that is the cause, > > it can be fixed by running VACUUM FREEZE before upgrade. > > Failure, exiting > > I'm not sure this is worth committing though. How many clusters are there > out there that have been pg_upgraded to version 9.3.0-9.3.4, and haven't > since been running for long enough to fix the oldestMultiXid value? Having > that error message seems pretty harmless too, but if you actually hit that > case that the file is missing, it might actually be more likely that you've > hit some other bug than that old pg_upgrade issue. I wouldn't commit the more-specific error message. If it did something for the "third possibility", that might be different. I think we can consider closed the topic of how 9.3 upgrades interact with 64-bit MultiXactOffset.