nix-community / lorri

Your project’s nix-env [maintainer=@Profpatsch,@nyarly]
Apache License 2.0
663 stars 24 forks source link

(fix) don't busywait when hitting file descriptor limit #26

Closed symphorien closed 3 years ago

symphorien commented 3 years ago

motivation: somehow I had lorri hitting the file descriptor limit and when it does it takes 100% of a cpu.

I might be better to review all possible error and just crash on some of them, instead of retrying in a loop.

Profpatsch commented 3 years ago

This shouldn’t happen;

https://github.com/nix-community/lorri/blob/90e34262d4b39e03fb382c8627a5b236451b8339/src/daemon/server.rs#L129-L164

should always join all threads as they are done.

How did you arrive in this state? Can you reproduce it? I’d rather crash I think.

Profpatsch commented 3 years ago

So it busy-looped because lorri was using all its assigned fds, and that made the client handler immediately fail on the accept in the listener:

https://github.com/nix-community/lorri/blob/90e34262d4b39e03fb382c8627a5b236451b8339/src/socket/communicate.rs#L155-L164

Which then spins in a busy loop because it will always fail on too many fds.

This sounds like maybe the watcher is watching too many files? But anyway, of course it should not lead to lorri busy-looping.

symphorien commented 3 years ago

It was when I was trying https://github.com/nix-community/lorri/pull/22#issuecomment-808914090 so it's probably my fault, but not sure.