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

Handle ping correctly in NioTransport #25462

Merged
merged 3 commits into from
Jun 29, 2017
Merged

Conversation

Tim-Brooks
Copy link
Contributor

Our current TCPTransport logic assumes that we do not pass pings to
the TCPTransport level.

This commit fixes an issue where NioTransport was passing pings to
TCPTransport and leading to exceptions.

@Tim-Brooks Tim-Brooks added :Distributed/Network Http and internode communication implementations review >test Issues or PRs that are addressing/adding tests v6.0.0 labels Jun 29, 2017
Copy link
Contributor

@s1monw s1monw left a comment

Choose a reason for hiding this comment

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

left a question

@@ -75,7 +75,11 @@ public int read() throws IOException {

try {
BytesReference messageWithoutHeader = message.slice(6, message.length() - 6);
handler.handleMessage(messageWithoutHeader, channel, channel.getProfile(), messageWithoutHeader.length());

// A message length of 6 bytes it is just a ping. Ignore for now.
Copy link
Contributor

Choose a reason for hiding this comment

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

right, should we check if the header is correct and if not close the connection?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This happens in the TcpFrameDecoder here. If the header is invalid, an exception is thrown .

When the exception is caught, the channel goes through out normal exception handling (and disconnect) logic.

Copy link
Contributor

Choose a reason for hiding this comment

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

good! just leave a comment about this in the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a comment next to the usage of frame decoder to indicate that it would thrown an exception if the message turned out to be invalid.

Copy link
Member

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

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

LGTM.

@Tim-Brooks Tim-Brooks merged commit 6c58f0c into elastic:master Jun 29, 2017
@Tim-Brooks
Copy link
Contributor Author

Merged. Thanks @s1monw and @jasontedor

jasontedor added a commit that referenced this pull request Jun 30, 2017
* master: (129 commits)
  Add doc note regarding explicit publish host
  Fix typo in name of test
  Add additional test for sequence-number recovery
  WrapperQueryBuilder should also rewrite the parsed query.
  Remove dead code and stale Javadoc
  Update defaults in documentation (#25483)
  [DOCS] Add docs-dir to Painless (#25482)
  Add concurrent deprecation logger test
  [DOCS] Update shared attributes for Elasticsearch (#25479)
  Use LRU set to reduce repeat deprecation messages
  Add NioTransport threads to thread name checks (#25477)
  Add shortcut for AbstractQueryBuilder.parseInnerQueryBuilder to QueryShardContext
  Prevent channel enqueue after selector close (#25478)
  Fix Java 9 compilation issue
  Remove unregistered `transport.netty.*` settings (#25476)
  Handle ping correctly in NioTransport (#25462)
  Tests: Remove platform specific assertion in NioSocketChannelTests
  Remove QueryParseContext from parsing QueryBuilders (#25448)
  Promote replica on the highest version node (#25277)
  test: added not null assertion
  ...
@Tim-Brooks Tim-Brooks deleted the fix_ping branch November 14, 2018 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed/Network Http and internode communication implementations >test Issues or PRs that are addressing/adding tests v6.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants