pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Anna Akenteva <a.akenteva@postgrespro.ru>
To: pgsql-hackers@lists.postgresql.org
Subject: Re: [HACKERS] make async slave to wait for lsn to be replayed
Date: Sat, 21 Mar 2020 13:51:13 +0300
Message-ID: <fce65a95741bac14498bb8c92cdfcec4@postgrespro.ru> (raw)
In-Reply-To: <774cef59db63a150b6127da2428cba7d@postgrespro.ru>
References: <195e2d07ead315b1620f1a053313f490@postgrespro.ru>
	<ddbbdd9495beaf7b3d280c2f44736535@postgrespro.ru>
	<774cef59db63a150b6127da2428cba7d@postgrespro.ru>

On 2020-03-17 15:47, Kartyshov Ivan wrote:
> Synopsis
> ==========
>     WAIT FOR [ANY | SOME | ALL] event [, event ...]
I'm confused as to what SOME would mean in this
command's syntax, but I can see you removed it
from gram.y since the last patch. Did you
decide to not implement it after all?

Also, I had a look at the code and tested it a bit.

================
If I specify many events, here's what happens:

For WAIT_FOR_ALL strategy, it chooses
- maximum LSN
- maximum delay
and waits for the resulting event.

For WAIT_FOR_ANY strategy - same, but it uses
minimal LSN/delay.

In other words, statements
   (1) WAIT FOR ALL
         LSN '7F97208' TIMEOUT 11,
         LSN '3002808' TIMEOUT 50;
   (2) WAIT FOR ANY
         LSN '7F97208' TIMEOUT 11,
         LSN '3002808' TIMEOUT 50;
are essentially equivalent to:
   (1) WAIT FOR LSN '7F97208' TIMEOUT 50;
   (2) WAIT FOR LSN '3002808' TIMEOUT 11;

It seems a bit counter-intuitive to me, because
I expected events to be treated independently.
Is this the expected behaviour?

================
In utility.c:
     if (event->delay < time_val)
         time_val = event->delay / 1000;

Since event->delay is an int, the result will
be zero for any delay value less than 1000.
I suggest either dividing by 1000.0 or
explicitly converting int to float.

Also, shouldn't event->delay be divided
by 1000 in the 'if' part as well?

================
You compare two LSN-s using pg_lsn_cmp():
     res = DatumGetUInt32(
         DirectFunctionCall2(pg_lsn_cmp,
                             lsn, trg_lsn));

As far as I understand, it'd be enough to use
operators such as "<=", as you do in wait.c:
     /* If LSN has been replayed */
     if (trg_lsn <= cur_lsn)

-- 
Anna Akenteva
Postgres Professional:
The Russian Postgres Company
http://www.postgrespro.com





view thread (216+ messages)  latest in thread

Message-ID: <fce65a95741bac14498bb8c92cdfcec4@postgrespro.ru>
Permalink:  ../fce65a95741bac14498bb8c92cdfcec4@postgrespro.ru/
Also on:    postgresql.org/message-id/fce65a95741bac14498bb8c92cdfcec4@postgrespro.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: a.akenteva@postgrespro.ru, pgsql-hackers@lists.postgresql.org
  Subject: Re: [HACKERS] make async slave to wait for lsn to be replayed
  In-Reply-To: <fce65a95741bac14498bb8c92cdfcec4@postgrespro.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox