honeycombio / libhoney-rb

Ruby library for sending data to Honeycomb
Apache License 2.0
11 stars 30 forks source link

sending threads don't handle all exceptions #11

Closed toshok closed 7 years ago

toshok commented 7 years ago

Right now we don't guard against threads going away due to an uncaught exception.

what's the ruby behavior for this anyway? does it bring the entire process down? the thread down? both are bad (the first obviously much worse)

samstokes commented 7 years ago

An exception in a non-main thread will not terminate the process; it terminates the thread where the exception occurred, leaving that thread in the state dead, but has no other effect on other threads... unless one of those threads calls Thread#join on the dead thread, at which point the exception is re-raised in the thread that called Thread#join.

We call #join on all the threads in TransmissionClient#close. So the current behaviour is that each exception will permanently and silently remove its thread from the thread pool - which could affect the stability of the program if @block_on_send is set, but not otherwise - and then the call to #close will raise one of those exceptions (whichever occurred in the earliest-created thread).

That's not terrible - because you're probably only calling #close at process shutdown anyway - but not great - because we might interrupt other shutdown stuff or at best produce a confusing error message.

I'll take a task to fix it. I think the fix is straightforward, but I'd want to test it a bit.

samstokes commented 7 years ago

Fixed by #13.