-
Notifications
You must be signed in to change notification settings - Fork 184
add note about Unix.select and "Invalid argument" errors #222
Description
Please update the manual to mention that if you see an Invalid argument' onUnix.select' it means that this 1024 file descriptor limit was exceeded:
"libev is used by default on Unix, because it supports any number of file descriptors while Unix.select supports only 1024 at most, and is also much more efficient. "
Background:
Just hit the problem described here with Ocsigenserver: http://blog.mashape.com/scaling-up-api-proxy-ocaml/:
Mar 11 16:18:04: main: Fatal - select(): Invalid argument
(and sometimes it would fail with Unix_error 12, which would be ENOMEM).
The problem was that lwt wasn't built with libev, and it falled back to Unix.select.
If you google for EINVAL on select you usually see that the timeout argument might be wrong, but that was not my case.
OCaml's Unix.select also fails with EINVAL if the maximum file descriptor number exceeds FD_SET_SIZE (1024 on Linux), which I found out by looking at its source code.
I was running my app inside a Docker container, where the default ulimit -n is 1048576, so although ocsigen would only accept 350 connections by default, some file descriptor numbers would exceed 1024 (even if it didn't actually try to poll more than 1024 at a time), and cause this error.
Switching to libev solved all these problems.