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 1mzqsY-0003wD-BM for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Dec 2021 01:57:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mzqsW-0003o0-LQ for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Dec 2021 01:57:16 +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 1mzqsV-0003nr-UR for pgsql-hackers@lists.postgresql.org; Wed, 22 Dec 2021 01:57:16 +0000 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mzqsO-0002hO-Fl for pgsql-hackers@lists.postgresql.org; Wed, 22 Dec 2021 01:57:14 +0000 Received: by mail-ed1-x533.google.com with SMTP id w16so2249730edc.11 for ; Tue, 21 Dec 2021 17:57:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=oivsInJmHSzVqBilRjv8VeNGuUx30KQRF1fiSQstMvY=; b=Eipk1Y0cSJbyMcarW+/wfzBetzpckhMJiA86Nr6uNKokm4f+wW+aFu9HAkJwq4Jxtf Ej6NCKVLN7k9UZh6LaQJIa4QDlTr9sFSLEIU3jR8HAAjTvPuhmJeaIVr/Q75+8hnQlaB W24gSHJlnBS+UPywkx7Nm4E/xmYi1seMMhw80ydrHb2zKksElPB9Sl7UIZhx3GVzghbl c/7KPvhxwkr7MJe2TSiLQMXDO2UC2LiAGYQMfH5hvjS6zGmJAbwNRR/43r7Hq2A3Lptn qSfmBrwI8k70CSqxlMgEzmTcFnAj/T8ZGp/6E46bk9By8jFhjtYAyU+nCTpfJ/1HhSDd mU0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=oivsInJmHSzVqBilRjv8VeNGuUx30KQRF1fiSQstMvY=; b=h92nrJ4yTyTwvIzZwk0tLIBqrFtqfGU8UBxYaAyU5LR5Bh3DUFITNnhla7jSAZ9M/E qbxaFmxyTPOAxh8yTmT0vJGrQybV65awab+sj8AqH2AGF9NLqHjKIPhoxWc9aHSoyKTt 4zftp7hQaNPL1+5QyjS6z5ykq6vAEnUQT4/AARl+7RJHMJy/juplFarDhtdfWlN1ybA5 lWMrkVJdBdnT3hMg4PFWSVC/RHWKaSLkhIVyXhx3MAfvPZGnkU0PNFSLyGcWxSDkLZbH ksSp8bkfiltGtF9i6zf3wNMD8KJfWxRKxHpzuxdV05i6D8Zf4ihDogvyfaLAOf/KjrKm v6tA== X-Gm-Message-State: AOAM533/qYrfk62qhxKGgxP4ms/xGpU2XFgHdMVzC8B7HhKh8aW9MS2a kYxkVaU5Oc58znmYfrSe14o/HTlsIUSfMYbOsVSTirWwGpQLJs8unWpj5GzfO0H/mDn4rEiMwhY b4Y+BkHtATx/90ahMQilOGUA6EpG30VthoV9fgrVoMK7qV/mmuCofQu5C47fz4U+w7EHDWHBDzg Qw1GZ/wDxcKC2oHDUnWdbWBqQ7NgvMsFbuHK+fEL723G8LaK+C7/oT X-Google-Smtp-Source: ABdhPJzNLi7X6spXa4aPuoDxQH/QAwZuz9AJ/3ZxydQePONOnqgKPucnOPCEmTgtrebnllHdkNWwPQ== X-Received: by 2002:a17:907:d07:: with SMTP id gn7mr782867ejc.575.1640138226693; Tue, 21 Dec 2021 17:57:06 -0800 (PST) Received: from [10.137.0.18] (ip-86-49-251-241.net.upcbroadband.cz. [86.49.251.241]) by smtp.gmail.com with ESMTPSA id nc14sm143681ejc.44.2021.12.21.17.57.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Dec 2021 17:57:06 -0800 (PST) Message-ID: <4450cd74-1a41-ec03-83ee-fcabc183715d@enterprisedb.com> Date: Wed, 22 Dec 2021 02:57:02 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: sequences vs. synchronous replication Content-Language: en-US To: Amit Kapila Cc: PostgreSQL Hackers References: <712cad46-a9c8-1389-aef8-faf0203c9be9@enterprisedb.com> From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 12/19/21 04:03, Amit Kapila wrote: > On Sat, Dec 18, 2021 at 7:24 AM Tomas Vondra > wrote: >> >> while working on logical decoding of sequences, I ran into an issue with >> nextval() in a transaction that rolls back, described in [1]. But after >> thinking about it a bit more (and chatting with Petr Jelinek), I think >> this issue affects physical sync replication too. >> >> Imagine you have a primary <-> sync_replica cluster, and you do this: >> >> CREATE SEQUENCE s; >> >> -- shutdown the sync replica >> >> BEGIN; >> SELECT nextval('s') FROM generate_series(1,50); >> ROLLBACK; >> >> BEGIN; >> SELECT nextval('s'); >> COMMIT; >> >> The natural expectation would be the COMMIT gets stuck, waiting for the >> sync replica (which is not running), right? But it does not. >> > > How about if we always WAL log the first sequence change in a transaction? > I've been thinking about doing something like this, but I think it would not have any significant advantages compared to using "SEQ_LOG_VALS 0". It would still have the same performance hit for plain nextval() calls, and there's no measurable impact on simple workloads that already write WAL in transactions even with SEQ_LOG_VALS 0. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company