Re: Avoiding data loss with synchronous replication

From: "Bossart, Nathan" <bossartn(at)amazon(dot)com>
To: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, Andres Freund <andres(at)anarazel(dot)de>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Avoiding data loss with synchronous replication
Date: 2021-07-26 17:08:52
Message-ID: 56C86A75-664C-4627-9E2A-5C492DC779BB@amazon.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 7/24/21, 3:54 AM, "Andrey Borodin" <x4mmm(at)yandex-team(dot)ru> wrote:
> Let's clearly enumerate problems of blocking.
> It's been mentioned that backend is not responsive when cancelation is blocked. But on the contrary, it's very responsive.

It is responsive in the sense that it emits a WARNING to the client
whose backend received the request. However, it is still not
responsive in other aspects. The backend won't take the requested
action, and if the action was requested via
pg_cancel/terminate_backend(), no useful feedback is provided to the
user to explain why it is blocked.

> Semantics of cancelation assumes correct query interruption. This is not possible already when we committed locally. There cannot be any correct cancelation. And I don't think it worth to add incorrect cancelation.

The latest version of the block-cancels patch that I've seen still
allows you to cancel things if you really want to. For example, you
can completely turn off synchronous replication by unsetting
synchronous_standby_names. Alternatively, you could store the value
of the new block-cancels parameter in shared memory and simply turn
that off to allow cancellations to proceed. In either case, a user is
forced to change the settings for the whole server. I think allowing
users to target a specific synchronous replication wait is useful.
Even if I want to block canceling waits for most queries, perhaps I am
okay with unblocking an administrative session that is stuck trying to
update a password (although that could also be achieved by remembering
to set synchronous_commit = local).

What do you think about allowing multiple sets of behavior with the
new parameter? The "always allow" value would make things work just
like they do today. The "when specifically requested" value would
allow users to use a new mechanism (perhaps new signals) to
intentionally cancel synchronous replication waits. And the "always
block" value would disallow blocking such waits without altering the
server-wide settings.

Nathan

Attachment Content-Type Size
fig1.jpg image/jpeg 86.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2021-07-26 17:11:31 Re: when the startup process doesn't (logging startup delays)
Previous Message Simon Riggs 2021-07-26 17:01:19 Re: Skip temporary table schema name from explain-verbose output.