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 1mTnd8-0004TE-5P for pgsql-performance@arkaria.postgresql.org; Fri, 24 Sep 2021 16:00:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mTnd6-0000TE-2A for pgsql-performance@arkaria.postgresql.org; Fri, 24 Sep 2021 16:00:52 +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 1mTnd5-0000T2-Q4 for pgsql-performance@lists.postgresql.org; Fri, 24 Sep 2021 16:00:51 +0000 Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mTnd3-0001Xp-9H for pgsql-performance@lists.postgresql.org; Fri, 24 Sep 2021 16:00:50 +0000 Received: (Authenticated sender: adsend@dunslane.net) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 43F0F1C000D; Fri, 24 Sep 2021 16:00:44 +0000 (UTC) Subject: Re: Performance for initial copy when using pg_logical to upgrade Postgres To: "Westwood, Giles" , pgsql-performance@lists.postgresql.org References: From: Andrew Dunstan Message-ID: <8b064d7e-204f-9a89-24a1-e856c66d408d@dunslane.net> Date: Fri, 24 Sep 2021 12:00:42 -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: 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 9/24/21 10:28 AM, Westwood, Giles wrote: > At Orcid we're trying to upgrade our Postgres database (10 to 13) > using pg_logical for no downtime. The problem we have is how long the > initial copy is taking for the ~500GB database. If it takes say 20days > to complete, will we need to have 20days of WAL files to start > catching up when it's complete? > > I read an earlier thread which pointed me to the tool > pglogical_create_subscriber which does a pg_basebackup to start the > initial replication but this is only going to be useful for logical > clusters on the same version. > > I had hoped that the COPY could be parallelized more by > "max_sync_workers_per_subscription" which is set to 2. However there's > only a single process:- > > postgres 1022196  6.0 24.5 588340 491564 ?       Ds   Sep22 193:19 > postgres: main: xxx xxxx 10.xx.xx.xx(59144) COPY > > One of the best resources I've found of real world examples are thead > on gitlabs own gitlab about their Postgres migrations. They discussed > one method that might work:- > > 1. Setup 9.6 secondary via streaming > 2. Turn physical secondary into logical secondary > 3. Shutdown and upgrade secondary to 10 > 4. Turn secondary back on. > > In which case we would only need the time required to perform the upgrade. If you're using the pglogical extension, the best way is often to create the replica as a physical replica (using pg_basebackup for example), and then using the extension's utility program pglogical_create_subscriber to convert the physical replica to a logical replica, which you then upgrade and switch over to. Of course, test it out before doing this for real. cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com