github-actions[bot] commented on code in PR #62679:
URL: https://github.com/apache/doris/pull/62679#discussion_r3117252002
##########
fe/fe-core/src/main/java/org/apache/doris/mysql/ReadListener.java:
##########
@@ -46,23 +49,37 @@ public void handleEvent(ConduitStreamSourceChannel channel)
{
XnioIoThread.requireCurrentThread();
ctx.suspendAcceptQuery();
// start async query handle in task thread.
- channel.getWorker().execute(() -> {
- ctx.setThreadLocalInfo();
- try {
- connectProcessor.processOnce();
- if (!ctx.isKilled()) {
- ctx.resumeAcceptQuery();
- } else {
- ctx.stopAcceptQuery();
+ try {
+ channel.getWorker().execute(() -> {
+ ctx.setThreadLocalInfo();
+ try {
+ connectProcessor.processOnce();
+ if (!ctx.isKilled()) {
+ ctx.resumeAcceptQuery();
+ } else {
+ ctx.stopAcceptQuery();
+ ctx.cleanup();
+ }
+ } catch (Throwable e) {
+ LOG.warn("Exception happened in one session(" + ctx +
").", e);
+ ctx.setKilled();
ctx.cleanup();
+ } finally {
+ ConnectContext.remove();
}
- } catch (Throwable e) {
- LOG.warn("Exception happened in one session(" + ctx + ").", e);
+ });
+ } catch (RejectedExecutionException e) {
+ LOG.warn("Failed to submit query task for one session({}).", ctx,
e);
+ ctx.getState().setError(ErrorCode.ERR_UNKNOWN_ERROR,
+ "Too many concurrent requests, please retry later");
Review Comment:
`MysqlProto.sendResponsePacket()` is not safe here. This branch runs before
`MysqlConnectProcessor.processOnce()` does `channel.setSequenceId(0)` and
`fetchOnePacket()`, so the response reuses whatever `MysqlChannel.sequenceId`
was left by the previous command. For a normal one-packet command that is
typically `2` after the last response, and for a multi-packet request we cannot
know the correct reply sequence at all because the request was never consumed.
That means this overload path can still send a protocol-invalid ERR packet. The
new unit test mocks `MysqlProto.sendResponsePacket()`, so it will not catch
this.
Safer options are to close the channel directly, or to restructure this path
so the request is consumed and the sequence is initialized through the normal
command-processing flow before replying.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]