penghuazhou opened a new issue #13621:
URL: https://github.com/apache/shardingsphere/issues/13621
Thread stuck when I begin a transaction and throw a 重复键违反唯一约束 exception.
version: shardingsphere-proxy 5.0.0
`
import (
"fmt"
"gorm.io/driver/postgres"
"gorm.io/gorm"
"testing"
)
func TestShardingSphereTransactionRollback(t *testing.T) {
dsn := "host=119.23.43.207 user=sharding password=sharding
dbname=sharding_db port=3307" +
" sslmode=disable TimeZone=Asia/Shanghai client_encoding=UTF8"
db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})
if err != nil {
fmt.Println(err)
return
}
tx := db.Begin()
tx.Debug().Exec("insert into t_order(user_id,order_id,info)
values(12,12,'9')")
//tx.Debug().Exec("update t_order set info = 'test5' where user_id = 9
and order_id = 9")
//tx.Debug().Exec("update t_order set info = 'test5' where user_id = 9
and order_id = 9")
//tx.Rollback()
//tx.Debug().Exec("insert into t_order(user_id,order_id,info)
values(11,11,'9')")
tx.Commit()
}
`

Thanks for using Atomikos! Evaluate
http://www.atomikos.com/Main/ExtremeTransactions for advanced features and
professional support
or register at http://www.atomikos.com/Main/RegisterYourDownload to disable
this message and receive FREE tips & advice
[INFO ] 2021-11-15 19:44:40.995 [main]
o.a.s.p.i.i.AbstractBootstrapInitializer - Database name is `PostgreSQL`,
version is `9.2.24`
[INFO ] 2021-11-15 19:44:41.227 [main] o.a.s.p.frontend.ShardingSphereProxy
- ShardingSphere-Proxy start success.
Thanks for using Atomikos! Evaluate
http://www.atomikos.com/Main/ExtremeTransactions for advanced features and
professional support
or register at http://www.atomikos.com/Main/RegisterYourDownload to disable
this message and receive FREE tips & advice
[INFO ] 2021-11-15 19:48:02.450 [main]
o.a.s.p.i.i.AbstractBootstrapInitializer - Database name is `PostgreSQL`,
version is `9.2.24`
[INFO ] 2021-11-15 19:48:02.647 [main] o.a.s.p.frontend.ShardingSphereProxy
- ShardingSphere-Proxy start success.
[ERROR] 2021-11-15 19:49:19.360 [Connection-2-ThreadExecutor]
o.a.s.p.f.c.CommandExecutorTask - Exception occur:
org.postgresql.util.PSQLException: 错误: 重复键违反唯一约束"t_order_0_pkey"
详细:键值"(order_id)=(12)" 已经存在
at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440)
at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183)
at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:307)
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:293)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:270)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:266)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:1168)
at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:103)
at
com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java)
at
org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.callback.impl.ProxyStatementExecutorCallback.execute(ProxyStatementExecutorCallback.java:40)
at
org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.callback.ProxyJDBCExecutorCallback.executeSQL(ProxyJDBCExecutorCallback.java:73)
at
org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.callback.ProxyJDBCExecutorCallback.executeSQL(ProxyJDBCExecutorCallback.java:66)
at
org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.callback.ProxyJDBCExecutorCallback.executeSQL(ProxyJDBCExecutorCallback.java:44)
at
org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback.execute(JDBCExecutorCallback.java:85)
at
org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback.execute(JDBCExecutorCallback.java:64)
at
org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine.syncExecute(ExecutorEngine.java:101)
at
org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine.serialExecute(ExecutorEngine.java:87)
at
org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine.execute(ExecutorEngine.java:81)
at
org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutor.execute(JDBCExecutor.java:65)
at
org.apache.shardingsphere.proxy.backend.communication.jdbc.executor.ProxyJDBCExecutor.execute(ProxyJDBCExecutor.java:66)
at
org.apache.shardingsphere.proxy.backend.communication.ProxySQLExecutor.useDriverToExecute(ProxySQLExecutor.java:170)
at
org.apache.shardingsphere.proxy.backend.communication.ProxySQLExecutor.execute(ProxySQLExecutor.java:127)
at
org.apache.shardingsphere.proxy.backend.communication.ProxySQLExecutor.execute(ProxySQLExecutor.java:116)
at
org.apache.shardingsphere.proxy.backend.communication.ProxyLockEngine.doExecute(ProxyLockEngine.java:103)
at
org.apache.shardingsphere.proxy.backend.communication.ProxyLockEngine.execute(ProxyLockEngine.java:81)
at
org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine.execute(DatabaseCommunicationEngine.java:99)
at
org.apache.shardingsphere.proxy.backend.text.data.impl.SchemaAssignedDatabaseBackendHandler.execute(SchemaAssignedDatabaseBackendHandler.java:55)
at
org.apache.shardingsphere.proxy.frontend.postgresql.command.query.text.PostgreSQLComQueryExecutor.execute(PostgreSQLComQueryExecutor.java:63)
at
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:93)
at
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:71)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Exception in thread "Connection-2-ThreadExecutor"
java.lang.IllegalArgumentException: No enum constant
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLMessageSeverityLevel.错误
at java.lang.Enum.valueOf(Enum.java:238)
at
org.apache.shardingsphere.db.protocol.postgresql.constant.PostgreSQLMessageSeverityLevel.valueOf(PostgreSQLMessageSeverityLevel.java:25)
at
org.apache.shardingsphere.proxy.frontend.postgresql.err.PostgreSQLErrPacketFactory.createErrorResponsePacket(PostgreSQLErrPacketFactory.java:75)
at
org.apache.shardingsphere.proxy.frontend.postgresql.err.PostgreSQLErrPacketFactory.newInstance(PostgreSQLErrPacketFactory.java:48)
at
org.apache.shardingsphere.proxy.frontend.postgresql.command.PostgreSQLCommandExecuteEngine.getErrorPacket(PostgreSQLCommandExecuteEngine.java:72)
at
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.processException(CommandExecutorTask.java:108)
at
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:75)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
--
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]