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

fix: make sure old query stream doesn't block on close #5730

Merged
merged 4 commits into from
Jul 1, 2020

Conversation

purplefox
Copy link
Contributor

@purplefox purplefox commented Jun 30, 2020

Description

Fixes #5724

The ksqlDB CLI currently uses the old query streaming API at /query.

When terminating a query from the CLI, the connection is closed. The close is detected in the QueryStreamWriter poll loop which causes it to flush the OutputStream. This causes a write to be called on the underlying ResponseOutputStream, but because the channel isn't available for writing writeQueueFull() returns true and the thread is blocked until it times out (previously 60 seconds). This means that, previously, if you start and terminate queries quite rapidly, it takes 60 seconds for each ones state to be cleared up on the server.

This PR changes the blocking in ResponseOutputStream so it can return more quickly if the stream is closed. It also changes the blocking timeout to 10 minutes, and it changes the server idle timeout to 10 minutes.

The old query endpoint had been migrated as is from Jetty to Vert.x. The old code is somewhat complex and this bug arose in the mapping from the synchronous approach taken in the old implementation and the Vert.x asynchronous APIs.

I'd recommend that the ksqlDB is refactored to use the new query streaming API (e.g. via the new Java client) which does not have these issues, and the old /query API is deprecated.

Testing done

Non functional change.

Manually verified.

Reviewer checklist

  • Ensure docs are updated if necessary. (eg. if a user visible feature is being added or changed).
  • Ensure relevant issues are linked (description should include text like "Fixes #")

@purplefox purplefox requested a review from a team as a code owner June 30, 2020 15:34
@purplefox purplefox requested a review from vcrfxia June 30, 2020 15:38
Copy link
Contributor

@vcrfxia vcrfxia left a comment

Choose a reason for hiding this comment

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

Thanks @purplefox ! This should also be backported to 6.0.x, right?

config/ksql-server.properties Outdated Show resolved Hide resolved
@apurvam
Copy link
Contributor

apurvam commented Jun 30, 2020

Yes, let's target 6.0.x and merge.

@purplefox purplefox merged commit 970d19f into confluentinc:master Jul 1, 2020
@purplefox purplefox deleted the push_query_close branch July 1, 2020 11:48
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.

CLI hangs and throws TimeoutException in 0.10.0
3 participants