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 1wHA86-006urK-0D for pgsql-hackers@arkaria.postgresql.org; Mon, 27 Apr 2026 00:47:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wHA75-00BWOT-39 for pgsql-hackers@arkaria.postgresql.org; Mon, 27 Apr 2026 00:46:15 +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 1wHA75-00BWOI-0N for pgsql-hackers@lists.postgresql.org; Mon, 27 Apr 2026 00:46:15 +0000 Received: from fout-a2-smtp.messagingengine.com ([103.168.172.145]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wHA71-00000003Fex-2alo for pgsql-hackers@lists.postgresql.org; Mon, 27 Apr 2026 00:46:14 +0000 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id F0569EC01F3; Sun, 26 Apr 2026 20:46:08 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Sun, 26 Apr 2026 20:46:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1777250768; x=1777337168; bh=A9lu+K5Bl+ TzRG0EhQEY35co9z1ZiBzefh2XocpC698=; b=LNc0suF/2r9Ph6QpgUs+u+mDC/ ROkbMI6fRL72dlNKzNs0oj/ZrSNNsyUI8/6EPBCUU3N5gZVFt1BQJfRqbdICnICE cmkSOJSdfZUUys0CQYVi/zAkbtx98OPDVHHIpIYCsKXTw/SJUR9pZnYqrrPEWStn oy5iDP+iUlNgkvBnTdZt1SdB/JcU35vZL6Zchc8Jz30kSwpdXGbczYnK7V1DCOyL Zp2bR8jS4qQ6YlxwOJh/NeigREwQJitFMG6+fCYWztvwhGWAfOcV2qhsSyvkwNQb Ij+23npNLXqwuPNNQAL0xcwjjlXydBJjo+0NGeuk1DYiz5NkFNt+VRabFgtg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1777250768; x=1777337168; bh=A9lu+K5Bl+TzRG0EhQEY35co9z1ZiBzefh2 XocpC698=; b=kg1994Ossce8scgPNDC1WAW/mGzSaoQSdHyT09I9rwl+W+dsGd7 OQoTpmbSCQDvBqRVsZqLd9UGqnlrVXHCsSr+sPZVGzKW6Fuzku6fAm9zm+GebbUS fKrkN3mxdZmCgn9DRL/z2izbXfJdF0ukNZ1daFNcUTsuvhMdx1C3hWt0xKkrzaLq qiQAYwCjr+I1O1Ky5Yd5d6LZcr35PnlosrTzxhl0G5NMf8ZzV5ZGVCW4aUiYr/Pq ZT33XhU8h0wDnTAMF7oNOVQGlOx0fqUpTUPfhN42YR1AkQS7ZSLxlPd0dImEOUz0 QM91Vikzf45UkTWee8Y6IFa12g8sDLjh/gQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdejjedvjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecufghrlhcuvffnffculdefhedmnecujfgurhepfffhvfevuf fkfhggtggujgesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgv rhcuoehmihgthhgrvghlsehprghquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpe egffejvefgveduvdejtddvtdeijeehudeuledvudeftdfgfeejvdekveekiedvvdenucff ohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiih iidpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheptg hhrghrshihrghmsehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghk vghrsheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 26 Apr 2026 20:46:07 -0400 (EDT) Date: Mon, 27 Apr 2026 09:46:02 +0900 From: Michael Paquier To: DaeMyung Kang Cc: pgsql-hackers@lists.postgresql.org Subject: Re: [PATCH] Fix memory leak of reply_message in walreceiver Message-ID: References: <20260426170100.847923-1-charsyam@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="WI7CiYpRJr05weyx" Content-Disposition: inline In-Reply-To: <20260426170100.847923-1-charsyam@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --WI7CiYpRJr05weyx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Apr 27, 2026 at 01:59:09AM +0900, DaeMyung Kang wrote: > initStringInfo() unconditionally allocates a fresh ~1KB buffer with > palloc() and overwrites the existing data pointer without freeing the > previous one. So every time the walreceiver re-enters the streaming > path -- e.g., after a timeline switch, end-of-WAL, or any other > condition that drives the outer for(;;) loop to iterate -- the prior > buffer is leaked. The leak is bounded per streaming restart but > accumulates over the lifetime of a long-running standby that > restarts streaming often. This is a problem similar to [1], and I'd agree about cleaning that up properly. > This appears to date back to commit add6c3179a4 ("Make the streaming > replication protocol messages architecture-independent.", 2012), so > the fix is likely a candidate for back-patching to all supported > branches. This is minor, so I don't really see a point in back-patching. Same reason as the other thread. I'll go merge that together. [1]: https://www.postgresql.org/message-id/ae6vp9L-GUb0ERTF@paquier.xyz -- Michael --WI7CiYpRJr05weyx Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmnuscoACgkQnvQgOdby QH3ANA//YXZQMP2ZV077+XoIIEKSu4kVsEMsEGV+O2UKM2ZZM61hrW4rNDqfNU/o 2KoSbUh8Vie8ZBu9+Stw2JS2MVMSCZDsz66n4Rl6Dri87Icg7r2Las9+1OoCGgc/ BmN2IFegJke3+sx1Qqruwi5FQ0+NqfQOlW18sfK3/9laDPGNxA/KOVAVVd4Wy7TE hgI8Yr46HqAFAW9D/slCvN0KgBjodhq78BO0xUqjPyVEWU4k5i9KcS0nDiCJ+6aC PapyA3PgG9zSyRX15668XA1R1lPimOQk7lIQ1AxIkX9i5Is5+XiSpMQS0xZtFFj2 naTkxnRWjYfzDeMR0foxBMDZR8VMkhtQvVB/4h5EGfhs8LyBNpNmLyNus4iEc+3H s5hfDwOP5ARiG8+71S7dYY8d6gPYs+5HfwxUZDwSZSDfJdAkAFE5D4upLXbLRbdN SB3MLdh+gLZ9q9UPTIJs3ZLNPyVFZD+HM1+3BGj752j5ZKXXSaHsaEAULcmcArLJ q5RR26CAXOZrOADHkF7y9yWX5vojJo5eLCKMwgysj/eoDtwsTqLfM0svtTJvI+3U jyFnwkQtkVqPMiiV0QRzIyB45jvpx+eGVHKMqZ4J7K2FxVy78Q26mxCeBXMKgTPL w5C0O+O1OfzWlv2EoCCg5mhyBjoOphn+eDwxVDNYUNJDCEMgAaQ= =Iwly -----END PGP SIGNATURE----- --WI7CiYpRJr05weyx--