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 1lJJDS-0005Hw-56 for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Mar 2021 16:58:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lJJDQ-0006Bq-V4 for pgsql-hackers@arkaria.postgresql.org; Mon, 08 Mar 2021 16:58:44 +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 1lJJDQ-0006BT-Nv for pgsql-hackers@lists.postgresql.org; Mon, 08 Mar 2021 16:58:44 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lJJDO-0007ST-E9 for pgsql-hackers@postgresql.org; Mon, 08 Mar 2021 16:58:43 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 128Gwd1x1743619; Mon, 8 Mar 2021 11:58:39 -0500 From: Tom Lane To: Magnus Hagander cc: Robins Tharakan , Peter Eisentraut , "pgsql-hackers@postgresql.org" Subject: Re: pg_upgrade failing for 200+ million Large Objects In-reply-to: References: <1742698.1615221182@sss.pgh.pa.us> Comments: In-reply-to Magnus Hagander message dated "Mon, 08 Mar 2021 17:35:56 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1743617.1615222719.1@sss.pgh.pa.us> Date: Mon, 08 Mar 2021 11:58:39 -0500 Message-ID: <1743618.1615222719@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Magnus Hagander writes: > On Mon, Mar 8, 2021 at 5:33 PM Tom Lane wrote: >> It does seem that --single-transaction is a better idea than fiddling with >> the transaction wraparound parameters, since the latter is just going to >> put off the onset of trouble. However, we'd have to do something about >> the lock consumption. Would it be sane to have the backend not bother to >> take any locks in binary-upgrade mode? > I believe the problem occurs when writing them rather than when > reading them, and I don't think we have a binary upgrade mode there. You're confusing pg_dump's --binary-upgrade switch (indeed applied on the dumping side) with the backend's -b switch (IsBinaryUpgrade, applied on the restoring side). > We could invent one of course. Another option might be to exclusively > lock pg_largeobject, and just say that if you do that, we don't have > to lock the individual objects (ever)? What was in the back of my mind is that we've sometimes seen complaints about too many locks needed to dump or restore a database with $MANY tables; so the large-object case seems like just a special case. The answer up to now has been "raise max_locks_per_transaction enough so you don't see the failure". Having now consumed a little more caffeine, I remember that that works in pg_upgrade scenarios too, since the user can fiddle with the target cluster's postgresql.conf before starting pg_upgrade. So it seems like the path of least resistance is (a) make pg_upgrade use --single-transaction when calling pg_restore (b) document (better) how to get around too-many-locks failures. regards, tom lane