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 1lNXkA-0005bf-OS for pgsql-hackers@arkaria.postgresql.org; Sat, 20 Mar 2021 09:18:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lNTOO-0000Yf-BC for pgsql-hackers@arkaria.postgresql.org; Sat, 20 Mar 2021 04:39:16 +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 1lNTOO-0000YW-17 for pgsql-hackers@lists.postgresql.org; Sat, 20 Mar 2021 04:39:16 +0000 Received: from mail-qt1-x830.google.com ([2607:f8b0:4864:20::830]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lNTOL-0003NG-N1 for pgsql-hackers@postgresql.org; Sat, 20 Mar 2021 04:39:15 +0000 Received: by mail-qt1-x830.google.com with SMTP id u7so8422303qtq.12 for ; Fri, 19 Mar 2021 21:39:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wi3ck-info.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=gY6mo5J/n2s+1128233Gdu3qLs+7UuVlsq1vXkCe66k=; b=ISMQ2IhingVu7rH9gVWVS2caDMRTi5oODXHZN80ka3yfWnDHpXmQ+Ra0ylgyFMDxTh LJx7ni7bTa+XIQuJjPoqV+z7Qq8rs8LIqDVQP1IGLn66i2AfqwbZBbb8Y/f67+2LX0Pw wtjAXhkj9ksh0CVRzKJw5KN6SaemM8fr4IMS5Aocg9eK8lUOoXSo5DKwNMSdYQKNv5FF FsV091HfIg4wbA9PuM7WPWORO2G6m89my8SkO0ymOtFf/5nt88OCQrATMHno78f41jGo 7fYRo3HKsuDBIWW7SLgC7wCjRZ3A0k6dEi2wDo+d6KwOxVP4AkFiKnvr8dRoyol/OmTA dreQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=gY6mo5J/n2s+1128233Gdu3qLs+7UuVlsq1vXkCe66k=; b=QgSUc+l4VxfqzHhQfOQHcA3dBp9PiWzHf5cqfPIAZJ5EBIKWcot8jeyb0NbMh045cw cJwRmROLSEtu3Sbz/dqEGZUOhMZGFv27naKJ1Se82hnVMsowV3b54IV5/jpxQomrDiLN flH/do8TZmDRrTUyCdrrKCy50yh/Jkg+qC5CJbxlOEUZ51HjMviPc6jAWs+QdYC76+3V VqGLnMYkzEhSyIICOGNtN1ct0+qZ8ljt1llRdivmncA3tijdKnNj6F1yeJrq9uF47799 foJ53NkOavtDX5ctOdH+vgMQSd34Thx56XTRgas7VrWW/I1LT9WodVznc+dkq9byMBN+ kM8A== X-Gm-Message-State: AOAM530C3AYCmQmZbeG+OrZkTIMtkCt+F+GyMt123FuNfqtxbXmz6Quq CmQoia3X3OJXj2308W/9/6RfAVSvyQQiL8fx X-Google-Smtp-Source: ABdhPJzlXvkqCkr+rYGzcVS6qZm4LiO/zfIoLNl2RiYCLiTpLvF8JlGXNX6vpaCrAwoXuYw70KP0+A== X-Received: by 2002:a05:622a:13d3:: with SMTP id p19mr1708338qtk.88.1616215151422; Fri, 19 Mar 2021 21:39:11 -0700 (PDT) Received: from jupiter.onmars.janwieck.no-ip.info (pool-98-114-241-134.phlapa.fios.verizon.net. [98.114.241.134]) by smtp.gmail.com with ESMTPSA id i78sm6061188qke.46.2021.03.19.21.39.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Mar 2021 21:39:11 -0700 (PDT) Subject: Re: pg_upgrade failing for 200+ million Large Objects To: 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> From: Jan Wieck Message-ID: <4fbf92f2-ec91-f4fa-a259-f0968e34f3d7@wi3ck.info> Date: Sat, 20 Mar 2021 00:39:10 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <1743618.1615222719@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 ... Regards, Jan -- Jan Wieck Principle Database Engineer Amazon Web Services