You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by wu...@apache.org on 2021/10/21 11:35:41 UTC
[shardingsphere] branch master updated: shardingshere proxy
connection limit #13132 (#13179)
This is an automated email from the ASF dual-hosted git repository.
wuweijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new f6202cf shardingshere proxy connection limit #13132 (#13179)
f6202cf is described below
commit f6202cfe5b1e65e3e0a76aba8c4c7ef81cf68439
Author: sunhangda <lw...@126.com>
AuthorDate: Thu Oct 21 19:35:05 2021 +0800
shardingshere proxy connection limit #13132 (#13179)
* proxy conntion limit Issue[#13132]
* shardingshere proxy connection limit Issue[#13132] fix checkstyle
* shardingshere proxy connection limit Issue[#13132] add lisence header
* shardingshere proxy connection limit [#13132] return database message
* shardingshere proxy connection limit Issue[apache#13132] fix code style
* shardingshere proxy connection limit [#13132] add mysql error code
* shardingshere proxy connection limit Issue[#13132] modiy exception msg
---
.../db/protocol/error/CommonErrorCode.java | 4 +-
.../properties/ConfigurationPropertyKey.java | 7 +-
.../src/main/resources/conf/server.yaml | 1 +
.../connection/ConnectionLimitContext.java | 78 ++++++++++++++++++++++
.../FrontendConnectionLimitException.java | 32 ++-------
.../FrontendChannelLimitationInboundHandler.java | 53 +++++++++++++++
.../frontend/netty/ServerHandlerInitializer.java | 1 +
.../mysql/command/MySQLCommandExecuteEngine.java | 7 +-
.../frontend/mysql/err/MySQLErrPacketFactory.java | 11 ++-
.../command/OpenGaussCommandExecuteEngine.java | 7 +-
.../opengauss/err/OpenGaussErrorPacketFactory.java | 1 +
.../command/PostgreSQLCommandExecuteEngine.java | 7 +-
.../postgresql/err/PostgreSQLErrPacketFactory.java | 1 +
.../frontend/command/CommandExecuteEngine.java | 10 ++-
14 files changed, 186 insertions(+), 34 deletions(-)
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-core/src/main/java/org/apache/shardingsphere/db/protocol/error/CommonErrorCode.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-core/src/main/java/org/apache/shardingsphere/db/protocol/error/CommonErrorCode.java
index 5f97e4a..fb479af 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-core/src/main/java/org/apache/shardingsphere/db/protocol/error/CommonErrorCode.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-core/src/main/java/org/apache/shardingsphere/db/protocol/error/CommonErrorCode.java
@@ -36,7 +36,9 @@ public enum CommonErrorCode implements SQLErrorCode {
TABLE_LOCK_WAIT_TIMEOUT(1301, "C1301", "The table %s of schema %s lock wait timeout of %s ms exceeded"),
TABLE_LOCKED(1302, "C1302", "The table %s of schema %s is locked"),
-
+
+ TOO_MANY_CONNECTIONS_EXCEPTION(1040, "08004", "Too many connections"),
+
RUNTIME_EXCEPTION(1997, "C1997", "Runtime exception: [%s]"),
UNSUPPORTED_COMMAND(1998, "C1998", "Unsupported command: [%s]"),
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/properties/ConfigurationPropertyKey.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/properties/ConfigurationPropertyKey.java
index 2e3e905..e8c35e1 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/properties/ConfigurationPropertyKey.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/properties/ConfigurationPropertyKey.java
@@ -113,7 +113,12 @@ public enum ConfigurationPropertyKey implements TypedPropertyKey {
* 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("proxy-backend-executor-suitable", "OLAP", String.class);
+ PROXY_BACKEND_EXECUTOR_SUITABLE("proxy-backend-executor-suitable", "OLAP", String.class),
+
+ /**
+ * Proxy connection num limit. less than 0 or equal 0 means no limit.
+ */
+ PROXY_FRONTEND_CONNECTION_LIMIT("proxy-frontend-connection-limit", "-1", int.class);
private final String key;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/server.yaml b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/server.yaml
index 7d00b63..0498cad 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/server.yaml
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/server.yaml
@@ -74,3 +74,4 @@
# # 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
+# proxy-frontend-connection-limit: -1 # Proxy connection limit, less than 0 or equal 0 means no limit.
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/connection/ConnectionLimitContext.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/connection/ConnectionLimitContext.java
new file mode 100644
index 0000000..bc5779d
--- /dev/null
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/connection/ConnectionLimitContext.java
@@ -0,0 +1,78 @@
+/*
+ * 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.proxy.frontend.connection;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+/**
+ * Connection limit context.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class ConnectionLimitContext {
+
+ private static final ConnectionLimitContext INSTANCE = new ConnectionLimitContext();
+
+ private final AtomicInteger activeConnections = new AtomicInteger();
+
+ /**
+ * Get instance of ConnectionLimitContext.
+ *
+ * @return instance of ConnectionLimitContext.
+ */
+ public static ConnectionLimitContext getInstance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Channel active state.
+ * @return Whether the connection can be established.
+ */
+ public boolean connect() {
+ if (this.getConnectionLimit() <= 0) {
+ return true;
+ }
+ if (this.activeConnections.incrementAndGet() <= this.getConnectionLimit()) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Channel inactive state.
+ */
+ public void disconnect() {
+ if (this.getConnectionLimit() <= 0) {
+ return;
+ }
+ this.activeConnections.decrementAndGet();
+ }
+
+ /**
+ * Connection limit size.
+ * @return limit size.
+ */
+ public int getConnectionLimit() {
+ return ProxyContext.getInstance().getContextManager().getMetaDataContexts().getProps().<Integer>getValue(ConfigurationPropertyKey.PROXY_FRONTEND_CONNECTION_LIMIT);
+ }
+}
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-core/src/main/java/org/apache/shardingsphere/db/protocol/error/CommonErrorCode.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/exception/FrontendConnectionLimitException.java
similarity index 50%
copy from shardingsphere-db-protocol/shardingsphere-db-protocol-core/src/main/java/org/apache/shardingsphere/db/protocol/error/CommonErrorCode.java
copy to shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/exception/FrontendConnectionLimitException.java
index 5f97e4a..ff160e6 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-core/src/main/java/org/apache/shardingsphere/db/protocol/error/CommonErrorCode.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/exception/FrontendConnectionLimitException.java
@@ -15,37 +15,19 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.db.protocol.error;
+package org.apache.shardingsphere.proxy.frontend.exception;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
/**
- * Common error code.
+ * Frontend connection limit exception.
*/
@RequiredArgsConstructor
@Getter
-public enum CommonErrorCode implements SQLErrorCode {
-
- CIRCUIT_BREAK_MODE(1000, "C1000", "Circuit break mode is ON."),
-
- SCALING_JOB_NOT_EXIST(1201, "C1201", "Scaling job %s does not exist."),
-
- SCALING_OPERATE_FAILED(1209, "C1209", "Scaling Operate Failed: [%s]"),
-
- TABLE_LOCK_WAIT_TIMEOUT(1301, "C1301", "The table %s of schema %s lock wait timeout of %s ms exceeded"),
-
- TABLE_LOCKED(1302, "C1302", "The table %s of schema %s is locked"),
-
- RUNTIME_EXCEPTION(1997, "C1997", "Runtime exception: [%s]"),
-
- UNSUPPORTED_COMMAND(1998, "C1998", "Unsupported command: [%s]"),
-
- UNKNOWN_EXCEPTION(1999, "C1999", "Unknown exception: [%s]");
-
- private final int errorCode;
-
- private final String sqlState;
-
- private final String errorMessage;
+public final class FrontendConnectionLimitException extends FrontendException {
+
+ private static final long serialVersionUID = -4397915988239251541L;
+
+ private final String message;
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelLimitationInboundHandler.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelLimitationInboundHandler.java
new file mode 100644
index 0000000..758faef
--- /dev/null
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelLimitationInboundHandler.java
@@ -0,0 +1,53 @@
+/*
+ * 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.proxy.frontend.netty;
+
+import org.apache.shardingsphere.proxy.frontend.connection.ConnectionLimitContext;
+import org.apache.shardingsphere.proxy.frontend.exception.FrontendConnectionLimitException;
+import org.apache.shardingsphere.proxy.frontend.spi.DatabaseProtocolFrontendEngine;
+
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * Frontend channel limitation inbound handler.
+ */
+@Slf4j
+@RequiredArgsConstructor
+public class FrontendChannelLimitationInboundHandler extends ChannelInboundHandlerAdapter {
+
+ private final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine;
+
+ @Override
+ public void channelActive(final ChannelHandlerContext ctx) throws Exception {
+ if (ConnectionLimitContext.getInstance().connect()) {
+ ctx.fireChannelActive();
+ } else {
+ log.debug("Close channel {}, The server connections greater than {}", ctx.channel().remoteAddress(), ConnectionLimitContext.getInstance().getConnectionLimit());
+ ctx.writeAndFlush(databaseProtocolFrontendEngine.getCommandExecuteEngine().getErrorPacket(new FrontendConnectionLimitException("The number of connections exceeds the limit")));
+ ctx.close();
+ }
+ }
+
+ @Override
+ public void channelInactive(final ChannelHandlerContext ctx) throws Exception {
+ ConnectionLimitContext.getInstance().disconnect();
+ }
+}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/ServerHandlerInitializer.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/ServerHandlerInitializer.java
index ffe54ac..15452fe 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/ServerHandlerInitializer.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/netty/ServerHandlerInitializer.java
@@ -39,6 +39,7 @@ public final class ServerHandlerInitializer extends ChannelInitializer<SocketCha
DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine = DatabaseProtocolFrontendEngineFactory.newInstance(databaseType);
ChannelPipeline pipeline = socketChannel.pipeline();
pipeline.addLast(new PacketCodec(databaseProtocolFrontendEngine.getCodecEngine()));
+ pipeline.addLast(new FrontendChannelLimitationInboundHandler(databaseProtocolFrontendEngine));
pipeline.addLast(new FrontendChannelInboundHandler(databaseProtocolFrontendEngine));
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecuteEngine.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecuteEngine.java
index ba40309..c3f5aa3 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecuteEngine.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecuteEngine.java
@@ -64,7 +64,12 @@ public final class MySQLCommandExecuteEngine implements CommandExecuteEngine {
public DatabasePacket<?> getErrorPacket(final Exception cause, final BackendConnection backendConnection) {
return MySQLErrPacketFactory.newInstance(cause);
}
-
+
+ @Override
+ public DatabasePacket<?> getErrorPacket(final Exception cause) {
+ return MySQLErrPacketFactory.newInstance(cause);
+ }
+
@Override
public Optional<DatabasePacket<?>> getOtherPacket(final BackendConnection backendConnection) {
return Optional.empty();
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactory.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactory.java
index dc48c7b..b5175b6 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactory.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.proxy.frontend.mysql.err;
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
+import java.sql.SQLException;
+
import org.apache.shardingsphere.db.protocol.error.CommonErrorCode;
import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLServerErrorCode;
import org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLErrPacket;
@@ -36,6 +36,7 @@ import org.apache.shardingsphere.proxy.backend.exception.TableModifyInTransactio
import org.apache.shardingsphere.proxy.backend.exception.UnknownDatabaseException;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.exception.CommonDistSQLErrorCode;
import org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.exception.CommonDistSQLException;
+import org.apache.shardingsphere.proxy.frontend.exception.FrontendConnectionLimitException;
import org.apache.shardingsphere.proxy.frontend.exception.UnsupportedCommandException;
import org.apache.shardingsphere.proxy.frontend.exception.UnsupportedPreparedStatementException;
import org.apache.shardingsphere.scaling.core.common.exception.ScalingJobNotFoundException;
@@ -43,7 +44,8 @@ import org.apache.shardingsphere.sharding.route.engine.exception.NoSuchTableExce
import org.apache.shardingsphere.sharding.route.engine.exception.TableExistsException;
import org.apache.shardingsphere.sql.parser.exception.SQLParsingException;
-import java.sql.SQLException;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
/**
* ERR packet factory for MySQL.
@@ -119,6 +121,9 @@ public final class MySQLErrPacketFactory {
if (cause instanceof RuntimeException) {
return new MySQLErrPacket(1, CommonErrorCode.RUNTIME_EXCEPTION, cause.getMessage());
}
+ if (cause instanceof FrontendConnectionLimitException) {
+ return new MySQLErrPacket(1, CommonErrorCode.TOO_MANY_CONNECTIONS_EXCEPTION, CommonErrorCode.TOO_MANY_CONNECTIONS_EXCEPTION.getErrorMessage());
+ }
return new MySQLErrPacket(1, CommonErrorCode.UNKNOWN_EXCEPTION, cause.getMessage());
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/OpenGaussCommandExecuteEngine.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/OpenGaussCommandExecuteEngine.java
index 29a2220..1609036 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/OpenGaussCommandExecuteEngine.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/OpenGaussCommandExecuteEngine.java
@@ -65,7 +65,12 @@ public final class OpenGaussCommandExecuteEngine implements CommandExecuteEngine
PostgreSQLConnectionContextRegistry.getInstance().get(backendConnection.getConnectionId()).getPendingExecutors().clear();
return OpenGaussErrorPacketFactory.newInstance(cause);
}
-
+
+ @Override
+ public DatabasePacket<?> getErrorPacket(final Exception cause) {
+ return OpenGaussErrorPacketFactory.newInstance(cause);
+ }
+
@Override
public Optional<DatabasePacket<?>> getOtherPacket(final BackendConnection backendConnection) {
return postgreSQLCommandExecuteEngine.getOtherPacket(backendConnection);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/err/OpenGaussErrorPacketFactory.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/err/OpenGaussErrorPacketFactory.java
index a3249c0..79a0369 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/err/OpenGaussErrorPacketFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/main/java/org/apache/shardingsphere/proxy/frontend/opengauss/err/OpenGaussErrorPacketFactory.java
@@ -84,6 +84,7 @@ public final class OpenGaussErrorPacketFactory {
if (cause instanceof PostgreSQLAuthenticationException) {
return new OpenGaussErrorResponsePacket(PostgreSQLMessageSeverityLevel.FATAL, ((PostgreSQLAuthenticationException) cause).getErrorCode().getErrorCode(), cause.getMessage());
}
+ // TODO OpenGauss need consider FrontendConnectionLimitException
return createErrorResponsePacketForUnknownException(cause);
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngine.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngine.java
index 14a9cf1..b660fe8 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngine.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngine.java
@@ -81,7 +81,12 @@ public final class PostgreSQLCommandExecuteEngine implements CommandExecuteEngin
}
return PostgreSQLErrPacketFactory.newInstance(cause);
}
-
+
+ @Override
+ public DatabasePacket<?> getErrorPacket(final Exception cause) {
+ return PostgreSQLErrPacketFactory.newInstance(cause);
+ }
+
@Override
public Optional<DatabasePacket<?>> getOtherPacket(final BackendConnection backendConnection) {
PostgreSQLConnectionContext connectionContext = PostgreSQLConnectionContextRegistry.getInstance().get(backendConnection.getConnectionId());
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/err/PostgreSQLErrPacketFactory.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/err/PostgreSQLErrPacketFactory.java
index 1e01131..4aba54a 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/err/PostgreSQLErrPacketFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/err/PostgreSQLErrPacketFactory.java
@@ -61,6 +61,7 @@ public final class PostgreSQLErrPacketFactory {
if (cause instanceof PostgreSQLAuthenticationException) {
return PostgreSQLErrorResponsePacket.newBuilder(PostgreSQLMessageSeverityLevel.FATAL, ((PostgreSQLAuthenticationException) cause).getErrorCode(), cause.getMessage()).build();
}
+ // TODO PostgreSQL need consider FrontendConnectionLimitException
return createErrorResponsePacketForUnknownException(cause);
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-spi/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecuteEngine.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-spi/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecuteEngine.java
index 041ff3d..533e2c8 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-spi/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecuteEngine.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-spi/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecuteEngine.java
@@ -72,7 +72,15 @@ public interface CommandExecuteEngine {
* @return error packet
*/
DatabasePacket<?> getErrorPacket(Exception cause, BackendConnection backendConnection);
-
+
+ /**
+ * Get error packet.
+ *
+ * @param cause cause of error
+ * @return error packet
+ */
+ DatabasePacket<?> getErrorPacket(Exception cause);
+
/**
* Get other packet.
*