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 1myOxf-00015q-K8 for pgsql-hackers@arkaria.postgresql.org; Sat, 18 Dec 2021 01:56: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 1myOxe-00048v-Dt for pgsql-hackers@arkaria.postgresql.org; Sat, 18 Dec 2021 01:56: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 1myOxe-00048m-4V for pgsql-hackers@lists.postgresql.org; Sat, 18 Dec 2021 01:56:34 +0000 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1myOxb-0004Zw-IP for pgsql-hackers@lists.postgresql.org; Sat, 18 Dec 2021 01:56:33 +0000 Received: by mail-ed1-x52f.google.com with SMTP id j21so10059243edt.9 for ; Fri, 17 Dec 2021 17:56:31 -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 :from:to:cc:references:in-reply-to:content-transfer-encoding; bh=DvAtwCVlaPVdOCJmM6icVLXw8wLxY8cTESHBLyYhvGY=; b=Pso0177SO+h/WDTpgl2fYThffVPAKLkaaVhTQ2Sa3yrWWfDYRGqw6BpZSqyzJ+wyj8 7Zhn52FJ1HXqSqIuNpJuzG6rYf+/HIjsmpNeEBmG0AA8tOvQBVIWVPFglfDJX/u4/q7E tcA/I/zjsQp0pHVAn1ryAhcS2uEiUSP/EKbs8OPd5fodIB2GCTMKZ8IOezS624xs438F 6kWaNne3/9rmZ4qgxZnsf5GaouXhV/bUcno2rCGkrTwl+Z62HP5npQ2vQMcDawxkfibw EmsXobV7QfvpQec/4Jaa6NuoEZu1o9G3vFFTC7/KE0RqHq/UugCpYxK+QzZo3zjWg2xg i1hA== 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:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=DvAtwCVlaPVdOCJmM6icVLXw8wLxY8cTESHBLyYhvGY=; b=53Etltwo+j/1bMMuwenKsrveuQi3YjlIq398IjMf6pENEHxjMHR+AjgezrT/YmIiKh VdW5mV4oL6TkuKghd0kD/K3xth2jiqdAuePakRaAIwSxMzDQ+gsBtDQ0ZpbuwQVBjx+V foaIdgovrv/YlT/QR2FTC7PTFhSNLrxQEnx+fNw83uELkJ2pcUIF2qwPDFjizYeiVSee Tl9LCTlyIfWW7OviwN/TTov2/By4BAPMBLu3w/IKqESQ/kjuSLR6Dgo/d3eLBrJ1wJx+ 0kz2bCXdLlqMWvJ/batHIS0kUp47UGjKK1fy1f/SlHgr2Mq3Qc+jF/kHzq0LzoeU+vcf c4Gw== X-Gm-Message-State: AOAM530JEyuw+pShZWWEgf0OUR4cxXF7J6qWXiDrEogawWPA2CZ1QibX xtmfuMeLXmfYbWmZa5fNAxTrIOWiMBgWioFevDPadNDydkrZ+WZhfMWxdJ05oa/GbL+RNN8Tvpl 7emth0DD7vFF9vBIBfPIMAr3voA4esuCwFTTagieYtZaBQREHKc4AoLqmzei0cFU5kplgsU4x79 WOJ9jEy6gCvewYQ6kJmVwDSAeyLdta4sTFrmx93KO30Z0Xgo4aKfGb X-Google-Smtp-Source: ABdhPJx8VYIXM6eQPBnPEyyaCfZjNVea2j0M6Mj60s928GIbgK7w5vtHGM21z6vtPHCrO0QP3RYwQw== X-Received: by 2002:a17:906:5948:: with SMTP id g8mr4600432ejr.4.1639792589876; Fri, 17 Dec 2021 17:56:29 -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 g9sm4264977edb.52.2021.12.17.17.56.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Dec 2021 17:56:29 -0800 (PST) Message-ID: <90b4e402-3f07-14f4-deca-5eaca31f70a3@enterprisedb.com> Date: Sat, 18 Dec 2021 02:56:26 +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: logical decoding and replication of sequences Content-Language: en-US From: Tomas Vondra To: Amit Kapila Cc: Peter Eisentraut , PostgreSQL Hackers , Petr Jelinek References: <3005299b-267d-8e4a-68a3-abdad3e96aba@enterprisedb.com> <3d6df331-5532-6848-eb45-344b265e0238@enterprisedb.com> <482c10c1-b110-819f-b0e7-17549fa2f0dc@enterprisedb.com> <12a9ecd6-4edb-a367-33da-4e2d03b0aace@enterprisedb.com> <2cd38bab-c874-8e0b-98e7-d9abaaf9806a@enterprisedb.com> <118b249f-e4ef-2faf-8e25-dd25236dc964@enterprisedb.com> 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/15/21 14:51, Tomas Vondra wrote: > On 12/15/21 14:20, Amit Kapila wrote: >> On Tue, Dec 14, 2021 at 7:02 AM Tomas Vondra >> wrote: >>> >>> Hi, >>> >>> here's an updated version of the patches, dealing with almost all of the >>> issues (at least in the 0001 and 0002 parts). The main changes: >>> >>> 1) I've removed the 'created' flag from fill_seq_with_data, as >>> discussed. I don't think it's needed by any of the parts (not even 0003, >>> AFAICS). We still need it in xl_seq_rec, though. >>> >>> 2) GetCurrentTransactionId() added to sequence.c are called only with >>> wal_level=logical, to minimize the overhead. >>> >>> >>> There's still one remaining problem, that I already explained in [1]. >>> The problem is that with this: >>> >>> BEGIN; >>> SELECT nextval('s') FROM generate_series(1,100); >>> ROLLBACK; >>> >>> >>> The root cause is that pg_current_wal_lsn() uses the LogwrtResult.Write, >>> which is updated by XLogFlush() - but only in RecordTransactionCommit. >>> Which makes sense, because only the committed stuff is "visible". >>> >>> But the non-transactional behavior of sequence decoding disagrees with >>> this, because now some of the changes from aborted transactions may be >>> replicated. Which means the wait_for_catchup() ends up not waiting for >>> the sequence change to be replicated. This is an issue for tests in >>> patch 0003, at least. >>> >>> My concern is this actually affects other places waiting for things >>> getting replicated :-/ >>> >> >> By any chance, will this impact synchronous replication as well which >> waits for commits to be replicated? >> > > Physical or logical replication? Physical is certainly not replicated. > Actually, I take that back. It does affect physical (sync) replication just as well, and I think it might be considered a data loss issue. I started a new thread to discuss that, so that it's not buried in this thread about logical replication. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company