-
Notifications
You must be signed in to change notification settings - Fork 43
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
Kill workers that are stuck in long running queires #21
Conversation
src/pgapp_worker.erl
Outdated
gen_server:call(W, {squery, Sql}, | ||
Timeout) | ||
catch | ||
exit:E -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe more specific like exit:timeout
?
src/pgapp_worker.erl
Outdated
catch | ||
exit:E -> | ||
exit(W, kill), | ||
exit(E) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, probably it would be better to keep original stacktrace by using erlang:raise(exit, E, get_stacktrace())
src/pgapp_worker.erl
Outdated
gen_server:call(W, {equery, Sql, Params}, | ||
Timeout) | ||
catch | ||
exit:E -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same here. Maybe use generic wrapper?
src/pgapp_worker.erl
Outdated
gen_server:call(W, {transaction, Fun}, | ||
Timeout) | ||
catch | ||
exit:E -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again
very good points! |
try | ||
Fun(Worker) | ||
catch | ||
Type:Error -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, are you sure you want to catch all errors, not exit = Type:{timeout, _} = Reason
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly yes, given that the current code can return incapacitated workers to the pool which can cause serious issues I think killing a worker too many might be better then killing a worker too few.
But all the calls wrapped are nothing more then a gen_server:call
so the only other exception possibly being thrown I can think of are all exits anyway.
This PR take a brutal approach at assassinating workers that happen to time out due to long running requests! This might not be the perfect solution, I'm more then open to better alternatives.
This is fixes the issue described in #20
Please be aware that as a side effect it includes hex related changes.