Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YR0sC-00027o-5b for pgsql-admin@arkaria.postgresql.org; Thu, 26 Feb 2015 16:01:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YR0sA-0003PX-O8 for pgsql-admin@arkaria.postgresql.org; Thu, 26 Feb 2015 16:01:10 +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 1YR0rJ-0002Ae-Q6 for pgsql-admin@postgresql.org; Thu, 26 Feb 2015 16:00:17 +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 1YR0rD-0005dD-1x for pgsql-admin@postgresql.org; Thu, 26 Feb 2015 16:00:13 +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 t1QG08NU023951; Thu, 26 Feb 2015 11:00:08 -0500 Received: from hydrogen.roaringpenguin.com (dfs@hydrogen.roaringpenguin.com [192.168.10.1]) by vanadium.roaringpenguin.com (8.14.4/8.14.4/Debian-4) with ESMTP id t1QG07Ge005065 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Thu, 26 Feb 2015 11:00:08 -0500 Date: Thu, 26 Feb 2015 11:00:07 -0500 From: "David F. Skoll" To: pgsql-admin@postgresql.org Cc: John Scalia Subject: Re: Weird spikes in delay for async streaming replication on 9.1 Message-ID: <20150226110007.09bb1551@hydrogen.roaringpenguin.com> In-Reply-To: <54EF411B.80202@gmail.com> References: <20150214110050.2f032f05@ollie.roaringpenguin.com> <20150226094428.34531376@hydrogen.roaringpenguin.com> <54EF3E6F.60403@gmail.com> <20150226104433.1b0df1db@hydrogen.roaringpenguin.com> <54EF411B.80202@gmail.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:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=main; bh=wDRFVt40RfHrsqy4tUH9NRzKy9w=; b=OHsslYixOWpC/Xo8SbmOhNHF8AeK vMFDZW5A8IhbvY6B4TSI670Z/9YRRGCQUuJvmDtTV/cq37QdyZ4DgFxC/0Pitfdx b4mxopBX2e7Ouh6+W2KK1aAqpfyIsIE4bBdO3/HofY9Gdqql8ShAvgb7brgPMPeQ 1h/P6hQTu/u/QJoPvfuB6VMiIsGaviPXoKFUbe7ttoEnAewfZWdyhbLMaILARccg hvTQGVueeA6XdoqMlterBBTjQJkxDKyxM6xi4WorIrGgST00Ca6HSq2vyK80y7nH XM2BcioV55VPfFt+OYJfSp/VOLLmXsTF3bOEU5/H9tKs1oyG1Yi/bBXDlw== 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/20150226 / 01NV408uJ 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 On Thu, 26 Feb 2015 10:51:55 -0500 John Scalia wrote: > OK, if it's asynchronous, is your script checking that primary isn't > holding up closing out and transmitting the latest WAL segment during > these times? No. The checking script is dead simple. It's a perl script that does more-or-less the equivalent of this. $master_dbi is a DBI handle pointing to the master database server and $standby_dbi is one pointing to the standby. Pseudocode is shown below (the real code actually measures the duration in much finer increments than 1s, but you get the idea...) my $time = time(); # There's one row in the table with key column 'Timestamp' $master_dbi->do("UPDATE table SET value = ? WHERE key = 'Timestamp'", undef, $time); my $start = time(); while(..) { $row = $standby_dbi->fetchrow_arrayref("SELECT * FROM table WHERE key = 'Timestamp'"); # Check that we got back the same $time we put in and if so, # break out of the while loop; otherwise pause for a bit. } # See how long that took my $duration = time() - $start; > And if the Standby really needs to be up to date, why > not try synchronous replication? It doesn't need to be totally up-to-date. It can lag by up to 30s without impacting our application. And we don't use synchronous replication because then a network problem would stall all the write transactions on the primary and that would be fatal. 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