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.96) (envelope-from ) id 1vdrtV-005ve5-2n for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Jan 2026 15:25:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vdrtU-002g17-2c for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Jan 2026 15:25:49 +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.96) (envelope-from ) id 1vdrtU-002g0z-1f for pgsql-hackers@lists.postgresql.org; Thu, 08 Jan 2026 15:25:49 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vdrtT-004uGv-35 for pgsql-hackers@lists.postgresql.org; Thu, 08 Jan 2026 15:25:48 +0000 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-432777da980so1813663f8f.0 for ; Thu, 08 Jan 2026 07:25:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767885946; x=1768490746; 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=JeBZYcn1S0R5rv9ipFwYGbuQrGI5SJk3ppeH/2y3qMU=; b=F0jOkcvX9k2bSLONdbXNz5y5JoG/ykRB0cVaAlBrBeuc1n6JpO5mQTEZLMGEnquob+ ZsrTauGjofOvUiXq5R41+AhBVaZ6Zy9rAllNb4jrzCV87EAFaZDf6DohQfHscOX/MYUm 3jz4bFy8Atr7hWoX/oepq3DDji9kBytvHORUlcJJbADY0N+1lzFozxfwmsBKP4tJ39f5 xDer0u3YAQKEo75PA8Yz06XXRdhKPL5AAthh0NoXwQgDU7fXxO/KLlG+pm1WX79s5LG5 YantJlSf4Ty+3WcN4G8nWGKu4gvsve1q/KFE01T8VcL+y20dKwdb2vNIZJd1sOgmzRNG jjig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767885946; x=1768490746; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=JeBZYcn1S0R5rv9ipFwYGbuQrGI5SJk3ppeH/2y3qMU=; b=cr27Go4SKSiGi0lFl+zwExwJ9Q2Pcpo6TUj3OCPEPJvS6DYOim8mrhQKwuXMeX8Zan qnW4Vccya1eUm5aWgvpFX5rnZfN4XW62AJlhTbtJ1ifR26cSw1CiuwlxqzSujZbvC1z4 Oiy9/Tkzlv1Ot82JfkwKRWvm05ZZMD5fw+/faGsnEF/TjHLvhmkJLdK2opoDMUStAQiv k1ERyXor3h1BaXxHs6CtAmER4tTfPyfDeDQP958jlZVFpLb4vCWG7I0kaZs2tgXyYeC4 C4g9KavxbzJHHahfW5dm6i+B8t9c+s43e/0cXadlZbDg2pHjeLiExDq4+hlIz3Txh11e N42g== X-Forwarded-Encrypted: i=1; AJvYcCX8mMRwTOlhZJQF+jVIHzFY7Kr2F6lgC1LuUvppKkAf/Kz4StzHpqv1WhBlhiTUichBjhKisTIDA3Z3V348@lists.postgresql.org X-Gm-Message-State: AOJu0YxYQ+f9SCrxtNN7W6wg08T20h1PjYq7NOkNhIKiT2sQLwQ7AiTX 0oXkUXwdrzhADvwkcE4zNt33cCue79vnsuG3zOoVWQTG7OJ6YWTC0PO0vEVdQetz5pqmhMiPuvj 7i4ksmQ8kL2SXu677vOcQbxX5ahXhwLA= X-Gm-Gg: AY/fxX6i99Eu4thulCBnBJ43f0qlInFnd0298tF2DGfhAjnFIWh3jembMMrq4xEqBiH tTwT9PyI3cdhwEGwZ1S9MGxNEbajL/BtNAc/Kw8O0Sj78Y9uaxpB9uIYpMbFygGANwneAI9QSdP MsM7CJ5Zp2H7T2GyDaI/J02RcV8YXFKJa2Wfva4Zxv8ezKrT5Q4rVC+9EUEnoTPu33IpnTW/gPy CLriaqBuXkp8TbCYATD4i0AowDvKrMNbtSpwjB41ykaFFlRppRcZ0vWYp9ABy8HCeGr+K4V X-Google-Smtp-Source: AGHT+IHUj/s+bK6D4heatGZOYn7fTAINb4L++5NuB6DvMJ8+cCuwcpdVkmOvkZitcHRAaUgWbN2CwX5SuT/DvUw3sok= X-Received: by 2002:a05:6000:2409:b0:432:c07a:ee62 with SMTP id ffacd0b85a97d-432c3775b85mr9422296f8f.62.1767885946010; Thu, 08 Jan 2026 07:25:46 -0800 (PST) MIME-Version: 1.0 References: <202512291435.5edkf3hnichv@alvherre.pgsql> <26279DAC-5ADA-4E30-B866-5DED0EEC2BEF@gmail.com> <349AF48A-06DE-4016-B23A-F4A2834484C3@gmail.com> In-Reply-To: <349AF48A-06DE-4016-B23A-F4A2834484C3@gmail.com> From: Ashutosh Bapat Date: Thu, 8 Jan 2026 20:55:32 +0530 X-Gm-Features: AQt7F2rwX4DNHIqxDqihPnTHinagThH85BPAnxvXcBbJi_Lks5YfFl_u9tddQ_s Message-ID: Subject: Re: Refactor replication origin state reset helpers To: Chao Li Cc: Masahiko Sawada , =?UTF-8?Q?=C3=81lvaro_Herrera?= , Postgres hackers 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 Thu, Jan 8, 2026 at 6:32=E2=80=AFPM Chao Li wro= te: > > > > > On Jan 8, 2026, at 17:44, Ashutosh Bapat = wrote: > > > > Hi Masahiko, > > > > Thanks for updating the patches. Here are some more comments. > > > > On Thu, Jan 8, 2026 at 7:17=E2=80=AFAM Masahiko Sawada wrote: > >> > >> On Wed, Jan 7, 2026 at 5:15=E2=80=AFPM Chao Li wrote: > >> > >> I've made some cosmetic changes to both patches (comments and the > >> commit messages). Please review them and let me know what you think. > > > > 0001 > > ------- > > > > +/* > > + * Clear session replication origin state. > > + * > > + * replorigin_session_origin is also cleared if clear_origin is set. > > + */ > > +void > > +replorigin_session_clear(bool clear_origin) > > +{ > > + replorigin_session_origin_lsn =3D InvalidXLogRecPtr; > > + replorigin_session_origin_timestamp =3D 0; > > + if (clear_origin) > > + replorigin_session_origin =3D InvalidRepOriginId; > > +} > > > > All the other replorigin_session_* functions deal with > > session_replication_state, but this function does not deal with it. I > > see that in the next patch this function has been renamed as > > replorigin_xact_clear() which seems more appropriate. Do you intend to > > squash these two patches when committing? > > > > @@ -1482,8 +1493,8 @@ pg_replication_origin_xact_reset(PG_FUNCTION_ARGS= ) > > { > > replorigin_check_prerequisites(true, false); > > - replorigin_session_origin_lsn =3D InvalidXLogRecPtr; > > - replorigin_session_origin_timestamp =3D 0; > > + /* Clear only origin_lsn and origin_timestamp */ > > + replorigin_session_clear(false); > > > > The comment can explain why we are not clearing > > replorigin_session_origin here. Something like "This function is > > cancel the effects of pg_replication_origin_xact_setup(), which only > > sets origin_lsn and origin_timestamp, so we only clear those two > > fields here.". > > > > Next comment does not apply to this patch, but the inconsistency I am > > speaking about becomes apparent now. This function resets the state > > setup by pg_replication_origin_xact_setup(), which checks for > > session_replication_state being non-NULL. So I expected > > pg_replication_origin_xact_reset() also to check for the same > > condition or at least Assert it. Why is it not doing so? > > Hi Ashutosh, > > Thanks for your follow-up review. > > IMO, we don=E2=80=99t have to no more on 0001. As 0002 is a big refactori= ng, where we group the 3 global variables into a structure and rename the h= elp function, 0001 can be considered as a preparation commit that does some= simple cleanup. So that, we can put main focus on the real refactoring in = 0002. > In that case at least the function name change should be part of 0001. --=20 Best Wishes, Ashutosh Bapat