Re: Measuring replay lag

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com>
Cc: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Measuring replay lag
Date: 2017-02-17 07:41:50
Message-ID: CAEepm=3NL1DQJWAMbF9z85WPNDbJH3TZcrX6LyETkqmwu=4HRw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Feb 16, 2017 at 11:18 PM, Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com> wrote:
> Hi Thomas.
>
> At 2017-02-15 00:48:41 +1300, thomas(dot)munro(at)enterprisedb(dot)com wrote:
>>
>> Here is a new version with the buffer on the sender side as requested.
>
> This looks good.

Thanks for the review!

>> + <entry><structfield>write_lag</></entry>
>> + <entry><type>interval</></entry>
>> + <entry>Estimated time taken for recent WAL records to be written on this
>> + standby server</entry>
>
> I think I would find a slightly more detailed explanation helpful here.

Fixed.

> A few tiny nits:
>
>> + * If the lsn hasn't advanced since last time, then do nothing. This way
>> + * we only record a new sample when new WAL has been written, which is
>> + * simple proxy for the time at which the log was written.
>
> "which is simple" → "which is a simple"

Fixed.

>> + * If the buffer if full, for now we just rewind by one slot and overwrite
>> + * the last sample, as a simple if somewhat uneven way to lower the
>> + * sampling rate. There may be better adaptive compaction algorithms.
>
> "buffer if" → "buffer is"

Fixed.

>> + * Find out how much time has elapsed since WAL position 'lsn' or earlier was
>> + * written to the lag tracking buffer and 'now'. Return -1 if no time is
>> + * available, and otherwise the elapsed time in microseconds.
>
> Find out how much time has elapsed "between X and 'now'", or "since X".
> (I prefer the former, i.e., s/since/between/.)

Fixed.

I also added some more comments in response to Simon's request for
more explanation of how it works (but will reply to his email
separately). Please find version 2 attached.

--
Thomas Munro
http://www.enterprisedb.com

Attachment Content-Type Size
replication-lag-v2.patch application/octet-stream 18.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2017-02-17 07:42:34 Re: Partitioned tables and relfilenode
Previous Message Amit Kapila 2017-02-17 07:25:01 Re: Write Ahead Logging for Hash Indexes