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

Filebeat: Allow stateless and stateful ACKer on the global ack handler #7214

Merged
merged 2 commits into from
Jun 4, 2018

Conversation

ph
Copy link
Contributor

@ph ph commented May 30, 2018

This commit introduces a change in how filebeat handle ACK by default,
before the ACK was using the private field of the event to retrieve a
state. The updated state was sent to the registrar, and the registrar
was finalizing the ACK.

But with the introduction of the TCP/UDP and the Redis input, the events
don't have any state attached. So in that scenario, Filebeat was not
correctly acking these events to some wait group.

The ACKer was modified to handle both stateless (default) and stateful
events, when stateful is required, the states are sent to the registry
otherwise, the waiting groups are directly updated.

Fixes: #7202

@ph ph added the Filebeat Filebeat label May 30, 2018
@ph ph force-pushed the fix/ack-stateless branch from e95ebe8 to f21b847 Compare May 30, 2018 17:31
@ph ph added review needs_backport PR is waiting to be backported to other branches. labels May 30, 2018
@ph ph force-pushed the fix/ack-stateless branch from 73c2a5e to 33d5be1 Compare May 30, 2018 17:38
ph added 2 commits May 30, 2018 13:38
This commit introduces a change in how filebat handle ACK by default,
before the ACK was using the private field of the event to retrieve a
state. The updated state was sent to the registrar, and the registrar
was finalizing the ACK.

But with the introduction of the TCP/UDP and the Redis input, the events
don't have any state attached. So in that scenario, Filebeat was not
correctly acking these events to some wait group.

The ACKer was modified to handle both stateless (default) and stateful
events, when stateful is required, the states are sent to the registry
otherwise, the waiting groups are directly updated.

Fixes: elastic#7202
@ph ph force-pushed the fix/ack-stateless branch from 33d5be1 to b3b42ab Compare May 30, 2018 17:38
Copy link
Contributor

@kvch kvch 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. However, I am a bit worried about updating the WaitGroup in multiple places. I would delegate the full responsibility of updating it either to the registrar or to the eventACKer. I would prefer to do it in the registrar, if that's possible. WDYT?

@ph
Copy link
Contributor Author

ph commented Jun 1, 2018

@kvch I see your point and it is a good comment.

I think my original goal was If the type doesn't require a registrar like the Redis, TCP or UDP we should not delegate the ack to the specialize Acker. I see a world where a source could provide their own Acker.

So actually the acker type now acts as a multiplexer of ACKs and delegates them the right acker using the type of event.Private. If we ever implement another source, maybe a queue, we could correctly ack the events that we read. Another way would be to add a ack handler on the client and each input have their own client.

I think maybe the problem you see is the ACKER is not generalized enough, would you be OK if we make the ACKER more generic but Keep the two acking strategy?

Pseudocode

m := NewActMultiplexer(DefaultStatelessAck)
m.Add(file.State, StatefulAcker)

@ph
Copy link
Contributor Author

ph commented Jun 1, 2018

I am a bit worried about updating the WaitGroup in multiple places.

I think this could be removed because of some changes in the pipeline.
I wanted to keep the changes small in that PR to ship it with 6.3.

Also, I am not too worried about possible problems:

  • The implementation is threadsafe
  • We were actually decorating it with the registrar.
  • Input not requiring registrar update should still not invoke the registrar.

@tsg tsg merged commit b9d2150 into elastic:master Jun 4, 2018
@tsg tsg added v6.3.0 and removed needs_backport PR is waiting to be backported to other branches. labels Jun 4, 2018
@urso
Copy link

urso commented Jun 4, 2018

Changes LGTM.

The finishedLogger and the eventACKER decreasing the WaitGroup is a filebeat solution only. It is used to implement the wait_shutdown setting. The publisher pipeline in libbeat supports this use-case as well, but we didn't manage to replace the finishedLogger with the libbeat implementation for various reason (more refactoring required). The finishedLogger and the WaitGroup will be removed in the future + all beats will switch to the libbeat wait_shutdown logic.

As is done in this PR, stateless events should not be routed via the registry, as the registry introduces another potential delay/backpressure, even if not required.

tsg pushed a commit to tsg/beats that referenced this pull request Jun 5, 2018
elastic#7214)

* Filebeat: Allow stateless and stateful ACKer on the global ack handler

This commit introduces a change in how filebat handle ACK by default,
before the ACK was using the private field of the event to retrieve a
state. The updated state was sent to the registrar, and the registrar
was finalizing the ACK.

But with the introduction of the TCP/UDP and the Redis input, the events
don't have any state attached. So in that scenario, Filebeat was not
correctly acking these events to some wait group.

The ACKer was modified to handle both stateless (default) and stateful
events, when stateful is required, the states are sent to the registry
otherwise, the waiting groups are directly updated.

Fixes: elastic#7202

* changelog

(cherry picked from commit b9d2150)
urso pushed a commit that referenced this pull request Jun 5, 2018
#7214) (#7258)

* Filebeat: Allow stateless and stateful ACKer on the global ack handler

This commit introduces a change in how filebat handle ACK by default,
before the ACK was using the private field of the event to retrieve a
state. The updated state was sent to the registrar, and the registrar
was finalizing the ACK.

But with the introduction of the TCP/UDP and the Redis input, the events
don't have any state attached. So in that scenario, Filebeat was not
correctly acking these events to some wait group.

The ACKer was modified to handle both stateless (default) and stateful
events, when stateful is required, the states are sent to the registry
otherwise, the waiting groups are directly updated.

Fixes: #7202

* changelog

(cherry picked from commit b9d2150)
leweafan pushed a commit to leweafan/beats that referenced this pull request Apr 28, 2023
elastic#7214) (elastic#7258)

* Filebeat: Allow stateless and stateful ACKer on the global ack handler

This commit introduces a change in how filebat handle ACK by default,
before the ACK was using the private field of the event to retrieve a
state. The updated state was sent to the registrar, and the registrar
was finalizing the ACK.

But with the introduction of the TCP/UDP and the Redis input, the events
don't have any state attached. So in that scenario, Filebeat was not
correctly acking these events to some wait group.

The ACKer was modified to handle both stateless (default) and stateful
events, when stateful is required, the states are sent to the registry
otherwise, the waiting groups are directly updated.

Fixes: elastic#7202

* changelog

(cherry picked from commit 31c46c9)
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.

4 participants