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 1w3HIX-0014ZO-0V for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Mar 2026 17:36:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w3HHW-001VMj-0b for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Mar 2026 17:35:38 +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 1w3HHV-001VMP-2v for pgsql-hackers@lists.postgresql.org; Thu, 19 Mar 2026 17:35:38 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w3HHU-000000002ID-2ja9 for pgsql-hackers@lists.postgresql.org; Thu, 19 Mar 2026 17:35:37 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 62JHZYNM1305471; Thu, 19 Mar 2026 13:35:34 -0400 From: Tom Lane To: Jianghua Yang cc: pgsql-hackers@lists.postgresql.org Subject: Re: [PATCH] Fix fd leak in pg_dump compression backends when dup()+fdopen() fails In-reply-to: References: <62bbe34d-2315-4b42-b768-56d901aa83e1@gmail.com> <1302471.1773940095@sss.pgh.pa.us> Comments: In-reply-to Jianghua Yang message dated "Thu, 19 Mar 2026 10:19:10 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1305469.1773941734.1@sss.pgh.pa.us> Date: Thu, 19 Mar 2026 13:35:34 -0400 Message-ID: <1305470.1773941734@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Jianghua Yang writes: > That said, the patch does fix a real diagnostic problem. In the > original code, when dup() fails with EMFILE, the -1 return value is > passed directly to fdopen(), which fails with EBADF. The user sees: > pg_dump: error: could not open output file: Bad file descriptor > which is misleading -- the actual cause is fd exhaustion, not a bad > descriptor. With the patch, errno is preserved correctly, so the > message becomes: > pg_dump: error: could not open output file: Too many open files > which gives the user actionable information. Fair point. Still, this is such an unlikely edge-case that I don't think it's worth a back-patch. Let's just do HEAD. regards, tom lane