lichess-org/fishnet

broken pipe

LadyMarmelade opened this issue · 6 comments

This seems to be a known issue - i found several instances on the net - including a workaround:

fishnet says:
^Cthread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', library/std/src/io/stdio.rs:993:9
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

to reproduce:

sudo -u fishnet -H -s << EOF | tee -a fishlog
cd
./fishnet-x86_64-unknown-linux-gnu --auto-update
EOF

and then break (^C) out
please fixit

I suspect that ^C kills tee before fishnet shuts down, but fishnet still wants to write some more output.

As for an alternative, running it as a service with systemd (./fishnet-x86_64-unknown-linux-gnu --auto-update systemd to print a template) would give you a journal for free, and also make it easy to run fishnet as a specific unpriviliged user.

As for more gracefully handling the situation, I guess that could be done. But not logging the final lines will be kindof broken anyway.

Thanks so much. I am going with this workaround.

The following links show, that i was not the only one suffering from a problem possibly coming from a rust library:
nix-community/nix-index#69
rust-lang/rust#46016
https://www.reddit.com/r/rust/comments/akavh1/detect_closedinvalid_stdout/
https://willmurphyscode.net/2017/08/30/broken-pipe/

The problem in my case goes a hunch further: I am a retired old man running a huge server. i never install anything onto it, thus the fishnet is confined to a virtual machine. But i hate having to shut it down properly just to get hold of the log, thus i was using the construction shown above to push the log out of the VM. Now, using systemd, at least there wont be a problem with privilege to do so, only i would have to work this out on my own :-( (Delayed for now: it's christmas, after all)

Anyway: it turns out, i did not think about electricity costs beforehand, and for that very reason cut down the power of the VM in question. At least, it will be easy to ramp it up again for shorter periods of time, for example during a huge tournament, or things like that.

Have a nice X-mas and a happy new year!
Thanks again and stay away from CoVid!

regarding electrical cost: In USA my estimate is $15 per month per server. I usally only run one or the other

  1. older dual xeon configs . One is 2x6x2 = 24 threads , other is 2x8x2=32 threads
  2. based on full usages 24x7. ( actually runs about 75% of the time is my guess )
  3. appx 240 watts @ $ 0.08794 per KW (fixed delivery cost per month not included as I pay that anyway )

yes systemd is the way to go for logging IMHO

well, systemd does its job. Thanks for hinting me towards it.

When it comes to electricity, i had no income since 20 years, so i have to keep an eye on costs, and the server is drawing juice for 2x16 real cores: dual cpu, no hyperthreading, as virtualisation + stockfish don't like it, which means more nps than 64 HT-Cores. On top of that are 18 disk spinning rust and so on... It's no longer a PC. The server is running 24x7, but with lower utilisation.

You should be able to call tee with the -i flag. This will prevent tee from closing on the Ctrl-C, and instead wait for fishnet to finish and EOF the pipe.

I was going to send a PR to use writeln! in the logger instead, and retry on stderr if there is an ErrorKind::BrokenPipe. Should probably handle the SIGPIPE too and move to shutdown_soon when that signal is received.

Ah! Great input bharrisau! Didn't know about -i, which - in fact - would have prevented the error in the first place.