You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2019/12/27 14:22:03 UTC

[GitHub] [incubator-doris] lingbin commented on a change in pull request #2603: Add nio support for mysql protocol implementation

lingbin commented on a change in pull request #2603: Add nio support for mysql protocol implementation
URL: https://github.com/apache/incubator-doris/pull/2603#discussion_r361673107
 
 

 ##########
 File path: fe/src/main/java/org/apache/doris/mysql/nio/ReadListener.java
 ##########
 @@ -0,0 +1,66 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.doris.mysql.nio;
+
+import org.apache.doris.qe.ConnectContext;
+import org.apache.doris.qe.ConnectProcessor;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.xnio.ChannelListener;
+import org.xnio.XnioIoThread;
+import org.xnio.conduits.ConduitStreamSourceChannel;
+
+/**
+ * Created by infear on 2019/12/20.
+ */
+public class ReadListener implements ChannelListener<ConduitStreamSourceChannel> {
+    private final Logger LOG = LogManager.getLogger(this.getClass());
+    private NConnectContext ctx;
+    private ConnectProcessor connectProcessor;
+
+    public ReadListener(NConnectContext nConnectContext, ConnectProcessor connectProcessor) {
+        this.ctx = nConnectContext;
+        this.connectProcessor = connectProcessor;
+    }
+
+    @Override
+    public void handleEvent(ConduitStreamSourceChannel channel) {
+        // suspend must be call sync in current thread (the IO-Thread notify the read event),
+        // otherwise multi handler(task thread) would be waked up by once query.
+        XnioIoThread.requireCurrentThread();
+        ctx.suspendAcceptQuery();
+        // start async query handle in task thread.
+        channel.getWorker().execute(() -> {
 
 Review comment:
   I don't know much about the use of `jboss.xnio` library, just read its documentation.
   
   I have a question here: will this run in `WORKER THREAD pool`, which was configured to 16 in `NMysqlServer`(use `Options.WORKER_TASK_MAX_THREADS`)? 
   If it is, there may be a problem. For example: if we have 16 slow queries, such as running for 5 minutes, which makes these 16 threads are filled. And because there are no threads available for subsequent query requests, the server will hang for 5 minutes.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org