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 1w3pWr-001aDJ-2P for pgsql-hackers@arkaria.postgresql.org; Sat, 21 Mar 2026 06:09:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w3pWp-00942l-0K for pgsql-hackers@arkaria.postgresql.org; Sat, 21 Mar 2026 06:09:43 +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 1w3pWo-00942d-2c for pgsql-hackers@lists.postgresql.org; Sat, 21 Mar 2026 06:09:43 +0000 Received: from fhigh-b5-smtp.messagingengine.com ([202.12.124.156]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w3pWm-00000000IWL-0CoI for pgsql-hackers@lists.postgresql.org; Sat, 21 Mar 2026 06:09:42 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.stl.internal (Postfix) with ESMTP id BDD4A7A00F0; Sat, 21 Mar 2026 02:09:37 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Sat, 21 Mar 2026 02:09:37 -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=fm1; t=1774073377; x=1774159777; bh=GBdFZbcVsD lpiTcuuz4yF+/GnlmimhK1BYhsmbkLZXo=; b=M86ZRLgZYzW+iiY5uCBbCYZeWu WJ2yfBPTmi19LatjGnEm4TM6kQ8e9s3UFUIxL0QyOTO0WhqELS/KiDNdhVoTMfoX Wq2bSi6mkww3Knn/X+KXpTz96rE+i2K2/YbDycfaR2hz9gqNZ0MVqvacfnh/qYF7 idKX0I/E7+si0iIK2vS+SZHf9E4ztHilPN6vFYqbHWrrOz4Q3MrPR4uAQUpdsNer d+iSTHzySYsCjhKKNpnmodSHnSpjExZFkelKO5R5fpg58rKxBIT1BB3X/co0QAfU SSVsQT0eBtC4fxG4KPHIMwfv/seXHdibR3eYhO9GgpnDk8aIfht8szS/DXHA== 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=fm1; t= 1774073377; x=1774159777; bh=GBdFZbcVsDlpiTcuuz4yF+/GnlmimhK1BYh smbkLZXo=; b=374sZIgTli+5yiaqw78YWu1vKs+xWOMUszenX6vS4EqoRMwkHp1 FENdlapgBIQiY2Gg4bLy2gSCpURl1haxbcwOnD62Ilykhh2Bd4d6jRp1xyoZLnOB y0CccJFkndhXgBSyNqp9zjDsKnJSZnGn9Lv9IXQmJoEFeAULL61AFHcinCDfuHBC kRKqM/GZWmVog4F0wcp5PSG1aQ+W9NB4bjx2sT/CAImWk/owAuh8WkOptBfBLfeZ wWHJsIiQ0fr3elM5bQQy4ewEfQpkKtsvOsUz3Yh1m6/X6mKgPrFWYcaVHZEVgOAS 7OlwmRHGt1wgeXO5cCGwQGhVWH7vDOZxyTQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdefuddvtdeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucgfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvve fukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhi vghruceomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnh epteelieefudffhffhtdetleeggeegfffhkeeuveetiefgudduvedutefggeeivdejnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrg gvlhesphgrqhhuihgvrhdrgiihiidpnhgspghrtghpthhtohepvddpmhhouggvpehsmhht phhouhhtpdhrtghpthhtohephihjhhhjshhtiiesghhmrghilhdrtghomhdprhgtphhtth hopehpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhr gh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 21 Mar 2026 02:09:36 -0400 (EDT) Date: Sat, 21 Mar 2026 15:09:31 +0900 From: Michael Paquier To: Jianghua Yang Cc: pgsql-hackers@lists.postgresql.org Subject: Re: basebackup: add missing deflateEnd() in gzip compression sink Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="KNqeq+VzndI3sMG5" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --KNqeq+VzndI3sMG5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Mar 20, 2026 at 10:02:44AM -0700, Jianghua Yang wrote: > While reviewing the backup compression backends, I noticed that the gzip > sink (basebackup_gzip.c) never calls deflateEnd(), unlike the lz4 and > zstd sinks which properly free their compression contexts. >=20 > This means each archive (one per tablespace) leaks ~256KB of zlib > internal state until the backup's memory context is destroyed. On the > ERROR path, the zlib context is not released at all since there is no > gzip-specific cleanup callback. Yes, you are right on this one. This code could be better in cleaning up the resources it is working on (and note that all the other gzip-related code paths call the end() part if doing an init() or an init2()). Leaking that once per archive may not look like a big deal, but this is backend-side code we are talking about, and on a persistent replication connection it is not really cool to lose the context of this data with garbage coming from zlib piling up, so based on the argument of the permanent connection my take is that this cleanup warrants a backpatch. -- Michael --KNqeq+VzndI3sMG5 Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmm+NhsACgkQnvQgOdby QH1efg//brMDfrjysgp/I7woT54gkvP5SXgNHpxb/LNske63jE3m20R2blYjsHrn ma5gXy5slgKA2l5b0nnDWFeDmb2Ii9g4ZEqfg3AqxdmKCcu5prCP6wSdD3GIU2ey cOfnvNQATTBcFrQTqOxG5KfCs2CqYfBUVa9RnjGxFyQRKRiykSyjO4SzorFRd7KQ uzyER2h2alNu2ITamNJ0ZHj5V+McqpyUPQeBpaNaYkQTmduvaMK51qXXZU12MxQl pjNVslCxmPHZif74Hk9ByyzAS1Y2eLPnxkAtxUT05gEdk5+/gQh9lTTEst8+97Iz 0R8ad6Ud8kE3875AmjOJUJMD+ZJkbx79tfxha9iQdVmQOeMzkHHB9+5GHEPMOCCe 4RAbQImafbrgp4avga5yqLznLE9/aLzpILQUXadvldeIvJV5TIMs5afAEkJiN8o9 O46taw6WfwxwOeV4k4wMvaUpUH4+QT8Mzt8vFEOfVmICj3yNTHjo3O4I+/FWQxUt Zi4Rz0sMxYwDMcQz+rP9dhctTdzTPmM5tuF8ZvbEXaJURviTMW6DQIPH7lrOIDgU 0EJzGQjwBj7DeMDbNnM/LTRzdOV28Q+bRWjPlUSj0J/SG18FaQx1uAURHd70CwcI tAcrrROhx3xrwv5+9FmhSYnD7hoo6Cjb5HTbn3UCZ+H57MCxVmw= =Z260 -----END PGP SIGNATURE----- --KNqeq+VzndI3sMG5--