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

FIX: ThreadError Handling #175

Merged
merged 1 commit into from Jun 30, 2021

Conversation

keerthivaasan-kanagaraj
Copy link
Contributor

Hi @SamSaffron

We observed ThreadError was raised from prometheus_exporter when sidekiq triggers SHUTDOWN EXCEPTION.It was due to some improper shutdowns.

As per ruby ThreadError will raise only when main thread is killed then we are trying to create child thread for that main thread

if (GET_VM()->main_thread->status == THREAD_KILLED)
rb_raise(rb_eThreadError, "can't alloc thread");

So need to catch exception in Prometheus gem to handle this error.

Ref. PR: (opentelemetry-ruby) open-telemetry/opentelemetry-ruby#607

@SamSaffron
Copy link
Member

Seems good to me, a tiny bit fragile in case Ruby change the text on the exception but I guess that is the best we can do here.

@SamSaffron SamSaffron merged commit bd961c4 into discourse:master Jun 30, 2021
jobeus pushed a commit to scriptdash/prometheus_exporter that referenced this pull request Dec 16, 2021
Don't leak out an exception if the main thread is killed. 

```
if (GET_VM()->main_thread->status == THREAD_KILLED)
rb_raise(rb_eThreadError, "can't alloc thread");
```

This can happen during certain application shutdowns.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants