-
Notifications
You must be signed in to change notification settings - Fork 6
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 error handling on worker #17
Conversation
14d8569
to
39b4623
Compare
|
||
DEFAULT = { | ||
require: '.', | ||
process: 1, | ||
graceful_kill_timeout: 600, | ||
queue_timeout: 1, | ||
daemonize: false, | ||
abort_on_error: true | ||
abort_on_error: true, | ||
sleep_sec_on_error: 1, |
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 default can be set to 3 seconds?
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.
I don't know this value is reasonable or not.
So I think that default value should be minimmum.
If necessary, the user should optionally specify values that are reasonable for the user.
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.
I see.
We can take that option, and I leave the value to be customized by user since this is the last resort against a queue causing consecutive errors.
lib/shinq/launcher.rb
Outdated
|
||
def format_error_message(error) | ||
if defined?(::Rails) && ::Rails.backtrace_cleaner | ||
backtrace = ::Rails.backtrace_cleaner.clean(error.backtrace || []) |
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.
I think that backtrace should not omit.
Because omitting it makes it impossible to know the hierarchy.
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.
Actually, backtrace_cleaner does not stop us from knowing the hierarchy. Rather, it helps us understand the backtrace more quickly, which contributes to debug efficiency.
By default, backtrace_cleaner
does the following 2 operations.
- Filter: Show relative paths from application root instead of full paths from root
/
. - Silencer: Exclude lines which belong to internal libraries.
http://api.rubyonrails.org/classes/ActiveSupport/BacktraceCleaner.html
The former does not break hierarchy at all. It just removes redundant information like /home/app-user/application/releases/20170929123456/
from each line in backtrace. This significantly reduces noisy and redundant log messages especially on production servers.
The latter one also does not stop us from understanding the hierarchy. Since it removes line belonging to external libraries, the users' ruby codes in backtrace, from which almost all the errors are stemming, are not removed nor disordered. On the contrary, removing irrelevant lines makes the log concise and lets users focus on the real cause. In our environment, typical backtrace in worker has 16 lines in serverengine
, 5 lines in shinq
, and 15 lines in bundler
compared with a few (mainly 1 to 3) lines in our code, which means more than 90 % of backtrace consists of irrelevant lines.
Moreover, settings of backtrace_cleaner is usually maintained with application code typically under config/initializers/backtrace_cleaners.rb
. This means that the filters and silencers are appropriately customized by each user, and in case whole backtrace are required, a user can see it just by calling BacktraceCleaner#remove_filters!
.
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.
Just in case error occurs in external libraries, I will fix the code to show full backtrace when cleaned backtrace is empty.
|
||
DEFAULT = { | ||
require: '.', | ||
process: 1, | ||
graceful_kill_timeout: 600, | ||
queue_timeout: 1, | ||
daemonize: false, | ||
abort_on_error: true | ||
abort_on_error: true, | ||
sleep_sec_on_error: 1, |
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.
I don't know this value is reasonable or not.
So I think that default value should be minimmum.
If necessary, the user should optionally specify values that are reasonable for the user.
Thank you for reviewing this Pull Request. If that does not address your concern, it would be very helpful if you let me know the details. |
4740f5d
to
65ba189
Compare
65ba189
to
87bb78d
Compare
@ryopeko
I have improved error handling on worker.
Following are the details.
Shinq::Client.dequeue
andShinq.configuration.abort_on_error
conditional block inbegin
...rescue
blockShinq::Client.dequeue
where workers establish connection.--no-abort-on-error