You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2024/12/28 15:23:49 UTC

(shardingsphere) branch master updated: Add LockSQLException (#34193)

This is an automated email from the ASF dual-hosted git repository.

zhangliang 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 6d7d680b751 Add LockSQLException (#34193)
6d7d680b751 is described below

commit 6d7d680b75172759619b2b095acfb9cf2f73bf72
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sat Dec 28 23:23:43 2024 +0800

    Add LockSQLException (#34193)
---
 .../user-manual/error-code/sql-error-code.cn.md        |  9 +++++++--
 .../user-manual/error-code/sql-error-code.en.md        |  9 +++++++--
 .../sql/type/kernel/category/LockSQLException.java     | 18 ++++++++++--------
 .../{ => lock}/exception/LockedClusterException.java   |  6 +++---
 .../exception/NotLockedClusterException.java           |  6 +++---
 .../distsql/ral/updatable/LockClusterExecutor.java     |  2 +-
 .../distsql/ral/updatable/UnlockClusterExecutor.java   |  2 +-
 .../distsql/ral/updatable/LockClusterExecutorTest.java |  2 +-
 .../ral/updatable/UnlockClusterExecutorTest.java       |  2 +-
 9 files changed, 34 insertions(+), 22 deletions(-)

diff --git a/docs/document/content/user-manual/error-code/sql-error-code.cn.md b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
index 0845881f875..a09db6bb79f 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.cn.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
@@ -100,6 +100,13 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 | 14400       | 44000     | No application id within 'seata.conf' file.                                               |
 | 14401       | 25000     | Seata-AT transaction has been disabled.                                                   |
 
+### 锁
+
+| Vendor Code | SQL State | 错误信息                       |
+|-------------|-----------|----------------------------|
+| 15030       | HY000     | Cluster is already locked. |
+| 15031       | HY000     | Cluster is not locked.     |
+
 ### 集群
 
 | Vendor Code | SQL State | 错误信息                                                          |
@@ -108,8 +115,6 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 | 17001       | HY000     | Worker ID assigned failed, which should be in [0, %s).        |
 | 17010       | HY000     | Cluster persist repository error, reason is: %s               |
 | 17020       | HY000     | The cluster status is %s, can not support SQL statement '%s'. |
-| 17030       | HY000     | Cluster is already locked.                                    |
-| 17031       | HY000     | Cluster is not locked.                                        |
 | 17100       | 42S02     | Cluster persist repository configuration is required.         |
 
 ### 数据管道
diff --git a/docs/document/content/user-manual/error-code/sql-error-code.en.md b/docs/document/content/user-manual/error-code/sql-error-code.en.md
index 4359e8d65c1..282e53f2ea8 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.en.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.en.md
@@ -100,6 +100,13 @@ SQL error codes provide by standard `SQL State`, `Vendor Code` and `Reason`, whi
 | 14400       | 44000     | No application id within 'seata.conf' file.                                               |
 | 14401       | 25000     | Seata-AT transaction has been disabled.                                                   |
 
+### Lock
+
+| Vendor Code | SQL State | Reason                     |
+|-------------|-----------|----------------------------|
+| 15030       | HY000     | Cluster is already locked. |
+| 15031       | HY000     | Cluster is not locked.     |
+
 ### Cluster
 
 | Vendor Code | SQL State | Reason                                                        |
@@ -108,8 +115,6 @@ SQL error codes provide by standard `SQL State`, `Vendor Code` and `Reason`, whi
 | 17001       | HY000     | Worker ID assigned failed, which should be in [0, %s).        |
 | 17010       | HY000     | Cluster persist repository error, reason is: %s               |
 | 17020       | HY000     | The cluster status is %s, can not support SQL statement '%s'. |
-| 17030       | HY000     | Cluster is already locked.                                    |
-| 17031       | HY000     | Cluster is not locked.                                        |
 | 17100       | 42S02     | Cluster persist repository configuration is required.         |
 
 ### Data Pipeline
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/exception/LockedClusterException.java b/infra/exception/core/src/main/java/org/apache/shardingsphere/infra/exception/core/external/sql/type/kernel/category/LockSQLException.java
similarity index 62%
copy from mode/core/src/main/java/org/apache/shardingsphere/mode/exception/LockedClusterException.java
copy to infra/exception/core/src/main/java/org/apache/shardingsphere/infra/exception/core/external/sql/type/kernel/category/LockSQLException.java
index 88f24c2f253..1797f0cdc76 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/exception/LockedClusterException.java
+++ b/infra/exception/core/src/main/java/org/apache/shardingsphere/infra/exception/core/external/sql/type/kernel/category/LockSQLException.java
@@ -15,19 +15,21 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.mode.exception;
+package org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category;
 
-import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
-import org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.ClusterSQLException;
+import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.SQLState;
+import org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.KernelSQLException;
 
 /**
- * Locked cluster exception.
+ * Lock SQL exception.
  */
-public final class LockedClusterException extends ClusterSQLException {
+public abstract class LockSQLException extends KernelSQLException {
     
-    private static final long serialVersionUID = 122184861309346827L;
+    private static final long serialVersionUID = 7889797502163128147L;
     
-    public LockedClusterException() {
-        super(XOpenSQLState.GENERAL_ERROR, 30, "Cluster is already locked.");
+    private static final int KERNEL_CODE = 5;
+    
+    public LockSQLException(final SQLState sqlState, final int errorCode, final String reason, final Object... messageArguments) {
+        super(sqlState, KERNEL_CODE, errorCode, reason, messageArguments);
     }
 }
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/exception/LockedClusterException.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/lock/exception/LockedClusterException.java
similarity index 87%
rename from mode/core/src/main/java/org/apache/shardingsphere/mode/exception/LockedClusterException.java
rename to mode/core/src/main/java/org/apache/shardingsphere/mode/lock/exception/LockedClusterException.java
index 88f24c2f253..f41cb0ad837 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/exception/LockedClusterException.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/lock/exception/LockedClusterException.java
@@ -15,15 +15,15 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.mode.exception;
+package org.apache.shardingsphere.mode.lock.exception;
 
 import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
-import org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.ClusterSQLException;
+import org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.LockSQLException;
 
 /**
  * Locked cluster exception.
  */
-public final class LockedClusterException extends ClusterSQLException {
+public final class LockedClusterException extends LockSQLException {
     
     private static final long serialVersionUID = 122184861309346827L;
     
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/exception/NotLockedClusterException.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/lock/exception/NotLockedClusterException.java
similarity index 87%
rename from mode/core/src/main/java/org/apache/shardingsphere/mode/exception/NotLockedClusterException.java
rename to mode/core/src/main/java/org/apache/shardingsphere/mode/lock/exception/NotLockedClusterException.java
index 117cd86978a..af2186df694 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/exception/NotLockedClusterException.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/lock/exception/NotLockedClusterException.java
@@ -15,15 +15,15 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.mode.exception;
+package org.apache.shardingsphere.mode.lock.exception;
 
 import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
-import org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.ClusterSQLException;
+import org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.LockSQLException;
 
 /**
  * Not locked cluster exception.
  */
-public final class NotLockedClusterException extends ClusterSQLException {
+public final class NotLockedClusterException extends LockSQLException {
     
     private static final long serialVersionUID = -9181518142445461894L;
     
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/LockClusterExecutor.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/LockClusterExecutor.java
index 00cd54cd9fe..cba160afa02 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/LockClusterExecutor.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/LockClusterExecutor.java
@@ -26,7 +26,7 @@ import org.apache.shardingsphere.infra.exception.core.external.sql.identifier.SQ
 import org.apache.shardingsphere.infra.lock.LockContext;
 import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
 import org.apache.shardingsphere.infra.state.cluster.ClusterState;
-import org.apache.shardingsphere.mode.exception.LockedClusterException;
+import org.apache.shardingsphere.mode.lock.exception.LockedClusterException;
 import org.apache.shardingsphere.mode.lock.global.GlobalLockDefinition;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.lock.ClusterLock;
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/UnlockClusterExecutor.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/UnlockClusterExecutor.java
index 94d992aaac8..e1d6e423fce 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/UnlockClusterExecutor.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/UnlockClusterExecutor.java
@@ -23,7 +23,7 @@ import org.apache.shardingsphere.distsql.statement.ral.updatable.UnlockClusterSt
 import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import org.apache.shardingsphere.infra.lock.LockContext;
 import org.apache.shardingsphere.infra.state.cluster.ClusterState;
-import org.apache.shardingsphere.mode.exception.NotLockedClusterException;
+import org.apache.shardingsphere.mode.lock.exception.NotLockedClusterException;
 import org.apache.shardingsphere.mode.lock.global.GlobalLockDefinition;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable.lock.ClusterLock;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/LockClusterExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/LockClusterExecutorTest.java
index 4fae2b0b407..7e86f7bcbec 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/LockClusterExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/LockClusterExecutorTest.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.distsql.segment.AlgorithmSegment;
 import org.apache.shardingsphere.distsql.statement.ral.updatable.LockClusterStatement;
 import org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
 import org.apache.shardingsphere.infra.state.cluster.ClusterState;
-import org.apache.shardingsphere.mode.exception.LockedClusterException;
+import org.apache.shardingsphere.mode.lock.exception.LockedClusterException;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 import org.apache.shardingsphere.test.mock.AutoMockExtension;
diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/UnlockClusterExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/UnlockClusterExecutorTest.java
index 076ff500c77..58bc57722d1 100644
--- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/UnlockClusterExecutorTest.java
+++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/UnlockClusterExecutorTest.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.proxy.backend.handler.distsql.ral.updatable;
 
 import org.apache.shardingsphere.distsql.statement.ral.updatable.UnlockClusterStatement;
 import org.apache.shardingsphere.infra.state.cluster.ClusterState;
-import org.apache.shardingsphere.mode.exception.NotLockedClusterException;
+import org.apache.shardingsphere.mode.lock.exception.NotLockedClusterException;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 import org.apache.shardingsphere.test.mock.AutoMockExtension;