Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d2U9N-0002wn-VT for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Apr 2017 02:54:54 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d2U9N-0004Hb-FL for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Apr 2017 02:54:53 +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.84_2) (envelope-from ) id 1d2U7s-0001dt-OW for pgsql-hackers@postgresql.org; Mon, 24 Apr 2017 02:53:20 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d2U7q-0002kX-CG for pgsql-hackers@postgresql.org; Mon, 24 Apr 2017 02:53:19 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v3O2rFqs010701; Sun, 23 Apr 2017 22:53:15 -0400 From: Tom Lane To: Thomas Munro cc: Simon Riggs , Alvaro Herrera , Pg Hackers Subject: Re: [COMMITTERS] pgsql: Replication lag tracking for walsenders In-reply-to: References: <20170421190629.3srqyohjocgdvhhr@alvherre.pgsql> <27895.1492808648@sss.pgh.pa.us> <4219.1492875661@sss.pgh.pa.us> <300.1492927294@sss.pgh.pa.us> Comments: In-reply-to Thomas Munro message dated "Mon, 24 Apr 2017 10:34:44 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <10699.1493002395.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 23 Apr 2017 22:53:15 -0400 Message-ID: <10700.1493002395@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Thomas Munro writes: > On Sun, Apr 23, 2017 at 6:01 PM, Tom Lane wrote: >> Fair enough. But I'd still like an explanation of why only about >> half of the population is showing a failure here. Seems like every >> machine should be seeing the LSN as moving backwards in this test. >> So (a) why aren't they all failing, and (b) should we change the >> test to make sure every platform sees that happening? > Every machine sees the LSN moving backwards, but the code path that > had the assertion only reached if it decides to interpolate, which is > timing dependent: there needs to be a future sample in the lag > tracking buffer, which I guess is not the case in those runs. I'm dissatisfied with this explanation because if it's just timing, it doesn't seem very likely that some machines would reproduce the failure every single time while others never would. Maybe that can be blamed on kernel scheduler vagaries + different numbers of cores, but I can't escape the feeling that there's something here we've not fully understood. While chasing after this earlier today, I turned on some debug logging and noted that the standby's reports look like 2017-04-23 15:46:46.206 EDT [34829] LOG: database system is ready to accep= t read only connections 2017-04-23 15:46:46.212 EDT [34834] LOG: fetching timeline history file fo= r timeline 2 from primary server 2017-04-23 15:46:46.212 EDT [34834] LOG: started streaming WAL from primar= y at 0/3000000 on timeline 1 2017-04-23 15:46:46.213 EDT [34834] LOG: sending write 0/3020000 flush 0/3= 028470 apply 0/3028470 2017-04-23 15:46:46.214 EDT [34834] LOG: replication terminated by primary= server 2017-04-23 15:46:46.214 EDT [34834] DETAIL: End of WAL reached on timeline= 1 at 0/3028470. 2017-04-23 15:46:46.214 EDT [34834] LOG: sending write 0/3028470 flush 0/3= 028470 apply 0/3028470 2017-04-23 15:46:46.214 EDT [34830] LOG: new target timeline is 2 2017-04-23 15:46:46.214 EDT [34834] LOG: restarted WAL streaming at 0/3000= 000 on timeline 2 2017-04-23 15:46:46.228 EDT [34834] LOG: sending write 0/3020000 flush 0/3= 028470 apply 0/3028470 So you're right that the standby's reported "write" position can go backward, but it seems pretty darn odd that the flush and apply positions didn't go backward too. Is there a bug there? I remain of the opinion that if we can't tell from the transmitted data whether a timeline switch has caused the position to go backward, then that's a protocol shortcoming that ought to be fixed. regards, tom lane --=20 Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers