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.94.2) (envelope-from ) id 1sXR0k-00416G-VW for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Jul 2024 19:53:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sXR0h-00H8E9-Td for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Jul 2024 19:53:51 +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.94.2) (envelope-from ) id 1sXR0h-00H8E1-Hi for pgsql-hackers@lists.postgresql.org; Fri, 26 Jul 2024 19:53:51 +0000 Received: from mail-yb1-xb2a.google.com ([2607:f8b0:4864:20::b2a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sXR0b-001dBh-8q for pgsql-hackers@postgresql.org; Fri, 26 Jul 2024 19:53:50 +0000 Received: by mail-yb1-xb2a.google.com with SMTP id 3f1490d57ef6-e03a17a50a9so49512276.1 for ; Fri, 26 Jul 2024 12:53:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722023623; x=1722628423; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=LqiGT6zpTkRvJ+IJGDY9hQWd7sizHYHM1UFyT/bohL0=; b=Do4q8ommU2+U+FVSK1CJJDYF4WWuKV1RM8Vo29cmFDRkbcpE6aQOcsgheJKeq1kdsC SzNi+WAzHxthKeZTcPYzYoElCfXctiwGng8anmUbklhiJvCdMRZMT0KR2b/bodDCKfdQ ifUYmW7SY4gOy9plZhEz6eqMUKfIxnPjVlx9PzdHk/rKtlEE2EWQp+SKViq0Z5G1U4Tf hv8/Vvbs4DnoQDhjha88fxD4UOYD1Oft+1RSTTnxRUdn7Ex4w0KZDGCjhMEd9ISDLHFa Wpbs2128JLh/gmMUKm18Yn1nBE2PhKc5c5rcE6O7p3tbSMgOHFydb0E4XJu/9SBmwj3K KszA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722023623; x=1722628423; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LqiGT6zpTkRvJ+IJGDY9hQWd7sizHYHM1UFyT/bohL0=; b=qukBIu8f62Tn/6vkAbnZYKKlKSbSq5Wc2O3oyIocm8BDQ8iJcxXIWyTe8YB55r8Uo3 qdyNTBrv/lzGygVy6LSZL6TNJyhbll8ZWZlwzp2ayQe0oJdEPdME+531FSNUuow6Blfo WAuaRJYucSXfM8dGrwr5wpgltz0H7EbONZMSDDZ3sbYtJDZA3d0SQXmaRyy5yExm49L7 kWj/oXD3ycnXdynhbQ0KK50dLU8EbF0UK3jg/G0kkOkd4qllYsRLGbaUogbXACx+9IWp koqWjuOQa2zoUPhaSPdzn0wbemxG/nStZkchtVt8tmAP3sTvcueEKKUFOvEMEbwo2UQF 6r6Q== X-Forwarded-Encrypted: i=1; AJvYcCXTLT/y129n0NN1rUH1pklZ1T0H7Jm0esJudN1GHstuVopI2p06J/JLL39vhipmV42UKoRSvU22XwbJn5169mDdAi4PfznQbDI8N6zY X-Gm-Message-State: AOJu0Yz81shLxKkf1fbRCMKseCftjc/8jeLCrzIg1rDpVzTgZmhvw0zw XtrTW7ZdTxaDLciYjxJesSSy1jUDwSSE7teMF62Sp0YKiGF3eTURUfWiikdMQbOefeQdI43EFY9 rpr+9fK9r/DWZHDesgpg0khEqLcs= X-Google-Smtp-Source: AGHT+IFsDQnCUMIVQlvwjPwAmxbDvlEl/j8uITc7RJ5aKyv0BSBUSmY5pgHeW1MdxSo9Ugvc9g5gBe0P0gcICZSBKTo= X-Received: by 2002:a25:8546:0:b0:e03:9d46:44f4 with SMTP id 3f1490d57ef6-e0b5447cb8fmr908638276.15.1722023622989; Fri, 26 Jul 2024 12:53:42 -0700 (PDT) MIME-Version: 1.0 References: <842242.1706287466@sss.pgh.pa.us> <4a3ebf7d81bfc6dd4d545e5b27d6e8f6c32d8937.camel@cybertec.at> <3023817.1710629175@sss.pgh.pa.us> <6603e4e0.500a0220.a557f.4f39@mx.google.com> <3304322.1711551245@sss.pgh.pa.us> <20240327150826.GB3994937@nathanxps13> <20240401191930.GA2302032@nathanxps13> <1217588.1711999706@sss.pgh.pa.us> In-Reply-To: From: Alexander Korotkov Date: Fri, 26 Jul 2024 22:53:30 +0300 Message-ID: Subject: Re: pg_upgrade failing for 200+ million Large Objects To: Justin Pryzby Cc: Tom Lane , Nathan Bossart , Michael Banck , Laurenz Albe , vignesh C , "Kumar, Sachin" , Robins Tharakan , Jan Wieck , Bruce Momjian , Andrew Dunstan , Magnus Hagander , Peter Eisentraut , pgsql-hackers@postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, Justin! Thank you for sharing this. On Wed, Jul 24, 2024 at 5:18=E2=80=AFPM Justin Pryzby wrote: > On Mon, Apr 01, 2024 at 03:28:26PM -0400, Tom Lane wrote: > > Nathan Bossart writes: > > > The one design point that worries me a little is the non-configurabil= ity of > > > --transaction-size in pg_upgrade. I think it's fine to default it to= 1,000 > > > or something, but given how often I've had to fiddle with > > > max_locks_per_transaction, I'm wondering if we might regret hard-codi= ng it. > > > > Well, we could add a command-line switch to pg_upgrade, but I'm > > unconvinced that it'd be worth the trouble. I think a very large > > fraction of users invoke pg_upgrade by means of packager-supplied > > scripts that are unlikely to provide a way to pass through such > > a switch. I'm inclined to say let's leave it as-is until we get > > some actual field requests for a switch. > > I've been importing our schemas and doing upgrade testing, and was > surprised when a postgres backend was killed for OOM during pg_upgrade: > > Killed process 989302 (postgres) total-vm:5495648kB, anon-rss:5153292kB, = ... > > Upgrading from v16 =3D> v16 doesn't use nearly as much RAM. > > While tracking down the responsible commit, I reproduced the problem > using a subset of tables; at 959b38d770, the backend process used > ~650 MB RAM, and at its parent commit used at most ~120 MB. > > 959b38d770b Invent --transaction-size option for pg_restore. > > By changing RESTORE_TRANSACTION_SIZE to 100, backend RAM use goes to > 180 MB during pg_upgrade, which is reasonable. > > With partitioning, we have a lot of tables, some of them wide (126 > partitioned tables, 8942 childs, total 1019315 columns). I didn't track > if certain parts of our schema contribute most to the high backend mem > use, just that it's now 5x (while testing a subset) to 50x higher. Do you think there is a way to anonymize the schema and share it? > We'd surely prefer that the transaction size be configurable. I think we can add an option to pg_upgrade. But I wonder if there is something else we can do. It seems that restoring some objects is much more expensive than restoring others. It would be nice to identify such cases and check which memory contexts are growing and why. It would be helpful if you could share your data schema, so we could dig into it. I can imagine we need to count some DDL commands in aspect of maximum restore transaction size in a different way than others. Also, we probably need to change the default restore transaction size. ------ Regards, Alexander Korotkov Supabase