Close the thrift connection of KyuubiServer when backend engine is determined as dead by EngineAliveProbe #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why are the changes needed?
As described in apache#4457, when the backend engine becomes unresponsive,
the beeline will hang because
client.getOperationStatus(_remoteOpHandle)
inExecuteStatement #waitStatementComplete()
would never receive any response.https://github.com/apache/kyuubi/blob/43309b86f1997b028e8fde5cb4e6449d818f4f73/kyuubi-server/src/main/scala/org/apache/kyuubi/operation/ExecuteStatement.scala#L101-L105
While the EngineAliveProbe can identify engine failure, it does not resolve the underlying issue of the thrift client waiting for a response, causing the beeline to remain unresponsive. The only way to resolve this state of suspension is by interrupting the thrift client thread.
https://github.com/apache/kyuubi/blob/3d65f2711faa5dc9173130557e2d33adab04b5c7/kyuubi-server/src/main/scala/org/apache/kyuubi/client/KyuubiSyncThriftClient.scala#L84
This pull request introduces a new logic to the EngineAliveProbe feature, whereby upon detecting an engine failure, it deliberately closes the thrift connection. This creates an exception that can then be handled by the error handling mechanism introduced in apache#646, thereby allowing for a graceful shutdown of the session handle.
How was this patch tested?
I am very happy to add a test case but I am not aware of how to simulate a state of unresponsive.
Otherwise, I can implement test like this:
https://github.com/apache/kyuubi/blob/43309b86f1997b028e8fde5cb4e6449d818f4f73/kyuubi-server/src/test/scala/org/apache/kyuubi/operation/KyuubiOperationPerUserSuite.scala#L169
kyuubi-default.conf
After 3 consecutive alive probe fails, Engine is marked dead.
Now force closing the thrift client to generate an exception.
OperationManager try
closeOperation
but failed because the connection is already closedAliveProbeClient try to close the remote handler but failed.
It's expected as the backend Engine is dead already.
KyuubiSyncThriftClient#closeSession failed
It's expected as the backend Engine is dead already.
Beeline finished with errors (as expected)
The kyuubi-server suite wasn't working even before this PR.