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

acks: send sequence-0 ack for 0-window batches #479

Merged
merged 2 commits into from Sep 7, 2023

Conversation

yaauie
Copy link
Contributor

@yaauie yaauie commented Sep 6, 2023

Ensures that at least one ACK is sent in reply to each window, including those with 0-length, by emitting an empty batch when we receive a 0-window frame and sending a sequence-0 ACK in reply when we process an empty batch.

This enables upstream users of the protocol to (ab)use a 0-length window frame and an ensured in-protocol response to validate that we are alive.

Note: 0-sequence ACKs are already used as application-level keep-alives between when the ConnectionHandler receives bytes and when BeatsHandler finishes processing a batch, and therefore should already be handled gracefully by any existing clients.

Thanks for contributing to Logstash! If you haven't already signed our CLA, here's a handy link: https://www.elastic.co/contributor-agreement/

Ensures that at least one ACK is sent in reply to each window, including
those with 0-length, by emitting an empty batch when we receive a 0-window
frame and sending a sequence-0 ACK in reply when we process an empty batch.

This enables upstream users of the protocol to (ab)use a 0-length window
frame and an _ensured_ in-protocol response to validate that we are alive.

Note: 0-sequence ACKs are already used as application-level keep-alives
between when the `ConnectionHandler` receives bytes and when `BeatsHandler`
finishes processing a batch, and therefore should already be handled
gracefully by any existing clients.
@@ -5,6 +5,7 @@ env

set -ex

bundle exec rake test:java
Copy link
Contributor Author

Choose a reason for hiding this comment

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

review note: java unit tests were not being triggered as part of the build 🤦🏼

Copy link
Contributor

@jsvd jsvd left a comment

Choose a reason for hiding this comment

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

LGTM, I tested locally with a modified lumberjack client. I could observe that with this patch the client immediately received an ack after sending an zero window frame, instead of waiting a long time for the ack from the idlestatehandler.

The script used, that takes code from the original lumberjack ruby client, can be found here: https://gist.github.com/jsvd/b86ea9d2f16a868c1460d4e12145a35f#file-beats_empty_writer-rb

@yaauie yaauie merged commit 339913c into logstash-plugins:main Sep 7, 2023
2 checks passed
@yaauie yaauie deleted the ack-0-for-0-windows branch September 7, 2023 15:35
fbacchella added a commit to fbacchella/netty-beats that referenced this pull request Sep 27, 2023
…b.com>

acks: send sequence-0 ack for 0-window batches (logstash-plugins#479)

* acks: send sequence-0 ack for 0-window batches

Ensures that at least one ACK is sent in reply to each window, including
those with 0-length, by emitting an empty batch when we receive a 0-window
frame and sending a sequence-0 ACK in reply when we process an empty batch.

This enables upstream users of the protocol to (ab)use a 0-length window
frame and an _ensured_ in-protocol response to validate that we are alive.

Note: 0-sequence ACKs are already used as application-level keep-alives
between when the `ConnectionHandler` receives bytes and when `BeatsHandler`
finishes processing a batch, and therefore should already be handled
gracefully by any existing clients.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants