Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oFuOu-0002Zm-9a for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Jul 2022 09:29:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oFuOt-0002Ba-40 for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Jul 2022 09:29:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oFuOs-0002BR-Ot for pgsql-hackers@lists.postgresql.org; Mon, 25 Jul 2022 09:29:18 +0000 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oFuOo-0001ad-BK for pgsql-hackers@lists.postgresql.org; Mon, 25 Jul 2022 09:29:17 +0000 Received: by mail-lf1-x131.google.com with SMTP id y11so17048547lfs.6 for ; Mon, 25 Jul 2022 02:29:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=OQu/R6IgpBcL4NKf3U83FXHrduvxccLCwPbJQrrGvJ4=; b=QI6Zk07D5Q6gBesIvZpHxTd49rOdWetQCtSH24z3PyVKtnynaHK7Hjw/OS9TVMtrlD B/FQxVj6cjqXzcE6oh7dPbjo8sZhO6Bo/T7yUmCJOS+ADaOeH3liqvS0T7tE9kn6OXar Vg9HQa6eciqHTFI3VdEHu4Ls2876DzxpUNlGNn3JY+bteaB/wns5iaEgtxvg3I+38114 xgc9AAQILAzGJCm2bCVawGHavMZaojJLZ6KR80/VsXOvMooigwKEDqc8q1mwm6paBeMG DbBgrkalpdy9njQRdqpmmIc5Djwia58fpnSwZU1hs7jf8jzabccarv0Ga87EblrexNpH RV1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=OQu/R6IgpBcL4NKf3U83FXHrduvxccLCwPbJQrrGvJ4=; b=Tz4XcgrfuhutFaBT4OukFYNa6MZQK19q3z8YqmxJHwmCNLSOj2AeCCeQv5yinVMD12 zF+2Jr2MMxSfW8Kk9aQmR+Mh0oTuNvS+Mue945Bepg0tzq3vhsu7e/ZLwY19a9D9auG7 ike8/xi+QGnWrjStPRm734oE0nfDVXbeTRSNOxRVrKvWFsAa+tds87lG+4w/qgxYUx2I tPt98SxWzZwH7rAB0c3wDh65WsLlos2b0n/5baX1pdGjqLtmudMNSAnFbQXSRi3T5/JM dmR41oPOjQsM0KSoKVSjkacQj+Q8O7m8/lecOc8qobhc6SnlcYgaF3sQV2YuSkyowwm2 Z/Rw== X-Gm-Message-State: AJIora89UmcEQ+OUCWhaRfJt46MV3cM1+JzISXE1ASxzehkNLA6m5+0X Ex8L9nIHESqVbpFuCUafiOcugOC7r+Nju35wLElYMOv1c60= X-Google-Smtp-Source: AGRyM1sXGvuj4BSs2F4P9yAleWBOfplVh955ZwrIv/jwNJehtlWONOcv310XvjZSkGjy+pJkCwCurmP/jalM33hSRM0= X-Received: by 2002:a05:6512:39cd:b0:489:c7a5:7a46 with SMTP id k13-20020a05651239cd00b00489c7a57a46mr4142098lfu.142.1658741352771; Mon, 25 Jul 2022 02:29:12 -0700 (PDT) MIME-Version: 1.0 References: <9290b55b6ae2b04e002ca9dadadd1cca09461482.camel@cybertec.at> <763B5AF0-1C9E-4796-9639-F969A2E66189@yandex-team.ru> <11FF616C-C78C-41AA-A823-E3D4E745ACE5@yandex-team.ru> In-Reply-To: <11FF616C-C78C-41AA-A823-E3D4E745ACE5@yandex-team.ru> From: Bharath Rupireddy Date: Mon, 25 Jul 2022 14:59:02 +0530 Message-ID: Subject: Re: An attempt to avoid locally-committed-but-not-replicated-to-standby-transactions in synchronous replication To: Andrey Borodin Cc: Dilip Kumar , Laurenz Albe , PostgreSQL Hackers , SATYANARAYANA NARLAPURAM Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, May 10, 2022 at 5:55 PM Andrey Borodin wrote= : > > > 10 =D0=BC=D0=B0=D1=8F 2022 =D0=B3., =D0=B2 12:59, Bharath Rupireddy =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0= =D0=BB(=D0=B0): > > > > If okay, I can make the GUC behave this way - value 0 existing > > behaviour i.e. no wait for sync repl ack, just process query cancels > > and proc die interrupts immediately; value -1 wait unboundedly for the > > ack; value > 0 wait for specified milliseconds for the ack. > +1 if we make -1 and 0 only valid values. > > > query cancels or proc die interrupts > > Please note, that typical HA tool would need to handle query cancels and = proc die interrupts differently. Hm, after thinking for a while, I tend to agree with the above approach - meaning, query cancel interrupt processing can completely be disabled in SyncRepWaitForLSN() and process proc die interrupt immediately, this approach requires no GUC as opposed to the proposed v1 patch upthread. However, it's good to see what other hackers think about this. > When the network is partitioned and somewhere standby is promoted you def= initely want infinite wait for cancels. Yet once upon a time you want to sh= utdown postgres without coredump - thus proc die needs to be processed. Agree. On Mon, May 9, 2022 at 4:39 PM Andrey Borodin wrote: > > > On 26 Apr 2022, at 11:26, Laurenz Albe wrote= : > > > > Is it worth adding additional complexity that is not a complete solutio= n? > > Its not additional complexity. It is removing additional complexity that = made sync rep interruptible. (But I'm surely talking not about GUCs like sy= nchronous_replication_naptime_before_cancel - wait of sync rep must be inde= finite until synchrous_commit\synchronous_standby_names are satisfied ) > > And yes, we need additional complexity - but in some other place. Transac= tion can also be locally committed in presence of a server crash. But this = another difficult problem. Crashed server must not allow data queries until= LSN of timeline end is successfully replicated to synchronous_standby_name= s. Hm, that needs to be done anyways. How about doing as proposed initially upthread [1]? Also, quoting the idea here [2]. Thoughts? [1] https://www.postgresql.org/message-id/CALj2ACUrOB59QaE6=3DjF2cFAyv1MR7f= zD8tr4YM5+OwEYG1SNzA@mail.gmail.com [2] 2) Wait for sync standbys to catch up upon restart after the crash or in the next txn after the old locally committed txn was canceled. One way to achieve this is to let the backend, that's making the first connection, wait for sync standbys to catch up in ClientAuthentication right after successful authentication. However, I'm not sure this is the best way to do it at this point. Regards, Bharath Rupireddy.