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

Plugin won't shutdown if no events coming through the SQS queue #33

Closed
gregsterin opened this issue Feb 4, 2017 · 4 comments · Fixed by #65
Closed

Plugin won't shutdown if no events coming through the SQS queue #33

gregsterin opened this issue Feb 4, 2017 · 4 comments · Fixed by #65

Comments

@gregsterin
Copy link

gregsterin commented Feb 4, 2017

I've noticed that if an SQS queue has no events flowing through it, then the plugin won't shut down.

The use case I have for a queue without events flowing through it is that I use SQS as a fallback transport, and only send data through it when my primary transport is down or having issues streaming.

Looking at the code, it seems that breaking out of the polling loop happens only when there are messages to loop through:
https://github.com/logstash-plugins/logstash-input-sqs/blob/master/lib/logstash/inputs/sqs.rb#L143

seems there needs to be a before_request callback (http://docs.aws.amazon.com/sdkforruby/api/Aws/SQS/QueuePoller.html#before_request-instance_method) that checks for stopped and throws ':stop_polling' to break out of the processing loop even if there are no events flowing through the queue.

@danielpops
Copy link
Contributor

+1. I've been trying to track down why logstash was unable to shut down gracefully certain hosts. Turns out that this was the cause of it, since on those hosts in question, they have an SQS queue input that rarely receives input.

I can confirm that applying a patch like the one below addresses the problem

@@ -147,6 +147,10 @@
   def run(output_queue)
     @logger.debug("Polling SQS queue", :polling_options => polling_options)

+    poller.before_request do |stats|
+        throw :stop_polling if stop?
+    end
+
     run_with_backoff do
       poller.poll(polling_options) do |messages, stats|
         break if stop?

@dustin-decker
Copy link

This is causing noisy logs for us before our logstash containers hit their SIGTERM timeout of 5 minutes and get SIGKILLed. It'd be nice to get a fix merged.

@jayqi
Copy link

jayqi commented Oct 5, 2020

This still appears to be a problem in Logstash 7.9.1 and logstash-input-sqs 3.1.2.

@SebastiaanDewilde
Copy link

Still a problem, is it possible to merge the PR?

yaauie added a commit to yaauie/logstash-input-sqs that referenced this issue Feb 25, 2022
yaauie added a commit to yaauie/logstash-input-sqs that referenced this issue Feb 25, 2022
yaauie added a commit to yaauie/logstash-input-sqs that referenced this issue Feb 25, 2022
@kares kares closed this as completed in #65 Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants