Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raiK4-00B6QH-Ji for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Feb 2024 20:27:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1raiK2-00FRQe-OX for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Feb 2024 20:27:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1raiK2-00FRQW-Ck for pgsql-hackers@lists.postgresql.org; Thu, 15 Feb 2024 20:27:06 +0000 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1raiJy-006w1R-CZ for pgsql-hackers@lists.postgresql.org; Thu, 15 Feb 2024 20:27:04 +0000 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2d0e520362cso14192261fa.2 for ; Thu, 15 Feb 2024 12:27:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1708028820; x=1708633620; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=DhiuFvPtdvfbY6Za6noOOktPWcLMNBh7I/Y16WwQEtw=; b=jJNNGbO71KtNoVosd2Dn9b/d1BTUnrII4yzfU9rGjkwT2zwVs0F4mhaV3k7RCPmthY 899OX4K6kYzS4LsN+iogAgqy7qhUkpmFX8ueRIClhxTMxGakYgP5m4ceLNkR3bS9EzyS CV0WhjwG+QI3/TVbVhu+KZTxMPsyiJ7nokERwxf/vMFxYH4G3kuJMTK58wUNrgTOK0j0 FCpPWe+nwieS9SxVirZ9F9PYJ1xM4C5u/QxnoUO7m6ZoavkwwG0uhUUvfsceolPc3lbX 9fggxKNlLglRmgBZ9XnFcsH/i6kv4EvbeRxm+rmmaAiOVHocpqQW85VIe9ZwtaRnGFCd Y2Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708028820; x=1708633620; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DhiuFvPtdvfbY6Za6noOOktPWcLMNBh7I/Y16WwQEtw=; b=tmr9Y5AJpY1WcwjF8zQAfBpILQPi+Yy1I2OIug3sT9wxdGJabQOaq+LECzW37Vp4pm PVE9bxWEfvkDupczqbE8tywHTKFflODJzTvre/ks7hZuX5nCDT83hAbMT8zeyIqJTtyF 8D3HdvPtU4+URRx44aF9nSHXlvciz1dVecQCLW97zYx80b/Wa6YBDOhiE7cUfIXqRNwq Z3o7D0/aKdzyEfIHS9pbO0rmTf/txNNVb5RGfGGxXlvwhIEH9Yeicne+M4bSvD3SCDV9 KmqXseJoxE7UBoc7ZCbTrHAPHoIpycRdUqdZp+uHZCuxokBFqxuhKewLJXmT9zknLcsE CO6A== X-Forwarded-Encrypted: i=1; AJvYcCV2RgTRPySPSfmRoed/F+ZQhcs2pOPjLN05HCRPEAPkxWlg3Wu7qMvbs1PIOOrU3e13c+5GFDEbuUgrja5Yn2N+d3Yc0FMjEkHnaBEJDYW/Zkwo X-Gm-Message-State: AOJu0YylPgx2z6YTrCpJY90V7JZWDVF9gCfIEvrWrytblTNC1mAp0hIS xGhUeFr7eoyAvdfNgIPJiubk5is02htX9k/lhy1G7V6yQ8qiSYnDysvp8jv0Bg== X-Google-Smtp-Source: AGHT+IHKPjgLyDVT7evrrFzoPqtslRlhGtTmK6j4MWZ8jw3isLhmBFmgBOvu1OQ2mZ1iXwjSUR7kLw== X-Received: by 2002:a2e:9dc2:0:b0:2d0:fa63:baad with SMTP id x2-20020a2e9dc2000000b002d0fa63baadmr2016292ljj.21.1708028820625; Thu, 15 Feb 2024 12:27:00 -0800 (PST) Received: from [10.137.0.18] (ip-86-49-229-30.bb.vodafone.cz. [86.49.229.30]) by smtp.gmail.com with ESMTPSA id dn23-20020a05600c655700b0040fafd84095sm163959wmb.41.2024.02.15.12.26.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Feb 2024 12:27:00 -0800 (PST) Message-ID: <241d6c00-7997-480f-80c1-636b28d457cf@enterprisedb.com> Date: Thu, 15 Feb 2024 21:26:59 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: logical decoding and replication of sequences, take 2 Content-Language: en-US To: Robert Haas Cc: Amit Kapila , Ashutosh Bapat , Dilip Kumar , "Hayato Kuroda (Fujitsu)" , "Zhijie Hou (Fujitsu)" , PostgreSQL Hackers , Masahiko Sawada , Peter Eisentraut References: <577ec4fc-62c5-cb4a-de0f-66dee8232d00@enterprisedb.com> <09613730-5ee9-4cc3-82d8-f089be90aa64@enterprisedb.com> <929a38f6-b9f9-4cc4-926a-ac972e769e17@enterprisedb.com> <996e4d3c-648a-46d0-86d2-6465f53ddc58@enterprisedb.com> <5bbadb71-b51e-45a1-9acc-d54f5e8850b6@enterprisedb.com> From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2/15/24 05:16, Robert Haas wrote: > On Wed, Feb 14, 2024 at 10:21 PM Tomas Vondra > wrote: >> The way I think about non-transactional sequence changes is as if they >> were tiny transactions that happen "fully" (including commit) at the LSN >> where the LSN change is logged. > > 100% this. > >> It does not mean we can arbitrarily reorder the changes, it only means >> the changes are applied as if they were independent transactions (but in >> the same order as they were executed originally). Both with respect to >> the other non-transactional changes, and to "commits" of other stuff. > > Right, this is very important and I agree completely. > > I'm feeling more confident about this now that I heard you say that > stuff -- this is really the key issue I've been worried about since I > first looked at this, and I wasn't sure that you were in agreement, > but it sounds like you are. I think we should (a) fix the locking bug > I found (but that can be independent of this patch) and (b) make sure > that this patch documents the points from the quoted material above so > that everyone who reads the code (and maybe tries to enhance it) is > clear on what the assumptions are. > > (I haven't checked whether it documents that stuff or not. I'm just > saying it should, because I think it's a subtlety that someone might > miss.) > Thanks for thinking about these issues with reordering events. Good we seem to be in agreement and that you feel more confident about this. I'll check if there's a good place to document this. For me, the part that I feel most uneasy about is the decoding while the snapshot is still being built (and can flip to consistent snapshot between the relfilenode creation and sequence change, confusing the logic that decides which changes are transactional). It seems "a bit weird" that we either keep the "simple" logic that may end up with incorrect "non-transactional" result, but happens to then work fine because we immediately discard the change. But it still feels better than the alternative, which requires us to start decoding stuff (relfilenode creation) before building a proper snapshot is consistent, which we didn't do before - or at least not in this particular way. While I don't have a practical example where it would cause trouble now, I have a nagging feeling it might easily cause trouble in the future by making some new features harder to implement. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company