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 1tS7cK-00ECKd-N2 for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Dec 2024 04:43:01 +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 1tS7cJ-009qXC-PG for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Dec 2024 04:42:59 +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 1tS7cI-009qX3-Rx for pgsql-hackers@lists.postgresql.org; Mon, 30 Dec 2024 04:42:59 +0000 Received: from fhigh-a5-smtp.messagingengine.com ([103.168.172.156]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tS7cG-001CRj-2m for pgsql-hackers@lists.postgresql.org; Mon, 30 Dec 2024 04:42:57 +0000 Received: from phl-compute-09.internal (phl-compute-09.phl.internal [10.202.2.49]) by mailfhigh.phl.internal (Postfix) with ESMTP id 79EE41140152; Sun, 29 Dec 2024 23:42:55 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-09.internal (MEProxy); Sun, 29 Dec 2024 23:42:55 -0500 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=1735533775; x=1735620175; bh=i2LlgwQT0g Xt6cZhWRwSIRhz+zcWMhZTurIu45QX7kE=; b=um+JXx8MT1iuZ9lRRuaVFV7YDv jkXrVxXwxravogWZISfbYfSjQbpKR0WLZ88cDNpK4YDSXv30DWYIyAQKBLE1qrHE BDHPYzAts6Ps9MyGlBAvJMSzgDrslKshMn+WtO3glbv4+2M5n2EfVbMYqqIU1CoC WDT7JHr9dUfFefOCx8PcP2BAqIqUs5iigNEyX4yTU7ZE6Wk5WI88STCURF0NL+Ff Oh+90WScGDA9FBYv5KzgI+kkGnKmaJghAgo0PwgaZPYbNuOM5grQcOZdIv9vovsk ujU6eS6vau0ZKifj9QcHM/pYZL/0BUeg6nwVjDhRf2wvTX0TkBoccb1swNvA== 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= 1735533775; x=1735620175; bh=i2LlgwQT0gXt6cZhWRwSIRhz+zcWMhZTurI u45QX7kE=; b=qQx0nFQ0VZ6i6apOHToJjm8YFtNxcCWUkQB5KHS6i9wmPtILqNr dD+bk9LtAxTIZtACGESdmD1YCOAzUA00Ps2YRd/h+N/eA2KybmnB6+cR10qGYLdE 6e3nWvlmk1n+fF7hEQoHoLNzuaPUqTsb/g5KpwZEvDFkoj3kGHMdG/RmYl679pNH InUvrqee60XGoU09AtwhGbFR0YBa4XCX7rNfdDBJidSomVAqpGCA2w+QAN6vfEQz LNb8SRDDwC/aR8IKZ7eZnwm20GszU6az3oU1W+HquEk4Y5AtlQu323vJCMYInIvJ eC9SNBOIFnDwzzWcZZ17HOfCiFSgVNmbdnw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddruddvhedgjeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnegfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhf gggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruc eomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteel ieefudffhffhtdetleeggeegfffhkeeuveetiefgudduvedutefggeeivdejnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhes phgrqhhuihgvrhdrgiihiidpnhgspghrtghpthhtohepfedpmhhouggvpehsmhhtphhouh htpdhrtghpthhtohephhhouhiijhdrfhhnshhtsehfuhhjihhtshhurdgtohhmpdhrtghp thhtohepvhhighhnvghshhdvudesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqh hlqdhhrggtkhgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 29 Dec 2024 23:42:53 -0500 (EST) Date: Mon, 30 Dec 2024 13:42:31 +0900 From: Michael Paquier To: "Zhijie Hou (Fujitsu)" Cc: vignesh C , PostgreSQL Hackers Subject: Re: Memory leak in pg_logical_slot_{get,peek}_changes Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="3xxlJgLopjKscnmv" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --3xxlJgLopjKscnmv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Dec 27, 2024 at 08:13:53AM +0000, Zhijie Hou (Fujitsu) wrote: > Thanks for updating patches ! They look good to me. Fine by me as well. I had a bit of time today, so I've taken care of all this one down to 15 for now after checking each branch. + cachectx_mcallback = palloc0(sizeof(MemoryContextCallback)); + cachectx_mcallback->func = pgoutput_cachectx_reset_callback; + MemoryContextRegisterResetCallback(ctx->context, cachectx_mcallback); In the version of the patch for 14 and 13, why don't you just use a single reset callback to handle both of cachectx and pubctx at the same time? That would be simpler. +/* + * Private memory context for relation attribute map, created in + * PGOutputData->context when starting pgoutput, and set to NULL when its + * parent context is reset via a dedicated MemoryContextCallback. + */ +static MemoryContext cachectx = NULL; This comment block is a copy-paste of the previous one, let's just stick both declarations together. > Just to confirm, would the other stuff (streamed_txns) that allocated under > CacheMemoryContext also leaks memory ? I think it's OK to change them > separately if it does but just would like to confirm if there is a risk. Yeah, let's tackle this stuff separately and remove more the dependency to CacheMemoryContext. -- Michael --3xxlJgLopjKscnmv Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmdyJLcACgkQnvQgOdby QH0UDw/9HtyBErqqX3xV085Lr5wfU01BGOcbPi8/jwxetcKPIgiN7iFrKseRYKZM x0cBgle8Q42xggE7XzPYPlLLVHWy39vsN6vi/uAU5F8mD1fb9EQozm0al805Nw2+ +GeIErMMY/FCPwnW1+bYFMbBetIuO5gcKxxCpmFN/YupAketp6a7UwpuctSYiBRE Glzh8LAPauf7oIJQkbMWHEAqjJ44CgjZ4CCf/RYveC4YMykFQJ/KWLtRWcJjEWCl LT28QNrTGYIcUFpB5VQsfFl7Cn1rUqsClsBu8DYQ3Yir3BhDdiFOk3p4d2+UNvlB QNuMSi2XS33BLmhv4rYSlmGRAlsoMTmc9bWQV86/S30u2GJePh4eLenB+cbkvizr RhAyoLIysX6BVSIf9C8HIQAn+PBLf/QbjKG7vqjSvCyrbBLPikYRPLoxYceQZ9W0 Dy1sTNJfXE5D7/+aw/L/qClxCWX9gLrVAV9m7lWiNWKdvdvQhdnC9BOUKkFbIpGq 9wdqcu6u93ztBH9SIhMkk2r4cQmP4zAEk2tuwWTx49tSOl1AWw5iLyE0V2hhFYVc h3G3T0D75oDNGCAmMPxfafOuaqsiNPJ5VD6vCKAuBJdT+BQ9WQ/CYYaWaNInNlHP jKBGCPGDPQH/528El/1gD3IZxO82xdQgj+paLqBrhYxgth+wu9w= =grk9 -----END PGP SIGNATURE----- --3xxlJgLopjKscnmv--