Merge branch 'master' into main-dmdb

# Conflicts:
#	db/db.go
This commit is contained in:
2026-04-11 21:54:37 +08:00
3 changed files with 179 additions and 10 deletions
+14 -1
View File
@@ -95,7 +95,12 @@ func (that *HoTimeDB) queryWithRetry(query string, retried bool, args ...interfa
that.LastErr.SetError(err)
if err != nil {
if !retried {
if that.Tx != nil {
if that.txFailed != nil {
*that.txFailed = true
}
}
if !retried && that.Tx == nil {
if pingErr := db.Ping(); pingErr == nil {
return that.queryWithRetry(query, true, args...)
}
@@ -169,6 +174,14 @@ func (that *HoTimeDB) execWithRetry(query string, retried bool, args ...interfac
if that.testTx != nil {
return resl, that.LastErr
}
// 事务内不做连接级重试:死锁等错误会导致 MySQL 自动回滚事务,
// 在已回滚的 Tx 上重试会以 auto-commit 模式执行,造成数据不一致
if that.Tx != nil {
if that.txFailed != nil {
*that.txFailed = true
}
return resl, that.LastErr
}
if !retried {
if pingErr := that.DB.Ping(); pingErr == nil {
return that.execWithRetry(query, true, args...)