Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fi3Vo-0001fO-8S for pgsql-general@arkaria.postgresql.org; Tue, 24 Jul 2018 20:02:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fi3Vm-0004Q1-38 for pgsql-general@arkaria.postgresql.org; Tue, 24 Jul 2018 20:02:22 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fi3Vk-0004Pu-Uh for pgsql-general@lists.postgresql.org; Tue, 24 Jul 2018 20:02:21 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fi3Vg-0004Mc-IO for pgsql-general@postgresql.org; Tue, 24 Jul 2018 20:02:19 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 3F50721B4C; Tue, 24 Jul 2018 16:02:15 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Tue, 24 Jul 2018 16:02:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=56i7+v5COTU6hbaRtx18BB2/yQLwwYOtX3LldrNywvo=; b=CY7zxDNq 0ZaNVs3ds3c4fQlMvg33tAWPTB5GRX+8gBIzKFUUCYuvlF/lkgrBMYLsleplc1iM 5GZ8Cjzg7van8/RH10kcjVUgb90rrCZgpGTp6YB8L6IvIwAxCH/R0eJRM9A3i0qQ z5SfuRTpjXjyhOUViyGKjS5Kz3QLK9UhCUZaGB0xIEVQ0IZrZnU3+rmadqHtJygU cyg1/57jkvlcDW7jzbTNPKJceuZRcJTQZopYdgQcN7717cPawwy0+lHN94+8aqRE ivXGeUFmFP6B9Qdy0ZjbqEumrTTP1eQtBJ69eSOFzen+oU0bxYReh3NmcD4RGXxh pcUw90Bddo6Jgw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=56i7+v5COTU6hbaRtx18BB2/yQLww YOtX3LldrNywvo=; b=e5QjMrsK932Fm295Vd1DNgIIBCxyyEl71GptQ28Y1b7lr fw//ZLwe1CvtRiNLxzh9BK6gTOt9/V4NdFyXpOqXnIj5VP1MePER9VxZNv+RtQ13 9m+fDviO09KZsWnXj2kPHS6DDq7VHrJAtXt1wrc3W6THzf1SeSbmiiyxD0c6Wzt8 O7PMWubt8SVfBZwBklgccdKajXY5ilXYgQJowVswdpcJOo0g1xDEtbG6q2+KEY61 lvDxAKqMGxlVkNP4CXducS1TO46zRP0F5w7GHmw8OJ4Su4iP+duGuIZ2t/PU+079 uCckFoSu/dRGEUzsAgLXI3592J83bwfNNKwxzDtFQ== X-ME-Proxy: X-ME-Sender: Received: from intern.anarazel.de (c-98-210-140-171.hsd1.ca.comcast.net [98.210.140.171]) by mail.messagingengine.com (Postfix) with ESMTPA id 99ACD10279; Tue, 24 Jul 2018 16:02:14 -0400 (EDT) Date: Tue, 24 Jul 2018 13:02:13 -0700 From: Andres Freund To: Rory Falloon Cc: pgsql-general@postgresql.org Subject: Re: Dealing with latency to replication slave; what to do? Message-ID: <20180724200213.r7kdsmferazxr6ps@alap3.anarazel.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2018-07-24 15:39:32 -0400, Rory Falloon wrote: > Looking for any tips here on how to best maintain a replication slave which > is operating under some latency between networks - around 230ms. On a good > day/week, replication will keep up for a number of days, but however, when > the link is under higher than average usage, keeping replication active can > last merely minutes before falling behind again. > > 2018-07-24 18:46:14 GMTLOG: database system is ready to accept read only > connections > 2018-07-24 18:46:15 GMTLOG: started streaming WAL from primary at > 2B/93000000 on timeline 1 > 2018-07-24 18:59:28 GMTLOG: incomplete startup packet > 2018-07-24 19:15:36 GMTLOG: incomplete startup packet > 2018-07-24 19:15:36 GMTLOG: incomplete startup packet > 2018-07-24 19:15:37 GMTLOG: incomplete startup packet > > As you can see above, it lasted about half an hour before falling out of > sync. How can we see that from the above? The "incomplete startup messages" are independent of streaming rep? I think you need to show us more logs. > On the master, I have wal_keep_segments=128. What is happening when I see > "incomplete startup packet" - is it simply the slave has fallen behind, > and cannot 'catch up' using the wal segments quick enough? I assume the > slave is using the wal segments to replay changes and assuming there are > enough wal segments to cover the period it cannot stream properly, it will > eventually recover? You might want to look into replication slots to ensure the primary keeps the necessary segments, but not more, around. You might also want to look at wal_compression, to reduce the bandwidth usage. Greetings, Andres Freund