public inbox for [email protected]  
help / color / mirror / Atom feed
From: Drouvot, Bertrand <[email protected]>
To: [email protected]
Cc: Alvaro Herrera <[email protected]>
Cc: Andres Freund <[email protected]>
Cc: Ibrar Ahmed <[email protected]>
Cc: Amit Khandekar <[email protected]>
Cc: tushar <[email protected]>
Cc: [pgdg] Robert Haas <[email protected]>
Cc: Rahila Syed <[email protected]>
Cc: pgsql-hackers <[email protected]>
Subject: Re: Minimal logical decoding on standbys
Date: Mon, 20 Sep 2021 12:17:11 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAFcNs+qKfjB+Hy5A7Ev6=JrrbhFqp2DtDFcmLpErhzp6y+UcVA@mail.gmail.com>
References: <[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<CAFcNs+qKfjB+Hy5A7Ev6=JrrbhFqp2DtDFcmLpErhzp6y+UcVA@mail.gmail.com>

Hi,

On 9/17/21 10:32 PM, Fabrízio de Royes Mello wrote:
>
> On Wed, Sep 15, 2021 at 8:36 AM Drouvot, Bertrand <[email protected] 
> <mailto:[email protected]>> wrote:
> >
> > Another rebase attached.
> >
> > The patch proposal to address Andre's walsender corner cases is 
> still a dedicated commit (as i think it may be easier to discuss).
> >
>
> Did one more battery of tests and everything went well...

Thanks for looking at it!

>
> But doing some manually tests:
>
> 1. Setup master/replica (wal_level=logical, hot_standby_feedback=on, etc)
> 2. Initialize the master instance: "pgbench -i -s10 on master"
> 3. Terminal1: execute "pgbench -c20 -T 2000"
> 4. Terminal2: create the logical replication slot:
>
> 271480 (replica) fabrizio=# select * from 
> pg_create_logical_replication_slot('test_logical', 'test_decoding');
> -[ RECORD 1 ]-----------
> slot_name | test_logical
> lsn       | 1/C7C59E0
>
> Time: 37658.725 ms (00:37.659)
>
>
> Even with activity on primary the creation of the logical replication 
> slot took ~38s. Can we do something related to it or should we need to 
> clarify even more the documentation?
>
For the logical slot creation on the standby, as we can not do WAL 
writes, we have to wait for xl_running_xact to be logged on the primary 
and be replayed on the standby.

So we are somehow dependent on the checkpoints on the primary and 
LOG_SNAPSHOT_INTERVAL_MS.

If we want to get rid of this, what i could think of is the standby 
having to ask the primary to log a standby snapshot (until we get one we 
are happy with).

Or, we may just want to mention in the doc:

+     For a logical slot to be created, it builds a historic snapshot, 
for which
+     information of all the currently running transactions is essential. On
+     primary, this information is available, but on standby, this 
information
+     has to be obtained from primary. So, creating a logical slot on 
standby
+     may take a noticeable time.

Instead of:

+     For a logical slot to be created, it builds a historic snapshot, 
for which
+     information of all the currently running transactions is essential. On
+     primary, this information is available, but on standby, this 
information
+     has to be obtained from primary. So, slot creation may wait for some
+     activity to happen on the primary. If the primary is idle, creating a
+     logical slot on standby may take a noticeable time.

What do you think?

Thanks

Bertrand



view thread (196+ messages)  latest in thread

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: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Minimal logical decoding on standbys
  In-Reply-To: <[email protected]>

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

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