Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YLJBp-0005Nn-IM for pgsql-admin@arkaria.postgresql.org; Tue, 10 Feb 2015 22:21:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YLJBp-0000V6-0r for pgsql-admin@arkaria.postgresql.org; Tue, 10 Feb 2015 22:21:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YLJBo-0000V0-44 for pgsql-admin@postgresql.org; Tue, 10 Feb 2015 22:21:52 +0000 Received: from www.ipv6.roaringpenguin.com ([2607:f748:1200:fb:70:38:112:54] helo=colo3.roaringpenguin.com) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YLJBh-0007GF-HO for pgsql-admin@postgresql.org; Tue, 10 Feb 2015 22:21:48 +0000 Received: from vanadium.roaringpenguin.com ([192.168.10.23]) by colo3.roaringpenguin.com (8.14.3/8.14.3/Debian-9.4) with ESMTP id t1AMLfx9018120 for ; Tue, 10 Feb 2015 17:21:41 -0500 Received: from ollie.roaringpenguin.com ([192.168.7.79]) by vanadium.roaringpenguin.com (8.14.4/8.14.4/Debian-4) with ESMTP id t1AMLem9019858 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT) for ; Tue, 10 Feb 2015 17:21:40 -0500 Date: Tue, 10 Feb 2015 17:21:39 -0500 From: "David F. Skoll" To: pgsql-admin@postgresql.org Subject: Streaming replication and WAL archiving Message-ID: <20150210172139.237ffb0b@ollie.roaringpenguin.com> Organization: Roaring Penguin Software Inc. X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=roaringpenguin.com; h=date :from:to:subject:message-id:mime-version:content-type :content-transfer-encoding; s=main; bh=lbDyVaSO5gulLtqB4MC6Hsebh /Q=; b=J2fRMLgbyWyNgZe64YkDrzdcQ/dI3nw2oFQZ41GOvs0BTx+xYvFgVUmQi l5myFArrRiZ9nY2zmSsIZkbzuwMz79fB5G1t7yg92QiGRLZ8dnPhHpAMSCmmP6in AOfVo6cvLhp4AKxQhlzyIL4X+O4HRqK2aJoAbK9uaZoqKUQHj8+AGS5tCFjcV6Sh ih0RAIro4VDpDWhbkU5K1ibSel0NU+7vFocvFTY8qmISsH4lHlUrSBk5Isl4gwa3 ZrkHPOCu80SPADVqFp7ROErNMq7qVfWbUerA/Nj81bHiUYuFCIv1brt8BnkLe9rN lNpQmddSf+SkLZ7F1/FB/OSwEbQmQ== X-Scanned-By: CanIt (www . roaringpenguin . com) X-Scanned-By: MIMEDefang 2.75 on 192.168.10.23 X-Spam-Score: undef - relay 192.168.10.23 marked with skip_spam_scan X-CanIt-Geo: No geolocation information available for 192.168.10.23 X-CanItPRO-Stream: outgoing (inherits from default) X-CanIt-Archive-Cluster: SQVyZJxqklY5buiWXYCN4T/BjiM X-CanIt-Archived-As: base/20150210 / 01NOKlFyF X-Pg-Spam-Score: -4.3 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org Hi, I have a two-database pair with a master and hot-standby. The hot-standby is connected to the master via streaming replication, but I also archive WAL files from master to standby just for safety. It occurs to me that this is a waste of bandwidth. I could set wal_keep_segments high and forget about the archiving, but what happens if disaster strikes and the backup is down for too long? I'm wondering if there's any way to write an archive_command script that: 1) Looks at the WAL file to figure out where it is in the transaction stream. 2) Connects to the backup server to figure out where *it* is. 3) If the backup server has already streamed all of the contents of the to-be-archived WAL file, just throw it away. Otherwise (or if step 2 failed) archive the WAL file. I'm not sure about the timing. It could be that it's impossible for all the WAL records to have been streamed already by the time a WAL file is ready to be archived. Maybe the archive_command could cheat and delay for a few seconds to see if the hot_standby can catch up. But I really would like to find some sort of adaptive way to decide whether or not a WAL file *really* needs to be archived over to the hot-standby for safety. Regards, David. -- Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin