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 1mwB5O-0004Ic-T3 for pgsql-hackers@arkaria.postgresql.org; Sat, 11 Dec 2021 22:43:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mwB5L-0001ie-O8 for pgsql-hackers@arkaria.postgresql.org; Sat, 11 Dec 2021 22:43:19 +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 1mwB5L-0001iU-At for pgsql-hackers@lists.postgresql.org; Sat, 11 Dec 2021 22:43:19 +0000 Received: from mail-il1-x129.google.com ([2607:f8b0:4864:20::129]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mwB5D-0002ci-KZ for pgsql-hackers@postgresql.org; Sat, 11 Dec 2021 22:43:17 +0000 Received: by mail-il1-x129.google.com with SMTP id m5so11688066ilh.11 for ; Sat, 11 Dec 2021 14:43:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=5k+4KUB9yh8CwGDMcO+mCHaCY1W8nF4f6QLtTExh4uQ=; b=IbSCkAQBoFQf1Z6F/nkaTBHFJDVlR5uP5xg4XwloZsx5DMeLPKPhKCWNIaUdrIxmJB WFCRqrQRg76kV4305i6y8MJKcyUWp6cT2WnxDVYmXqp0eKEaG2qfrDYsVJbY7M98jVvh qpzuVoPjfWmfrK1hLhyea1caPim5KlvL33M3eb4LJDbcSOcbW0RIQB1wKv+RYg+/GKKw JEqZESbwurOYGK/KrCr7rMMCbO7eiStNwnJDMhdVP5bPG4kVlI1ORJsZxNrffpe9I1ZM 1LGU5Yvzz9n7EYI52aFGMDCf5XFhDzLH8wSm2aUJmLj7IXsDKqxxOJRWothDPHwuX0cR V5+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=5k+4KUB9yh8CwGDMcO+mCHaCY1W8nF4f6QLtTExh4uQ=; b=8B62Tu9m2XxJQ3k6yLYby82PhuBt03wbZ3vaw7amru6hZSftRw06MFSZ3h2t378ZYX HFUmireWPBPt/TGLBt0XGn3zyGktFzPRm0cH1HbTaHgM8NcrKesm+EoKeamEEj6aYco/ 4mcO8J6AU5qNiKLyQbD4l3FZJSmDm8ExzlULE6BLmBACFccCEma+zjFTCCZBDVVHWAxz niZ4gJytpveI3pL1+eRh/6g2GrFlUVXhI2EmmPCinzp4ksmK0j9Qez/x0xvGJNy/XKFT kjCMoEIkPuZ1DhYh3cNZ3ybWqHCNHVfZIsHi05Um4R0R1RKsDpomWg3Nos3ptrcj+2Z5 KxEg== X-Gm-Message-State: AOAM533Jd586xrkkIjTwpPQkIbUBZ1gum7FEqLLmRQegAbhnXNaSeQzx 71T6iJJ2M5XCnNmhpNo38bbpxA== X-Google-Smtp-Source: ABdhPJwjvawjc5q06beN9VbCmjBTQm8HnbBWF2M5Sycby9rVblis60RMi5qSrAF3/dyTnRGR+LtOUQ== X-Received: by 2002:a05:6e02:1585:: with SMTP id m5mr27002777ilu.34.1639262590464; Sat, 11 Dec 2021 14:43:10 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id n10sm6124235ilk.58.2021.12.11.14.43.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Dec 2021 14:43:09 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id BA950800DDD; Sat, 11 Dec 2021 16:43:08 -0600 (CST) Date: Sat, 11 Dec 2021 16:43:08 -0600 From: Justin Pryzby To: Jan Wieck Cc: Tom Lane , Bruce Momjian , Zhihong Yu , Andrew Dunstan , Magnus Hagander , Robins Tharakan , Peter Eisentraut , pgsql-hackers@postgresql.org Subject: Re: pg_upgrade failing for 200+ million Large Objects Message-ID: <20211211224308.GM17618@telsasoft.com> References: <91b02dc1-f0d9-e50d-849c-18d9a66484fb@wi3ck.info> <985941.1616524546@sss.pgh.pa.us> <986904.1616525964@sss.pgh.pa.us> <6cccaa33-c263-b8a2-b064-985605d33d25@wi3ck.info> <988415.1616528159@sss.pgh.pa.us> <872315a8-99fc-da4e-463d-784cfb5a025d@wi3ck.info> <1010642.1616532950@sss.pgh.pa.us> <802b96e9-f5e1-015c-dfb9-8756974b11fc@wi3ck.info> <0263bf35-05d6-02a1-519b-b7895a918314@wi3ck.info> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0263bf35-05d6-02a1-519b-b7895a918314@wi3ck.info> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Mar 24, 2021 at 12:05:27PM -0400, Jan Wieck wrote: > On 3/24/21 12:04 PM, Jan Wieck wrote: > > In any case I changed the options so that they behave the same way, the > > existing -o and -O (for old/new postmaster options) work. I don't think > > it would be wise to have option forwarding work differently between > > options for postmaster and options for pg_dump/pg_restore. > > Attaching the actual diff might help. I think the original issue with XIDs was fixed by 74cf7d46a. Are you still planning to progress the patches addressing huge memory use of pg_restore? Note this other, old thread on -general, which I believe has variations on the same patches. https://www.postgresql.org/message-id/flat/7bf19bf2-e6b7-01a7-1d96-f0607c728c49@wi3ck.info There was discussion about using pg_restore --single. Note that that was used at some point in the past: see 12ee6ec71 and 861ad67bd. The immediate problem is that --single conflicts with --create. I cleaned up a patch I'd written to work around that. It preserves DB settings and passes pg_upgrade's test. It's probably not portable as written, but if need be could pass an empty file instead of /dev/null... diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c index 3628bd74a7..9c504aff79 100644 --- a/src/bin/pg_upgrade/pg_upgrade.c +++ b/src/bin/pg_upgrade/pg_upgrade.c @@ -364,6 +364,16 @@ create_new_objects(void) DbInfo *old_db = &old_cluster.dbarr.dbs[dbnum]; const char *create_opts; + PQExpBufferData connstr, + escaped_connstr; + + initPQExpBuffer(&connstr); + initPQExpBuffer(&escaped_connstr); + appendPQExpBufferStr(&connstr, "dbname="); + appendConnStrVal(&connstr, old_db->db_name); + appendShellString(&escaped_connstr, connstr.data); + termPQExpBuffer(&connstr); + /* Skip template1 in this pass */ if (strcmp(old_db->db_name, "template1") == 0) continue; @@ -378,18 +388,31 @@ create_new_objects(void) * propagate its database-level properties. */ if (strcmp(old_db->db_name, "postgres") == 0) - create_opts = "--clean --create"; + create_opts = "--clean"; else - create_opts = "--create"; + create_opts = ""; + /* Create the DB but exclude all objects */ parallel_exec_prog(log_file_name, NULL, "\"%s/pg_restore\" %s %s --exit-on-error --verbose " + "--create -L /dev/null " "--dbname template1 \"%s\"", new_cluster.bindir, cluster_conn_opts(&new_cluster), create_opts, sql_file_name); + + parallel_exec_prog(log_file_name, + NULL, + "\"%s/pg_restore\" %s %s --exit-on-error --verbose --single " + "--dbname=%s \"%s\"", + new_cluster.bindir, + cluster_conn_opts(&new_cluster), + create_opts, + escaped_connstr.data, + sql_file_name); + } /* reap all children */