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 1lJF5V-0001kk-Bf for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Mar 2021 12:34:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lJF5T-0007Qy-Dk for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Mar 2021 12:34:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lJF5T-0007Qr-6S for pgsql-hackers@lists.postgresql.org; Mon, 08 Mar 2021 12:34:15 +0000 Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lJF5Q-0005M6-Hx for pgsql-hackers@postgresql.org; Mon, 08 Mar 2021 12:34:14 +0000 Received: by mail-lj1-x229.google.com with SMTP id q14so15852646ljp.4 for ; Mon, 08 Mar 2021 04:34:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hagander-net.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6oH7oCBFr5+4Wj8dMX+HXVqGebtOqbn8nzBEtfo335U=; b=mA2JhICljqdOq15tLqP8sSa9peGAj0HmT+6k2UZcSkoIGa9P6eTSqcZ7zo/qZ4iq++ vpKSAZDQ5imPXmdAO+LSUy0hABE2eyVNDpyF5IOaNiTgirs6b3C0PLOaEdkRwwjzx+NY S5/Ney76/ngvZ2c5gEznnr14EDAYbDkIv4MDc6iZr/cble9JNzu1f/2i3GE13u0iA3XC AwHgczf6u46mTb4dSGWtL0E6/XQyOLy1584ClHw09xRWKkg8AXy1tCGjQwYfRFILWMnZ N6WHp/fWwxuIEX7IYcxm3KNbbBmfnQr1QcbtYMyeKMudDPPXAYHJlIWLUuHlqTqzmRJu FQVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6oH7oCBFr5+4Wj8dMX+HXVqGebtOqbn8nzBEtfo335U=; b=lh9zyOuryZWlh23aYRdwK9IeOvNw3sTXARD7Ni2j5QrsFZfMkzgBC6a3ubmcqO9356 BljXHmG7lioq9DCiGwwikCqWeZk4kq1MtQG+8hSFFe7LPEJIC/Ij4/lZuyeIX4OXNdWf hVHwTK8oGSP4xIk4V5nW84HT4csodqG5cKONwgUX4/K2XvgEgBPGG2n73bxsXE9b4Nb+ jJIGxuLD+wXZJ//TNAxSuIHWpybezSj7hAQ2hYnc3HU3Ob4Ovrl9gSN7mQbLQy94Xnlj jb6V4x7HfkfQ4Yi7mHrcnEjViSaNyLnMKeYAGPowIGrvk5hsJ4hBxzJreH6brn9HxLqo OUYg== X-Gm-Message-State: AOAM532c7QBzHpCFgFrTYQPvXXl6DFa1s3Iz3Yu8yIKZxAjjis9ucdoJ vaGLEm/RauS01/+fmmnkVf4YA5m5NDQiHAON0yXUpg== X-Google-Smtp-Source: ABdhPJzv/uUQEXSgNzhyD17n1X3A5uHaCxH3WYNalAYk80NrhafZsdGGpxfSA6wWeMya2Jlhr5riVNjiM72M7qWkEvI= X-Received: by 2002:a2e:9002:: with SMTP id h2mr14080112ljg.145.1615206850773; Mon, 08 Mar 2021 04:34:10 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Magnus Hagander Date: Mon, 8 Mar 2021 13:33:58 +0100 Message-ID: Subject: Re: pg_upgrade failing for 200+ million Large Objects To: "Tharakan, Robins" Cc: Peter Eisentraut , "pgsql-hackers@postgresql.org" Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Mar 8, 2021 at 12:02 PM Tharakan, Robins wrote: > > Thanks Peter. > > The original email [1] had some more context that somehow didn't get > associated with this recent email. Apologies for any confusion. Please take a look at your email configuration -- all your emails are lacking both References and In-reply-to headers, so every email starts a new thread, both for each reader and in the archives. It seems quite broken. It makes it very hard to follow. > In short, pg_resetxlog (and pg_resetwal) employs a magic constant [2] (for > both v9.6 as well as master) which seems to have been selected to force an > aggressive autovacuum as soon as the upgrade completes. Although that works > as planned, it narrows the window of Transaction IDs available for the > upgrade (before which XID wraparound protection kicks and aborts the > upgrade) to 146 Million. > > Reducing this magic constant allows a larger XID window, which is what the > patch is trying to do. With the patch, I was able to upgrade a cluster with > 500m Large Objects successfully (which otherwise reliably fails). In the > original email [1] I had also listed a few other possible workarounds, but > was unsure which would be a good direction to start working on.... thus this > patch to make a start. This still seems to just fix the symptoms and not the actual problem. What part of the pg_upgrade process is it that actually burns through that many transactions? Without looking, I would guess it's the schema reload using pg_dump/pg_restore and not actually pg_upgrade itself. This is a known issue in pg_dump/pg_restore. And if that is the case -- perhaps just running all of those in a single transaction would be a better choice? One could argue it's still not a proper fix, because we'd still have a huge memory usage etc, but it would then only burn 1 xid instead of 500M... AFAICT at a quick check, pg_dump in binary upgrade mode emits one lo_create() and one ALTER ... OWNER TO for each large object - so with 500M large objects that would be a billion statements, and thus a billion xids. And without checking, I'm fairly sure it doesn't load in a single transaction... -- Magnus Hagander Me: https://www.hagander.net/ Work: https://www.redpill-linpro.com/