Repository: apache/shardingsphere (Java)

Issue:
Remove property proxy-backend-executor-suitable from server.yaml
## API changes

The property `proxy-backend-executor-suitable` was introduced from https://github.com/apache/shardingsphere/pull/12474.
It is used for improving Proxy performance in scenario with fixed number of frontend connections. But blocking Netty EventLoop might cause troubles.
Consider the following points, I'm going to remove this API since 5.4.0:
1. It requires users to understand how Netty and ShardingSphere-Proxy work. It might cause have serious side effects if misuse.
1. In scenarios where the number of frontend connections changes frequently, it may cause latency behavior unexpectedly.
1. The variable naming might mislead users.





Fix (patch):
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/yaml-config/props.cn.md b/docs/document/content/user-manual/shardingsphere-proxy/yaml-config/props.cn.md
index 59b5dfa95a063..4c25bfc8b7142 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/yaml-config/props.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/yaml-config/props.cn.md
@@ -22,7 +22,6 @@ Apache ShardingSphere 提供了丰富的系统配置属性，用户可通过 `se
 | proxy-hint-enabled (?)                    | boolean | 是否允许在 ShardingSphere-Proxy 中使用 Hint。使用 Hint 会将 Proxy 的线程处理模型由 IO 多路复用变更为每个请求一个独立的线程，会降低 Proxy 的吞吐量。                                    | false    | 是      |
 | proxy-backend-query-fetch-size (?)        | int     | Proxy 后端与数据库交互的每次获取数据行数（使用游标的情况下）。数值增大可能会增加 ShardingSphere Proxy 的内存使用。默认值为 -1，代表设置为 JDBC 驱动的最小值。                                      | -1       | 是      |
 | proxy-frontend-executor-size (?)          | int     | Proxy 前端 Netty 线程池线程数量，默认值 0 代表使用 Netty 默认值。                                                                                           | 0        | 否      |
-| proxy-backend-executor-suitable (?)       | String  | 可选选项：OLAP、OLTP。OLTP 选项可能会减少向客户端写入数据包的时间开销，但如果客户端连接数超过 `proxy-frontend-executor-size`，尤其是执行慢 SQL 时，它可能会增加 SQL 执行的延迟甚至阻塞其他客户端的连接。        | OLAP     | 是      |
 | proxy-frontend-max-connections (?)        | int     | 允许连接 Proxy 的最大客户端数量，默认值 0 代表不限制。                                                                                                       | 0        | 是      |
 | sql-federation-type (?)                   | String  | 联邦查询执行器类型，包括：NONE，ORIGINAL，ADVANCED。                                                                                                   | NONE     | 是      |
 | proxy-mysql-default-version (?)           | String  | Proxy 通过配置文件指定 MySQL 的版本号，默认版本：5.7.22。                                                                                                 | 5.7.22   | 否      |
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/yaml-config/props.en.md b/docs/document/content/user-manual/shardingsphere-proxy/yaml-config/props.en.md
index bcbcf0dd29dbe..4832946065066 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/yaml-config/props.en.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/yaml-config/props.en.md
@@ -22,7 +22,6 @@ Apache ShardingSphere provides a wealth of system configuration properties, whic
 | proxy-hint-enabled (?)                    | boolean     | Whether Hint is allowed in ShardingSphere-Proxy. Using Hint changes the Proxy's threading model from IO multiplexing to a separate thread per request, reducing Proxy's throughput.                                                                                                                          | false     | True             |
 | proxy-backend-query-fetch-size (?)        | int         | The number of rows of data obtained when the backend Proxy interacts with databases (using a cursor). A larger number may increase the occupied memory of ShardingSphere-Proxy. The default value of -1 indicates the minimum value for JDBC driver.                                                         | -1        | True             |
 | proxy-frontend-executor-size (?)          | int         | The number of threads in the Netty thread pool of front-end Proxy.                                                                                                                                                                                                                                           | 0         | False            |
-| proxy-backend-executor-suitable (?)       | String      | Options: OLAP and OLTP. The OLTP option may reduce the time overhead when writing packets to the client, but if the number of client connections exceeds `proxy-frontend-executor-size`, especially with slow SQL, it can cause a longer delay to SQL execution and even block connections to other clients. | OLAP      | True             |
 | proxy-frontend-max-connections (?)        | int         | The maximum number of clients that can be connected to Proxy. The default value of 0 indicates that there's no limit.                                                                                                                                                                                        | 0         | True             |
 | sql-federation-type (?)                   | String      | SQL federation executor type, including: NONE, ORIGINAL, ADVANCED.                                                                                                                                                                                                                                           | NONE      | True             |
 | proxy-mysql-default-version (?)           | String      | Proxy specifies the MySQL version through configuration files, and the default verison is 5.7.22.                                                                                                                                                                                                            | 5.7.22    | False            |
diff --git a/examples/shardingsphere-proxy-example/shardingsphere-proxy-distsql-example/src/main/resources/server/server.yaml b/examples/shardingsphere-proxy-example/shardingsphere-proxy-distsql-example/src/main/resources/server/server.yaml
index addc5cbda5ec0..d93a9d599b3c5 100644
--- a/examples/shardingsphere-proxy-example/shardingsphere-proxy-distsql-example/src/main/resources/server/server.yaml
+++ b/examples/shardingsphere-proxy-example/shardingsphere-proxy-distsql-example/src/main/resources/server/server.yaml
@@ -61,6 +61,3 @@ props:
   # The default value is -1, which means set the minimum value for different JDBC drivers.
   proxy-backend-query-fetch-size: -1
   proxy-frontend-executor-size: 0 # Proxy frontend executor size. The default value is 0, which means let Netty decide.
-    # Available options of proxy backend executor suitable: OLAP(default), OLTP. The OLTP option may reduce time cost of writing packets to client, but it may increase the latency of SQL execution
-  # if client connections are more than proxy-frontend-netty-executor-size, especially executing slow SQL.
-  proxy-backend-executor-suitable: OLAP
diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/config/props/BackendExecutorType.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/config/props/BackendExecutorType.java
deleted file mode 100644
index d070dc062bf4f..0000000000000
--- a/infra/common/src/main/java/org/apache/shardingsphere/infra/config/props/BackendExecutorType.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.shardingsphere.infra.config.props;
-
-/**
- * Backend executor type.
- */
-public enum BackendExecutorType {
-    
-    OLTP, OLAP
-}
diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/config/props/ConfigurationPropertyKey.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/config/props/ConfigurationPropertyKey.java
index 5784dcf38aafb..fdda90d5d3752 100644
--- a/infra/common/src/main/java/org/apache/shardingsphere/infra/config/props/ConfigurationPropertyKey.java
+++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/config/props/ConfigurationPropertyKey.java
@@ -93,12 +93,6 @@ public enum ConfigurationPropertyKey implements TypedPropertyKey {
      */
     PROXY_FRONTEND_EXECUTOR_SIZE("proxy-frontend-executor-size", String.valueOf(0), int.class, true),
     
-    /**
-     * Available options of proxy backend executor suitable: OLAP(default), OLTP. The OLTP option may reduce time cost of writing packets to client, but it may increase the latency of SQL execution
-     * and block other clients if client connections are more than {@link ConfigurationPropertyKey#PROXY_FRONTEND_EXECUTOR_SIZE}, especially executing slow SQL.
-     */
-    PROXY_BACKEND_EXECUTOR_SUITABLE("proxy-backend-executor-suitable", BackendExecutorType.OLAP.name(), BackendExecutorType.class, false),
-    
     /**
      * Less than or equal to 0 means no limitation.
      */
diff --git a/proxy/bootstrap/src/main/resources/conf/server.yaml b/proxy/bootstrap/src/main/resources/conf/server.yaml
index a8574979a05da..872bed96992be 100644
--- a/proxy/bootstrap/src/main/resources/conf/server.yaml
+++ b/proxy/bootstrap/src/main/resources/conf/server.yaml
@@ -76,9 +76,6 @@
 #    # The default value is -1, which means set the minimum value for different JDBC drivers.
 #  proxy-backend-query-fetch-size: -1
 #  proxy-frontend-executor-size: 0 # Proxy frontend executor size. The default value is 0, which means let Netty decide.
-#    # Available options of proxy backend executor suitable: OLAP(default), OLTP. The OLTP option may reduce time cost of writing packets to client, but it may increase the latency of SQL execution
-#    # and block other clients if client connections are more than `proxy-frontend-executor-size`, especially executing slow SQL.
-#  proxy-backend-executor-suitable: OLAP
 #  proxy-frontend-max-connections: 0 # Less than or equal to 0 means no limitation.
 #    # Available sql federation type: NONE (default), ORIGINAL, ADVANCED
 #  sql-federation-type: NONE
diff --git a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyState.java b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyState.java
index 0827605597028..2ef8c0eede9a5 100644
--- a/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyState.java
+++ b/proxy/frontend/core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyState.java
@@ -18,7 +18,6 @@
 package org.apache.shardingsphere.proxy.frontend.state.impl;
 
 import io.netty.channel.ChannelHandlerContext;
-import org.apache.shardingsphere.infra.config.props.BackendExecutorType;
 import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
@@ -38,25 +37,18 @@ public final class OKProxyState implements ProxyState {
     
     @Override
     public void execute(final ChannelHandlerContext context, final Object message, final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine, final ConnectionSession connectionSession) {
-        ExecutorService executorService = determineSuitableExecutorService(context, connectionSession);
+        ExecutorService executorService = determineSuitableExecutorService(connectionSession);
         context.channel().config().setAutoRead(false);
         executorService.execute(new CommandExecutorTask(databaseProtocolFrontendEngine, connectionSession, context, message));
     }
     
-    private ExecutorService determineSuitableExecutorService(final ChannelHandlerContext context, final ConnectionSession connectionSession) {
-        if (requireOccupyThreadForConnection(connectionSession)) {
-            return ConnectionThreadExecutorGroup.getInstance().get(connectionSession.getConnectionId());
-        }
-        return isPreferNettyEventLoop() ? context.executor() : UserExecutorGroup.getInstance().getExecutorService();
+    private ExecutorService determineSuitableExecutorService(final ConnectionSession connectionSession) {
+        return requireOccupyThreadForConnection(connectionSession) ? ConnectionThreadExecutorGroup.getInstance().get(connectionSession.getConnectionId())
+                : UserExecutorGroup.getInstance().getExecutorService();
     }
     
     private boolean requireOccupyThreadForConnection(final ConnectionSession connectionSession) {
         return ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps().<Boolean>getValue(ConfigurationPropertyKey.PROXY_HINT_ENABLED)
                 || TransactionType.isDistributedTransaction(connectionSession.getTransactionStatus().getTransactionType());
     }
-    
-    private boolean isPreferNettyEventLoop() {
-        return BackendExecutorType.OLTP == ProxyContext.getInstance()
-                .getContextManager().getMetaDataContexts().getMetaData().getProps().<BackendExecutorType>getValue(ConfigurationPropertyKey.PROXY_BACKEND_EXECUTOR_SUITABLE);
-    }
 }