Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve event sending thread lifecycle management #265

Merged
merged 3 commits into from
Feb 27, 2023

Conversation

smortex
Copy link
Member

@smortex smortex commented Feb 27, 2023

This PR add a bunch of enhancements to the event sender thread to make the system more resilient to transcient communication errors.

When riemann was unreachable, riemann-wrapper was terminating, and the other tools stopped trying to send events (even if riemann was reachable again). This is now fixed by logging the failure and droping the events. Other (unknown) errors in the event sending thread now cause a termination of the program in all cases, with some diagnostic messages.

This remove an hypothetical race condition where a Thread is created,
start running and raise an expection *before* the main thread sets this
Thread's abort_on_exception to true.
If for some reason the worker thread is stopped (this should not happen
under normal circumstances), the #drain method called by #at_exit will
wait forever for queued items to be consumed.

Ensure the worker thread is still running while we drain.
If we cannot communicate with Riemann, assume this is a trancient error,
drop the messages and continue processing.  Otherwise, terminate the
program (without a worker sending thread, it does not make sense to
stack events forever).
@smortex smortex added the bug Something isn't working label Feb 27, 2023
Copy link
Member

@jamtur01 jamtur01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jamtur01 jamtur01 merged commit f211608 into main Feb 27, 2023
@smortex smortex deleted the improve-thread-management branch February 27, 2023 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants