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 1rch9V-001WaO-9k for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Feb 2024 07:36:25 +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 1rch9S-003Oe7-B9 for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Feb 2024 07:36:22 +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 1rch9S-003Odd-1i for pgsql-hackers@lists.postgresql.org; Wed, 21 Feb 2024 07:36:22 +0000 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rch9M-000EL8-7U for pgsql-hackers@lists.postgresql.org; Wed, 21 Feb 2024 07:36:20 +0000 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2d180d6bd32so71716251fa.1 for ; Tue, 20 Feb 2024 23:36:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708500975; x=1709105775; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=YKKKnfnkH9+wsA4TQLWkpWJ1QELqNtDoyq+IrwB1vo8=; b=ROksDYRJF8CG6gui8KD2K1QWtQfT73Czk0Ze3Ipwbr60vdghnU2EDKxb3ZrDQFRgjU oxkQNfui6ggmBNiDrmonJoevBRZfOIpmooNqUXS55tCGPAn02fx+5oag5KVe9g42a8b3 A6oCy1Vc4nY4rObofkQW/opCFHsZe+uL+13UZAGoaEVGrwY7kIU34Opgrk3yT8mpFTWQ o5iYkdgx0t5ZoAzng8mK98uUDA5MOTL09AY6Kf4HKauomTOaAAhaJAMQwVdztQHdEawh c2ma++gkSRqQJyzNwbptPati3Py1/z9FlBT/Y0HMgWaBRhgXfBlBd0342DSqKdVeudS4 cR+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708500975; x=1709105775; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YKKKnfnkH9+wsA4TQLWkpWJ1QELqNtDoyq+IrwB1vo8=; b=vb774w1/SjRD+YNVh3e3WwETFpKfzgFX2yQZjNcLq/U3K1KmZG/DaOdFHZjDS9QnzH TQ0WKpZbt2mWr9sytTVGMRvMmQRYWOe/6mXJi4ezrwQzXo3WoYPDiDiMSvXqZTM28kpW pkTNxdpSrOFvXlW434onddzE5d36uM2nOWNSB3fKrzbgO9qQIlAynt2VXILvdbI+CAyv rCst04sLfVenJwVkLudPZoh+DEcn1h89ngyurAc1YRQ39j7yiHSPuKrveZ+fnAXf0y0Z sOD6uYeB2GoBH0IMRnhXSt/LL9ifXp1zKz9vg2K4Y4PMW4O6wdtsU51sdHS9UPJdKBmz y00Q== X-Forwarded-Encrypted: i=1; AJvYcCXGpxNqNhhb/RZlh1cpKEm7yMcfD9on1KWrY0bdrunbu8lzfrtbE1tRrrhjlM5pI2lYoZPnMcsSPjtNxtAlcu065/lRX/3DcB+OeEy216dTILZs X-Gm-Message-State: AOJu0YxGXCx5NaZ/ug4IOv6QEsWydsGFEeK/mThGT/NvR23w3tEHT9+q VeBOUayCnpWJQz1ySLtPTFUIqPNWKOBz/7P5OWVeVaA1SwcSZgiZZIWwmS8ZNLYLaSggUB04YyK e3500uTcMFBXL+sBTVu4OMeRUIxw= X-Google-Smtp-Source: AGHT+IH0/FCgpr6ApPNg5W1d2SW3AclgSiRiWOiYATJyTr7q8OgpZKjZam1w7dpl1rsifIs97FjtbSA7fFCxuG1pjP8= X-Received: by 2002:a2e:b8c8:0:b0:2d0:c77c:b1ca with SMTP id s8-20020a2eb8c8000000b002d0c77cb1camr13341084ljp.49.1708500975232; Tue, 20 Feb 2024 23:36:15 -0800 (PST) MIME-Version: 1.0 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> <241d6c00-7997-480f-80c1-636b28d457cf@enterprisedb.com> In-Reply-To: From: Dilip Kumar Date: Wed, 21 Feb 2024 13:05:58 +0530 Message-ID: Subject: Re: logical decoding and replication of sequences, take 2 To: Robert Haas Cc: Tomas Vondra , Amit Kapila , Ashutosh Bapat , "Hayato Kuroda (Fujitsu)" , "Zhijie Hou (Fujitsu)" , PostgreSQL Hackers , Masahiko Sawada , Peter Eisentraut 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, Feb 20, 2024 at 4:32=E2=80=AFPM Dilip Kumar = wrote: > > On Tue, Feb 20, 2024 at 3:38=E2=80=AFPM Robert Haas wrote: > > > Let's say fast_forward is true. Then smgr_decode() is going to skip > > recording anything about the relfilenode, so we'll identify all > > sequence changes as non-transactional. But look at how this case is > > handled in seq_decode(): > > > > + if (ctx->fast_forward) > > + { > > + /* > > + * We need to set processing_required flag to notify the sequence > > + * change existence to the caller. Usually, the flag is set when > > + * either the COMMIT or ABORT records are decoded, but this must be > > + * turned on here because the non-transactional logical message is > > + * decoded without waiting for these records. > > + */ > > + if (!transactional) > > + ctx->processing_required =3D true; > > + > > + return; > > + } > > It appears that the 'processing_required' flag was introduced as part > of supporting upgrades for logical replication slots. Its purpose is > to determine whether a slot is fully caught up, meaning that there are > no pending decodable changes left before it can be upgraded. > > So now if some change was transactional but we have identified it as > non-transaction then we will mark this flag 'ctx->processing_required > =3D true;' so we temporarily set this flag incorrectly, but even if the > flag would have been correctly identified initially, it would have > been set again to true in the DecodeTXNNeedSkip() function regardless > of whether the transaction is committed or aborted. As a result, the > flag would eventually be set to 'true', and the behavior would align > with the intended logic. > > But I am wondering why this flag is always set to true in > DecodeTXNNeedSkip() irrespective of the commit or abort. Because the > aborted transactions are not supposed to be replayed? So if my > observation is correct that for the aborted transaction, this > shouldn't be set to true then we have a problem with sequence where we > are identifying the transactional changes as non-transaction changes > because now for transactional changes this should depend upon commit > status. I have checked this case with Amit Kapila. So it seems in the cases where we have sent the prepared transaction or streamed in-progress transaction we would need to send the abort also, and for that reason, we are setting 'ctx->processing_required' as true so that if these WALs are not streamed we do not allow upgrade of such slots. --=20 Regards, Dilip Kumar EnterpriseDB: http://www.enterprisedb.com