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 1lNdMS-00086c-1x for pgsql-hackers@arkaria.postgresql.org; Sat, 20 Mar 2021 15:17:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lNdMQ-0000rW-Vh for pgsql-hackers@arkaria.postgresql.org; Sat, 20 Mar 2021 15:17:54 +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 1lNdMQ-0000rP-Oa for pgsql-hackers@lists.postgresql.org; Sat, 20 Mar 2021 15:17:54 +0000 Received: from relay7-d.mail.gandi.net ([217.70.183.200]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lNdMJ-0000El-RL for pgsql-hackers@postgresql.org; Sat, 20 Mar 2021 15:17:54 +0000 X-Originating-IP: 99.10.92.30 Received: from [192.168.10.146] (99-10-92-30.lightspeed.rlghnc.sbcglobal.net [99.10.92.30]) (Authenticated sender: adsend@dunslane.net) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id C9A8C20006; Sat, 20 Mar 2021 15:17:43 +0000 (UTC) Subject: Re: pg_upgrade failing for 200+ million Large Objects To: Jan Wieck , Tom Lane , Magnus Hagander Cc: Robins Tharakan , Peter Eisentraut , "pgsql-hackers@postgresql.org" References: <1742698.1615221182@sss.pgh.pa.us> <1743618.1615222719@sss.pgh.pa.us> <4fbf92f2-ec91-f4fa-a259-f0968e34f3d7@wi3ck.info> From: Andrew Dunstan Message-ID: Date: Sat, 20 Mar 2021 11:17:41 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <4fbf92f2-ec91-f4fa-a259-f0968e34f3d7@wi3ck.info> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/20/21 12:39 AM, Jan Wieck wrote: > On 3/8/21 11:58 AM, Tom Lane wrote: >> 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. > > That would first require to fix how pg_upgrade is creating the > databases. It uses "pg_restore --create", which is mutually exclusive > with --single-transaction because we cannot create a database inside > of a transaction. On the way pg_upgrade also mangles the > pg_database.datdba (all databases are owned by postgres after an > upgrade; will submit a separate patch for that as I consider that a > bug by itself). > > All that aside, the entire approach doesn't scale. > > In a hacked up pg_upgrade that does "createdb" first before calling > pg_upgrade with --single-transaction. I can upgrade 1M large objects with >     max_locks_per_transaction = 5300 >     max_connectinons=100 > which contradicts the docs. Need to find out where that math went off > the rails because that config should only have room for 530,000 locks, > not 1M. The same test fails with max_locks_per_transaction = 5200. > > But this would mean that one has to modify the postgresql.conf to > something like 530,000 max_locks_per_transaction at 100 > max_connections in order to actually run a successful upgrade of 100M > large objects. This config requires 26GB of memory just for locks. Add > to that the memory pg_restore needs to load the entire TOC before even > restoring a single object. > > Not going to work. But tests are still ongoing ... I thought Tom's suggestion upthread: > Would it be sane to have the backend not bother to > take any locks in binary-upgrade mode? was interesting. Could we do that on the restore side? After all, what are we locking against in binary upgrade mode? cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com