createUnixDomainSocket: listen(unix, 5 -> 100)

This solves the error

    error: cannot connect to socket at '/nix/var/nix/daemon-socket/socket': Connection refused

on build farm systems that are loaded but operating normally.

I've seen this happen on an M1 mac running a loaded hercules-ci-agent.
Hercules CI uses multiple worker processes, which may connect to
the Nix daemon around the same time. It's not unthinkable that
the Nix daemon listening process isn't scheduled until after 6
workers try to connect, especially on a system under load with
many workers.

Is the increase safe?

The number is the number of connections that the kernel will buffer
while the listening process hasn't `accept`-ed them yet.
It did not - and will not - restrict the total number of daemon
forks that a client can create.

History

The number 5 has remained unchanged since the introduction in
nix-worker with 0130ef88ea in 2006.
This commit is contained in:
Robert Hensing 2022-05-26 10:53:06 +02:00
parent 762fa2b2ff
commit c156155239

View file

@ -1818,7 +1818,7 @@ AutoCloseFD createUnixDomainSocket(const Path & path, mode_t mode)
if (chmod(path.c_str(), mode) == -1) if (chmod(path.c_str(), mode) == -1)
throw SysError("changing permissions on '%1%'", path); throw SysError("changing permissions on '%1%'", path);
if (listen(fdSocket.get(), 5) == -1) if (listen(fdSocket.get(), 100) == -1)
throw SysError("cannot listen on socket '%1%'", path); throw SysError("cannot listen on socket '%1%'", path);
return fdSocket; return fdSocket;