Re: File descriptors inherited by restore_command - Mailing list pgsql-hackers

From Tom Lane
Subject Re: File descriptors inherited by restore_command
Date
Msg-id 28722.1561124732@sss.pgh.pa.us
Whole thread Raw
In response to File descriptors inherited by restore_command  (David Steele <david@pgmasters.net>)
Responses Re: File descriptors inherited by restore_command
List pgsql-hackers
David Steele <david@pgmasters.net> writes:
> While investigating "Too many open files" errors reported in our
> parallel restore_command I noticed that the restore_command can inherit
> quite a lot of fds from the recovery process.  This limits the number of
> fds available in the restore_command depending on the setting of system
> nofile and Postgres max_files_per_process.

Hm.  Presumably you could hit the same issue with things like COPY FROM
PROGRAM.  And the only reason the archiver doesn't hit it is it never
opens many files to begin with.

> I was wondering if we should consider closing these fds before calling
> restore_command?  It seems like we could do this by forking first or by
> setting FD_CLOEXEC using fcntl() or O_CLOEXEC on open() where available.

+1 for using O_CLOEXEC on machines that have it.  I don't think I want to
jump through hoops for machines that don't have it --- POSIX has required
it for some time, so there should be few machines in that category.

            regards, tom lane



pgsql-hackers by date:

Previous
From: David Steele
Date:
Subject: File descriptors inherited by restore_command
Next
From: ilmari@ilmari.org (Dagfinn Ilmari Mannsåker)
Date:
Subject: Re: using explicit_bzero