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 1vYMYv-001k5X-2w for pgsql-hackers@arkaria.postgresql.org; Wed, 24 Dec 2025 10:57: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 1vYMYt-004OnJ-2I for pgsql-hackers@arkaria.postgresql.org; Wed, 24 Dec 2025 10:57:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vYMYt-004OnB-1J for pgsql-hackers@lists.postgresql.org; Wed, 24 Dec 2025 10:57:48 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vYMYr-002UnA-1Q for pgsql-hackers@lists.postgresql.org; Wed, 24 Dec 2025 10:57:47 +0000 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-42fb0fc5aa4so4632207f8f.1 for ; Wed, 24 Dec 2025 02:57:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766573863; x=1767178663; 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=xKNfXqdAy0+zNG1KgIv2++N5O/osu3Tm1h2olGOMaII=; b=ROHalPfyE6voPiDyU8lzork154p9Tnvn4/P+yQOOn5yAFv90Ui2wJHtfZFrO2suKUs ZKn3h0904kOSx0RYccBsv3oCLBxaeuvzv3wLK3hnyeWvpzUIcoL8M4B7bUHLG530/8+p 1N1HJw1t7HBHPDnu0rZC1B6sFfHnoMmADuJIDt+KnKkPTtVMvAEmgqEKMA3/6gz6hF7Q 0MG7ikP9rIw1yyNMYbhvxBZrdaSpMuwznTJwLZbLMZev9m0iKX7f2WphV9Qc3xQe5APP vw3WV2snpTx/b3DBwer5Z6J9cOegjup/iMGXDG4JCIwYab1p8YXeFd11WHgZOTY8LOuP kNAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766573863; x=1767178663; 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=xKNfXqdAy0+zNG1KgIv2++N5O/osu3Tm1h2olGOMaII=; b=P3sBp8LSxmxLenr8kVb+/eFNfEXK37iCN4/u+JjQdj22MgrsD5ftoimkPQlqB1DeZ4 m0y9/QLlHoJqhbOrvexh58pYJ4C23toRhoYk0P7ZRTvEk083iz3Hs4yEktfErb/SHJvq mjcVbek1P6o0dWqkKmCUOYHkyWd5KP7eNBNAOEdevsejyhtXgJFO1LLhtI6uHffUUMKz Q1xhQgCgP/EUSxdroEguFAYS++SMUgZrwfL+DIrJp5wms/qx6ZvCt9NMrWiowEwS4J+1 /wUxVJcY2lCcpcBEcPYSR4LWynFiU7LvsBRPH8aUs59bz3NRw9ef6sLa8gcPdS6J1tEG R27w== X-Gm-Message-State: AOJu0YznSQm7xfg+JZUhZOrHnI6F+OWBiKSZgOhgb7iMDJVlrDfonHX8 EA8GXXErR76aMSVMA/AG7a/+DNtTiLKC310r/BgLrTnM7O9RSKxwbjflerXqpvnExfS/tcYoFO0 7BBvC5iKw4wlevBBCsIAQtR1xPgtXQgdRbH7B X-Gm-Gg: AY/fxX7KJgyKJK4cDcX7YHBs2mxRKSmP7WfuSa5RL2QEFoCZa+4czHBxxV4RWIGwft2 pFzWV7Qiz/ZoYvb6l/YbQkV8PPZdE1kYMX/QbMGw9Ge8F3yzhvM8H3HaSaK78B5WzN10NmWRU4z fLzyeu40wAg1ryyoLwf47wxzuzkmMpeVPSpEWRHjp9lTUzw0Dr7S6hSSe7xhAKket+Cx85EVN1m eKULtUE17R3nXtRJKrIeSDG1MNFZqhtkwHwESwsBW/BmDz3WSKe0xy1V194IOh+6tFS0vzy X-Google-Smtp-Source: AGHT+IGxxJLgTPvn0Ldr23VBFw7fO3k+RZz3D5uEYhGIjU/qaZkopHPlpJoLUJFLZBcdbpo6z9zL3tjR5e5lhDM6jMw= X-Received: by 2002:a5d:5442:0:b0:432:7068:18a with SMTP id ffacd0b85a97d-43270680252mr2771321f8f.20.1766573862741; Wed, 24 Dec 2025 02:57:42 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Ashutosh Bapat Date: Wed, 24 Dec 2025 16:27:29 +0530 X-Gm-Features: AQt7F2qsNaxyKmo7WP4REipL6Gy_98r8cD7oDOPlPXgjZADrPtkbDvQ1YwfbHPQ Message-ID: Subject: Re: Refactor replication origin state reset helpers To: Chao Li Cc: 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 Wed, Dec 24, 2025 at 6:58=E2=80=AFAM Chao Li wr= ote: > > Hi Hacker, > > While reviewing patches [1] and [2], I noticed some duplicate code of cle= aring replication origin states, I am proposing a small patch that removes = the duplicate code blocks by introducing a couple helper functions. No func= tional change at all. > The new functions bring together the global variables that need to be reset under certain conditions. The functions will help not to miss resetting some variable. However, this can be a mild backpatching pain. So, I am +.5 on this. If we go this route, we at least need to declare the new functions as static inline and move them to a header file instead of .c file. Further, does it make sense to put together all the state variables into a single structure? It's also quite easy to confuse between these functions and replorigin_session_reset(). It's not clear where the boundaries of the latter end and where those of the new ones start. I think the latter deals with the shared memory structures while the new ones deal with the backend local state. And then there's replorigin_reset() which adds to the confusion. That function doesn't call replorigin_session_reset() which the other two callers of replorigin_session_clear_state() call. Why? I think there is more to clean here than what's in the patch. That doesn't mean that we cannot accept this patch without larger cleanup, but it should not add to the existing confusion. --=20 Best Wishes, Ashutosh Bapat