-
Notifications
You must be signed in to change notification settings - Fork 911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
**BROKEN** Could not subdaemon channel: Too many open files #4868
Comments
The "correct" way to fix this would be to change our We could use the |
So let me propose an internal library for closing /* Call at program init.
* This is needed in order to open an `fd` "early" to
* a directory of open `fd`s:
* see #5 in https://stackoverflow.com/questions/899038/getting-the-highest-allocated-file-descriptor
* On systems where that is not necessary, this is a no-op.
*/
void closeallexcept_init(void);
/* Call after `fork`, in the child process.
* Closes all file descriptors except for those listed.
* The given set of `fd`s **must** be sorted in order
* from lowest to highest.
*/
void closeallexcept(int numfds, int fds_not_to_close[]); |
@ZmnSCPxj: Is there any reason you're not using |
Not all APIs expose And we do keep open some |
Whoa whoa whoa! So I was looking at our big nasty Lines 169 to 173 in 09459a9
@rustyrussell we hardcode a /* Dup any extra fds first */
while ((fd = va_arg(*ap, int *)) != NULL) {
int actual_fd = *fd;
/* If this were stdin, we moved it above! */
if (actual_fd == STDIN_FILENO)
actual_fd = stdin_is_now;
/* Move dev_disconnect_fd if it would be overwritten. */
if (fdnum == dev_disconnect_fd) {
int new_fd = dup(dev_disconnect_fd);
if (new_fd < 0)
goto child_errno_fail;
close(dev_disconnect_fd);
dev_disconnect_fd = new_fd;
}
if (!move_fd(actual_fd, fdnum))
goto child_errno_fail;
fdnum++;
}
/* Move dev_disconnect_fd as well. */
if (dev_disconnect_fd != -1) {
if (dev_disconnect_fd != fdnum) {
if (!move_fd(dev_disconnect_fd, fdnum))
goto child_errno_fail;
dev_disconnect_fd = fdnum;
}
fdnum++;
} Then the Actually come to think of it there is also the chance that So let me propose an alternate internal library for /* closefrom_compat_init
*
* Call at the start of a program before allocating any `fd`s.
*/
void closefrom_compat_init(void);
/* closefrom_compat_getfd
*
* The closefrom emulation may require an FD to be kept open.
* You may query this fd, for example if you are remapping FDs
* to specific numbers by dup2, you may want to check if
* this facility is using that specific number.
* @return -1 if the emulation requires no FD to be kept open,
* or the FD that needs to be kept open otherwise.
*/
int closefrom_compat_getfd(void);
/* closefrom_compat_remapfd
*
* The FD that needs to be kept open may occupy a number
* that is being remapped to via dup2.
* This call changes the FD number to a different one that
* is not currently in use.
*
* Precondition: closefrom_compat_getfd() should not
* have returned -1.
* Postcondition: closefrom_compat_getfd() will return a
* different value.
*/
void closefrom_compat_remapfd(void);
/* closefrom_compat
*
* Emulates the closefrom syscall as efficiently as possible
* on the system.
*
* @fromfd - The first fd to close, all other fds afterwards
* are also closed.
*/
void closefrom_compat(int fromfd); |
Another issue is this bit: lightning/ccan/ccan/pipecmd/pipecmd.c Lines 141 to 145 in 09459a9
This should also be adapted to use the Maybe make |
Hmm actually we do not need But So we really only need a |
Sent patches for |
For more information: ElementsProject#4868 Signed-off-by: ZmnSCPxj jxPCSnmZ <[email protected]>
For more information: ElementsProject#4868 Signed-off-by: ZmnSCPxj jxPCSnmZ <[email protected]>
Fixes: ElementsProject#4868 ChangeLog-Fixed: We now no longer self-limit the number of file descriptors (which limits the number of channels) in sufficiently modern systems, or where we can access `/proc`. We still self-limit on old systems where we cannot find the list of open files on `/proc`, so if you need > 1000 channels, upgrade or mount `/proc`.
For more information: ElementsProject#4868 Signed-off-by: ZmnSCPxj jxPCSnmZ <[email protected]>
Fixes: ElementsProject#4868 ChangeLog-Fixed: We now no longer self-limit the number of file descriptors (which limits the number of channels) in sufficiently modern systems, or where we can access `/proc` or `/dev/fd`. We still self-limit on old systems where we cannot find the list of open files on `/proc` or `/dev/fd`, so if you need > ~4000 channels, upgrade or mount `/proc`.
For more information: ElementsProject/lightning#4868 Signed-off-by: ZmnSCPxj jxPCSnmZ <[email protected]>
Fixes: ElementsProject#4868 ChangeLog-Fixed: We now no longer self-limit the number of file descriptors (which limits the number of channels) in sufficiently modern systems, or where we can access `/proc` or `/dev/fd`. We still self-limit on old systems where we cannot find the list of open files on `/proc` or `/dev/fd`, so if you need > ~4000 channels, upgrade or mount `/proc`.
Fixes: #4868 ChangeLog-Fixed: We now no longer self-limit the number of file descriptors (which limits the number of channels) in sufficiently modern systems, or where we can access `/proc` or `/dev/fd`. We still self-limit on old systems where we cannot find the list of open files on `/proc` or `/dev/fd`, so if you need > ~4000 channels, upgrade or mount `/proc`.
Issue and Steps to Reproduce
My node was exhibiting some erroneous behavior due to failing to launch subdaemons due to hitting the open file descriptor resource limit. I tried raising the limit using
ulimit
as suggested by @cdecker in #4534 (comment), but that had no effect. (Thelightningd
process still had both soft and hard limits of 1024 open files.) Come to find out, these limits are actually hardcoded inlightning/lightning.c
.Please implement a configuration option to override this insufficient limit.
Thanks to @TheBlueMatt for bringing the failure to my attention.
getinfo
outputThis is C-Lightning 0.10.1.
The text was updated successfully, but these errors were encountered: