Re: A proposal to provide a timeout option for CREATE_REPLICATION_SLOT/pg_create_logical_replication_slot

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: bharath(dot)rupireddyforpostgres(at)gmail(dot)com
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, chanderprabhjain95(at)gmail(dot)com
Subject: Re: A proposal to provide a timeout option for CREATE_REPLICATION_SLOT/pg_create_logical_replication_slot
Date: 2022-06-09 07:31:17
Message-ID: 20220609.163117.104235951156904748.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At Thu, 9 Jun 2022 10:25:06 +0530, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> wrote in
> Hi,
>
> Currently CREATE_REPLICATION_SLOT/pg_create_logical_replication_slot waits
> unboundedly if there are any in-progress write transactions [1]. The wait
> is for a reason actually i.e. for building an initial snapshot, but waiting
> unboundedly isn't good for usability of the command/function and when
> stuck, the callers will not have any information as to why.
>
> How about we provide a timeout for the command/function instead of letting
> them wait unboundedly? The behavior will be something like this - if the
> logical replication slot isn't created within this timeout, the
> command/function will fail.
>
> We could've asked callers to set statement_timeout before calling
> CREATE_REPLICATION_SLOT/pg_create_logical_replication_slot but that impacts
> the queries running in all other sessions and it may not be always possible
> to set this parameter just for the session that runs command
> CREATE_REPLICATION_SLOT.
>
> Thoughts?

How can the other sessions get affected by setting statement_timeout a
session? And "SET LOCAL" narrows the effect down to within a
transaction. I think that is sufficient. On the other hand,
CREATE_REPLICATION_SLOT doesn't honor statement_timeout, but honors
lock_timeout. (It's a bit strange but I would hardly go so far as to
say we should "fix" it..) If a program issues CREATE_REPLICATION_SLOT,
it's hard to believe that the same program cannot issue SET (for
lock_timeout) command as well.

When CREATE_REPLICATION_SLOT is called from a CREATE SUBSCRIPTION
command, the latter command itself honors statement_timeout and
disconnects the peer walsender. Thus, client_connection_check_interval
set on publisher side kills the walsender shortly after the
disconnection.

In short, I don't see much point in the timeout of the function/command.

As a general discussion on the timeout of functions/commands by a
parameter, I can only come up with pg_terminate_backend() for now, but
its timeout parameter not only determines timeout seconds but also
specifies whether the function waits for the process termination. That
functionality cannot be achieved by statement timeout. In that sense
it is a bit apart from pg_logical_replication_slot().

--
Kyotaro Horiguchi
NTT Open Source Software Center

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2022-06-09 07:49:01 Re: Improve TAP tests of pg_upgrade for cross-version tests
Previous Message Amit Kapila 2022-06-09 06:41:37 Re: A proposal to force-drop replication slots to make disabling async/sync standbys or logical replication faster in production environments