Re: [PATCH] Fix fd leak in pg_dump compression backends when dup()+fdopen() fails
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jianghua Yang <yjhjstz@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2026-03-19T17:35:34Z
Lists: pgsql-hackers
Jianghua Yang <yjhjstz@gmail.com> 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
Commits
-
Avoid leaking duplicated file descriptors in corner cases.
- 8b02c22bb43c 19 (unreleased) landed
-
Fix expanding 'bounds' in pg_trgm's calc_word_similarity() function
- 18bcdb75d155 19 (unreleased) cited
-
Introduce a generic pg_dump compression API
- e9960732a961 16.0 cited