为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】: DM8,DB Version:0x7000d
【操作系统】:Win10 x64
【CPU】: Intel I7
【问题描述】*:
使用包:
dm-go-driver\dm 8.1.4.80 和 gorm_v2_dialect
设置DSN:
dsn := "dm://SYSDBA:XXXXXXXX@localhost:5236?connectTimeout=5000&socketTimeout=5&sessionTimeout=5";
在使用如下代码执行SQL:
func UpdateUser(db *gorm.DB, name string) (Model, error) {
ctx, cancel := context.WithTimeout(context.Background(), 5time.Second)
defer cancel()
var result Model
err := db.WithContext(ctx).Where("name = ?", name).Update(&result).Error
return &result, err
}
如果有另一个程序B在执行该UPDATE操作并未结束或提交,当前程序A会进入等待,但是在以上DSN和context.WithTimeout(context.Background(), 5*time.Second)已设置超时的前提下,无法实现A在等待5秒后如果无法继续执行则退出的效果。
达梦的这驱动很幽默,本身一个简单的超时参数MySQL就很简单,达梦非得做的很不讲道理,你看我之前提的超时问题,他们官方有没有认真在回答,也不知道他们每天在干嘛?
https://eco.dameng.com/community/question/335bba15f01d1e89a36e3589fce3697f