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 1n0i03-0006b6-Ds for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Dec 2021 10:40:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n0i02-0002Vp-4z for pgsql-hackers@arkaria.postgresql.org; Fri, 24 Dec 2021 10:40:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n0i01-0002Vg-FL for pgsql-hackers@lists.postgresql.org; Fri, 24 Dec 2021 10:40:33 +0000 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1n0hzs-0006fW-VG for pgsql-hackers@lists.postgresql.org; Fri, 24 Dec 2021 10:40:32 +0000 Received: by mail-ed1-x531.google.com with SMTP id bm14so31968779edb.5 for ; Fri, 24 Dec 2021 02:40:24 -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=F1+BmGIMqMloqGgzNHt4zV6whEpWg3Kh7UdYEXBAiz4=; b=MZGSGVESNvGUSpJjkNIq/8la/g8KT7s4CwbkqvqCv55ebXFczO+9MDIPejrM6SP8pd 0TXkOXLmR2h1rI0uZHv/iAoEaPoP3AM7ApeYnXxrgm8aweV1uZjOLFBUFaOKOSuUZ4cx 1shSzM4MkEySRJM87hWIavKFPexUcCUDZ81Ia97YEL3Ji6J0riuOv8Hgk90mb4lJv1Tx N2ZhZoZkuPWRCPxbBWnbjtfnFs4a32mxZce+rY+N8fO1nqW7VuYfOEiCRUNYdh6CsW3m 0n16wc6uCEQ8C8VaftMEkBtohQ2QoG04Ggm+LqRk6W44F8pqHhnp+V/tcPIwc6Zvlo4w Sh+g== 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=F1+BmGIMqMloqGgzNHt4zV6whEpWg3Kh7UdYEXBAiz4=; b=uRU7dyOWzd2Kcb+b4RZ1KPRDaHxLSztGyy84V10/ZDs907CQFOJjVBXADy55G5ErPd Yi4zJnzL6mLBZ1+uMdacVGts3ygJ4pok4kTxipTWI2sXMjkZb+BoibjQC2xuANuFyEmK F12gEZxdTMnboFt5gQuHIaEZ9idr0GtwfVvf8Mgk366LE6ZdEAiS4TQ0t4DQ4R8oA6li mAe9EyJNNuUu3CD9kvX1UCOy/72OFzswxMcm767kB7uBEKAROxLMRluyRxGReoWa6xUH G4ZrD9VHpXs7qWMTcY7IM99AOpQRMSFIAseskt+v8G70aYOQvObstk6TyFBaTZ4l3IxO iXbg== X-Gm-Message-State: AOAM5300d4HT0mebG0RGmOt+KW1zmW14+rWCyaTUIxKGJB68aPug0+cI yKXDgQ2mWxwzaujhtNM0SH+d5Yfyr4+/9oYMeTukBeae4hb3nBa6EdFksXhplc7zYYf6w4Uv/yh nhgJ+w9kmK2rU54ccTe5cWWNAoYXIwwI8EQrTCe9CZP6HtVbNuIY/F9GRKNe8o1KXdnUXELfPvi lyzBHGjrCgEZ5m8ODsz3M1tkHFlpvcWJCWMYF0OgZuIWb40XLpcUqo X-Google-Smtp-Source: ABdhPJynMJQM3foHCG1ozNy5HIBhf9GAkQ2iRsFCpHpnKK+v5DNGfP8YkdHxPE879gQ71yLASu7P1w== X-Received: by 2002:a17:906:3a03:: with SMTP id z3mr4946791eje.326.1640342422350; Fri, 24 Dec 2021 02:40:22 -0800 (PST) Received: from [10.137.0.18] (ip-89-177-29-12.net.upcbroadband.cz. [89.177.29.12]) by smtp.gmail.com with ESMTPSA id f5sm2535166ejl.219.2021.12.24.02.40.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Dec 2021 02:40:21 -0800 (PST) Message-ID: <27f005a6-63f7-2ca9-2ab3-92fe9110e224@enterprisedb.com> Date: Fri, 24 Dec 2021 11:40:20 +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: Kyotaro Horiguchi Cc: masao.fujii@oss.nttdata.com, tgl@sss.pgh.pa.us, peter.eisentraut@enterprisedb.com, pgsql-hackers@lists.postgresql.org References: <20211224.143725.1750248643492340056.horikyota.ntt@gmail.com> <20211224.170451.116141220257426861.horikyota.ntt@gmail.com> From: Tomas Vondra In-Reply-To: <20211224.170451.116141220257426861.horikyota.ntt@gmail.com> 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/24/21 09:04, Kyotaro Horiguchi wrote: >>> ... >>> So, strictly speaking, that is a violation of the constraint I >>> mentioned regardless whether the transaction is committed or >>> not. However we have technical limitations as below. >>> >> >> I don't follow. What violates what? >> >> If the transaction commits (and gets a confirmation from sync >> replica), the modified WAL logging prevents duplicate values. It does >> nothing for uncommitted transactions. Seems like an improvement to me. > > Sorry for the noise. I misunderstand that ROLLBACK is being changed to > rollback sequences. > No problem, this part of the code is certainly rather confusing due to several layers of caching and these WAL-logging optimizations. >> No idea. IMHO from the correctness / behavior point of view, the >> modified logging is an improvement. The only issue is the additional >> overhead, and I think the cache addresses that quite well. > > Now I understand the story here. > > I agree that the patch is improvment from the current behavior. > I agree that the overhead is eventually-nothing for WAL-emitting workloads. > OK, thanks. > Still, as Fujii-san concerns, I'm afraid that some people may suffer > the degradation the patch causes. I wonder it is acceptable to get > back the previous behavior by exposing SEQ_LOG_VALS itself or a > boolean to do that, as a 'not-recommended-to-use' variable. > Maybe, but what would such workload look like? Based on the tests I did, such workload probably can't generate any WAL. The amount of WAL added by the change is tiny, the regression is caused by having to flush WAL. The only plausible workload I can think of is just calling nextval, and the cache pretty much fixes that. FWIW I plan to explore the idea of looking at sequence page LSN, and flushing up to that position. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company