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 1khw92-00075u-Ee for pgsql-admin@arkaria.postgresql.org; Wed, 25 Nov 2020 14:51:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1khw91-00044r-8Q for pgsql-admin@arkaria.postgresql.org; Wed, 25 Nov 2020 14:51:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1khw91-00044i-16 for pgsql-admin@lists.postgresql.org; Wed, 25 Nov 2020 14:51:43 +0000 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1khw8y-0007Lr-UM for pgsql-admin@postgresql.org; Wed, 25 Nov 2020 14:51:42 +0000 Received: by mail-ej1-x636.google.com with SMTP id a16so3388869ejj.5 for ; Wed, 25 Nov 2020 06:51:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=sqcTsvWJCeqtqMorxijkRH4YZiER6JJMIya25yJcoX0=; b=PA3OIhWNjxLn0DFXztlNLi8LcZM+b6ELtVUP3aeTaV/BwtZSL8TJ26jo5jJvq1yr8G wx7IT7LhMBl+cl3ubGxKBB66SFCSj2tBG0eeiCoDtSBWhR1KL/9kztVQJvk6fDfXunE5 rHpApZ8KhzccBjXoVK8CMNZR/YDi3qWeZ/02DTUcJ6DkuKYqkmw++th2sGW3YIKfQBw3 q04h+8ZxzQxoOQSVS+v/4VTUM4/CCJXI4sKL1amJ0GSZ+HVyEkFIFs838OEg3QxlxhSQ +9rIMPboCe72GJ0/53QFaU6ZyPbEwrLP/vhTfxeIhsznS1jHHIUD9N9j9rwsHT6LvaJX pPrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=sqcTsvWJCeqtqMorxijkRH4YZiER6JJMIya25yJcoX0=; b=LFrVm7B0skhThV8iFeZCH8G1KhuXCubMntaA8JNeM9GcLzgBnnHS/WPxX1AHf0UK7R g9FTnwoHcqEsb91f2/ZlZY9SqEwJD9dpso/Mmj74P4tPL241dcMhZ6kEMlrJcXKlIjD8 nslH1UGQV4mp0oseGqSxAuaA++lZ3On5dOLIcQOzXx/iQQnCziAdTU0qiWTu1gpAEXEI GFqL5sTXg35bXntVz+dWFGWLm6XeLSXmLjImKTx2nqfhIo8epEATyxjhZaP9Y35dhDbH jiQguIjw2xORViq0n3FwTBSu/utdgRXQ6QsRnrHd+VGp0PPEXupAVdIUClCf3E32XMyD WtEw== X-Gm-Message-State: AOAM5333UkUmQhovg/wzv3fhrkSG37WIErKbMpX5ZI4TSNABWKTleNuV C5dsCpqkXFK9RhbyrI3govP7lg2H78fCHg== X-Google-Smtp-Source: ABdhPJwJeBNrynDnEQHqVTr2RqNuj0YXIfrMM3m1nGejyT2NWzubjCtDZBBQdIUrTRwhOaKhV2OrmQ== X-Received: by 2002:a17:906:7c56:: with SMTP id g22mr3462648ejp.282.1606315900044; Wed, 25 Nov 2020 06:51:40 -0800 (PST) Received: from dynamic-dz4fdwzsoyt52ud39-pd01.res.v6.highway.a1.net (dynamic-dz4fdwzsoyt52ud39-pd01.res.v6.highway.a1.net. [2001:871:5c:14f:d00f:1a25:faaf:63c5]) by smtp.gmail.com with ESMTPSA id b13sm1402169edu.21.2020.11.25.06.51.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 06:51:39 -0800 (PST) Message-ID: <4a29258294e8e8c0a4e5189a3f502e03898f4e44.camel@cybertec.at> Subject: Re: Streaming Replication replay lag From: Laurenz Albe To: Nikhil Shetty Cc: pgsql-admin@postgresql.org Date: Wed, 25 Nov 2020 15:51:38 +0100 In-Reply-To: References: <3c462aa5a2da6b00f52fa90b69b7a542011cd924.camel@cybertec.at> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, 2020-11-25 at 11:02 +0530, Nikhil Shetty wrote: > > On Tue, Nov 24, 2020 at 9:35 PM Laurenz Albe wrote: > > On Tue, 2020-11-24 at 19:54 +0530, Nikhil Shetty wrote: > > > We have one Primary and three Standby Postgresql setup. Two standby in DC and one standby in DR. > > > > > > We have configured streaming replication.When there are a lot of write transactions > > > in the master, we observed that DR lags behind the master for 5-6 hours. We initially > > > thought this could be because of the slow network between DC and DR and this is normal > > > but when we saw the replay_lsn and receive_lsn , they had a huge difference. > > > > > > DR standby was receiving the WAL's in time and there was no delay, the delay was in > > > replaying the lag. Can anybody point me to where I can start with the investigation? > > > DC (Master and 2 Standby) and DR(Standby) have the same setup in terms of storage > > > and some database configuration parameters but DR has a little less CPU and RAM. > > > > If there is a delay replaying WAL, the cause is probably a replication conflict. > > > > Set "hot_standby = off" on the standby to avoid the problem totally. > > > > If you want queries on the standby, set "max_standby_streaming_delay" to 0 > > to keep replication from falling behind. > > We don't have any queries running on the DR server so setting "hot_standby=off" > can be done and we will observe the WAL replay but ss there a way to identify > that replay lag is because of the queries running on DR. I don't see any long > running queries in pg_stat_activity to > suggest that queries are not allowing the replay to happen. You could look for conflicts in "pg_stat_database" on the standby. If that is not the cause, perhaps the network is too slow for the amount of WAL, or the standby cannot replay fast enough (the startup process is a single thread). Yours, Laurenz Albe