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

queue drain option support #6433

Merged
merged 1 commit into from
Mar 1, 2017

Conversation

colinsurprenant
Copy link
Contributor

@colinsurprenant colinsurprenant commented Dec 16, 2016

This is in [WIP] state because the metrics on empty batch/queue need to be assessed - The creation of an empty final batch to handle the final flush upon shutdown which did not contain metrics yielded some errors so I added metrics to empty batches. There was originally a check for empty batches read to not start metrics but I believe this was bug because if this empty batch got used in a flush signal (slim chance) it would have crashed because of unstarted metrics for that batch.

Core tests/specs are passing locally.

This PR adds support for a queue drain option. It relates to issue #6085 and it is necessary for the upcoming BatchedQueue implementation. The goal is to be able to signal logstash to drain the queue before exiting on a normal shutdown. It is necessary for in-memory queueing support where events can be buffered.

  • It refactors the Wrapped xxx Queue ReadClient classes to not read the next batch directly in the constructor but instead expose a read_batch method so it is now possible to create a new empty batch.

  • The pipeline worker loop becomes a bit clearer to understand with regard to signal handling (shutdown & flush) and shutdown handling for final flush in particular.

  • By default this option is currently turned off and can be turned on in the config using queue.drain: true.

TODO

@guyboertje
Copy link
Contributor

Looks good to me so far. I was planning to port the Q clients to Java/JRuby soon anyway. I would rather do the port when the source is restructured i.e. #6431

@ph
Copy link
Contributor

ph commented Jan 24, 2017

Sorry didn't notice I need to review this, I will take a look asap.

@colinsurprenant
Copy link
Contributor Author

I rebased and would like to reboot this PR.

Copy link
Contributor

@guyboertje guyboertje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@ph ph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good to me, but there are some tests failings that need to be adjusted for this changes.

@colinsurprenant
Copy link
Contributor Author

@ph ok found and fixed the spec problems, some where related to empty batch handling as discussed, others related to the metrics start where my refactor had the call to add_starting_metrics(batch) right after the new empty batch creation but it needed to be after the read_batch.

@colinsurprenant
Copy link
Contributor Author

Build successful! 🎉
@ph final review?

Copy link
Contributor

@ph ph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

wip queue drain option

metrics on empty batches

reenabled spec

cosmetic fixes

stats collection, mutex, specs, empty batch handling

start_metrics
@colinsurprenant colinsurprenant merged commit 568666c into elastic:master Mar 1, 2017
@colinsurprenant
Copy link
Contributor Author

rebased & squashed, merged into master and 5.x

@colinsurprenant colinsurprenant changed the title [WIP] queue drain option support queue drain option support Mar 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants