Stop flush timer before closing queue#257
Merged
remeh merged 1 commit intoDataDog:masterfrom May 6, 2022
Merged
Conversation
abicky
commented
May 6, 2022
| @@ -102,10 +102,11 @@ def start | |||
| # to close the sender nor trying to continue to `#add` more message | |||
| # into the sender. | |||
| def stop(join_worker: true) | |||
Contributor
Author
There was a problem hiding this comment.
Without this change, the test fails as follows:
% bundle exec rspec spec/statsd/sender_spec.rb:116
Run options: include {:locations=>{"./spec/statsd/sender_spec.rb"=>[116]}}
Datadog::Statsd::Sender
#stop
when flush_interval is set
#<Thread:0x00007ff6e711b4e0@Statsd Timer /Users/arabiki/ghq/src/github.com/DataDog/dogstatsd-ruby/lib/datadog/statsd/timer.rb:18 run> terminated with exception (report_on_exception is true):
/Users/arabiki/ghq/src/github.com/DataDog/dogstatsd-ruby/lib/datadog/statsd/sender.rb:43:in `push': queue closed (ClosedQueueError)
from /Users/arabiki/ghq/src/github.com/DataDog/dogstatsd-ruby/lib/datadog/statsd/sender.rb:43:in `flush'
from /Users/arabiki/ghq/src/github.com/DataDog/dogstatsd-ruby/lib/datadog/statsd/sender.rb:24:in `block in initialize'
from /Users/arabiki/ghq/src/github.com/DataDog/dogstatsd-ruby/lib/datadog/statsd/timer.rb:25:in `block (2 levels) in start'
from /Users/arabiki/ghq/src/github.com/DataDog/dogstatsd-ruby/lib/datadog/statsd/timer.rb:20:in `synchronize'
from /Users/arabiki/ghq/src/github.com/DataDog/dogstatsd-ruby/lib/datadog/statsd/timer.rb:20:in `block in start'
stops the worker thread and the flush timer thread (FAILED - 1)
Failures:
1) Datadog::Statsd::Sender#stop when flush_interval is set stops the worker thread and the flush timer thread
Failure/Error: current_message_queue.push(:flush)
ClosedQueueError:
queue closed
# ./lib/datadog/statsd/sender.rb:43:in `push'
# ./lib/datadog/statsd/sender.rb:43:in `flush'
# ./lib/datadog/statsd/sender.rb:24:in `block in initialize'
# ./lib/datadog/statsd/timer.rb:25:in `block (2 levels) in start'
# ./lib/datadog/statsd/timer.rb:20:in `synchronize'
# ./lib/datadog/statsd/timer.rb:20:in `block in start'
Finished in 0.01402 seconds (files took 0.4371 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./spec/statsd/sender_spec.rb:117 # Datadog::Statsd::Sender#stop when flush_interval is set stops the worker thread and the flush timer thread
fb8532b to
91a6393
Compare
As `Datadog::Sender#flush` adds `:flush` command to the queue, the flush timer should be closed before the sender closes the queue to avoid ClosedQueueError.
remeh
approved these changes
May 6, 2022
Contributor
remeh
left a comment
There was a problem hiding this comment.
Makes total sense, thanks for your contribution!
Contributor
Author
|
Echo'oing @abicky , it would be awesome to get this fix released as part of the gem 😃 Appreciate all the work that goes into this piece of software. |
Contributor
|
@abicky @aniruddhb I'll work on a new release this week 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As
Datadog::Sender#flushadds:flushcommand to the queue, the flush timer should be closed before the sender closes the queue to avoid ClosedQueueError.