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 1jdq6u-0006Ry-0U for pgsql-general@arkaria.postgresql.org; Wed, 27 May 2020 07:04:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jdq6s-0004WJ-VN for pgsql-general@arkaria.postgresql.org; Wed, 27 May 2020 07:04:18 +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 1jdmJW-00069X-3W for pgsql-general@lists.postgresql.org; Wed, 27 May 2020 03:01:06 +0000 Received: from ip27.imatronix.com ([200.63.97.108]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jdmJQ-0002nz-Q1 for pgsql-general@postgresql.org; Wed, 27 May 2020 03:01:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=superfactura.cl; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=uLl0/hIew/nJ14BlWvIrVTVX83w7bQ24Z4/9yBEg3bk=; b=K3RsZIk+OuloVnv5jVh4BynU3T CvDFh8S8rxtOwKPmh2PFquIrcm7iXQvPpuuarz5l8Bdhiuqm0kdvutMw+Ppb7bdjTKXIIbbuXG0nu 0Zs9bJs4rS6mhAiSJU3gIf+RUk17MNpDITN4+umX+0M/X1tTKuC7aCe6WhmrTPpIvVKQlOEhp8SYX WSxN2IzTma1+b6ukZoeO8JOPim2sbaznn/Jn9aTNvzGKd1hdx8wtWFtwwJhi+2NioQh+onAl81BI8 613IzUM8WT859XmZWYsKIg1EH9pnQWFlypyzwp17dP5DDHBgQAobsWwcMSKW67Pelx2LWlwyA5LQO Ps8scrOg==; Received: from [200.73.112.45] by cpanel.imatronix.com with esmtpsa (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.93) (envelope-from ) id 1jdmJL-0006rg-4y ; Tue, 26 May 2020 23:00:55 -0400 Subject: Re: pg_basebackup + delta base backups To: Stephen Frost Cc: pgsql-general@postgresql.org References: <514b14cb-f0b8-157b-2755-d5170ed4d24b@imatronix.cl> <20191204030907.GB6962@tamriel.snowman.net> <367ee69d-9dc7-4de6-f8a1-b460567bcc07@imatronix.cl> <20200521124303.GV3418@tamriel.snowman.net> <03f63a68-14be-978a-ccc8-177a84f115a5@imatronix.cl> <20200524194833.GW3418@tamriel.snowman.net> <6c18a547-f2f3-74b7-32ad-f44cfaef10e3@imatronix.cl> <20200526142030.GD3418@tamriel.snowman.net> From: Christopher Pereira Organization: IMATRONIX S.A. Message-ID: Date: Tue, 26 May 2020 23:00:52 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 MIME-Version: 1.0 In-Reply-To: <20200526142030.GD3418@tamriel.snowman.net> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cpanel.imatronix.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - imatronix.cl X-Get-Message-Sender-Via: cpanel.imatronix.com: authenticated_id: soporte@superfactura.cl X-Authenticated-Sender: cpanel.imatronix.com: soporte@superfactura.cl X-Source: X-Source-Args: X-Source-Dir: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 26-May-20 10:20, Stephen Frost wrote: > [...] > > "out of sync" is a bit of an odd concept, but having a replica fall > behind a long way is certainly something that can happen and may require > a rebuild from a backup (or from a new sync off of the primary in some > other way, as you suggest below). In a situation where there's async > replication happening and you promote a replica to take over, that's > definitely a case where you might also have to rebuild the former > primary. Hi Stepehen, Yes, a common case with async streaming is when primary (A) goes down and replica is promoted as a new master (B). Then A comes back and has some data that was not streamed to B so pg_rewind is useless. I wonder if there is some option to just discard this branched data from A in order to start as a new replica. I noticed that pg_rewind is useless even when both DBs are identical (according to pg_dumpall | md5sum). > [...] >> As you said, all the pieces are there and it would be quite easy to write a >> new "pg_basebackup_delta" script that could be executed on the standby host >> to: >> >> 1) setup a pgBackRest repo on the primary host (via SSH) >> >> 2) create a backup on the primary host (via SSH) >> >> 3) do a delta restore on the standby >> >> Even when the repository on the primary host is only created temporarily >> (and require double storage, resources, etc), it may still be worth >> considering the traffic that can be saved by doing a delta restore on a >> standby host in a different region, right? > So... There's actually a way to do this with pgbackrest, but it doesn't > support the delta capability. If I understood correctly the method you described, you were basically doing a "backup" between A (primary) and B (repo) and in such a way the repo is then compatible with the pg_data structure, but without delta support (ie. transfering the whole database)? Delta support is critical for VLDBs, so I see two alternatives to replace pg_basebackup with pgbackrest to rebuild a replica: 1) Create a temporary repo on the primary 2) Create a temporary repo on the replica All configurations would be undone after the replica has been rebuilt and both alternatives would be using delta over the wire. In your opinion, which alternative is better considering network traffic? Thanks, Christopher