-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There is a deadlock in gcache #3577
Comments
你的代码是什么呢,发出来看看 |
What is your code? Send it and take a look. |
// 创建表
create table issue3577(
id INT PRIMARY KEY NOT NULL,
name TEXT NOT NULL,
age INT NOT NULL
)
// 插入一条数据
insert into issue3577 values(1,'wln',28);
type Issue3577 struct {
Id int `orm:"id"`
Name string `orm:"name"`
Age int `orm:"age"`
}
func init(){
gdb.AddConfigNode("sqlite", gdb.ConfigNode{
Link: "sqlite::@file(/testdb.sqlite3)",
})
}
func Test_issue3577(t *testing.T) {
ctx := context.TODO()
sqlite := g.DB("sqlite")
key := "isssue3577"
t.Log("连接sqlite成功,开始查询")
v, err := gcache.GetOrSetFuncLock(ctx, key, func(ctx context.Context) (value interface{}, err error) {
return test_issue3557_getone(ctx, sqlite)
}, 0)
t.Log("查询结束")
if err != nil {
t.Fatal(err)
}
t.Log("val=", v.Interface())
}
func test_issue3557_getone(_ context.Context, db gdb.DB) (val any, err error) {
res, err := db.Model("issue3577").One()
if err != nil {
return nil, err
}
data := Issue3577{}
err = res.Struct(&data)
return data, err
} 运行命令 go test -timeout 30s -run ^Test_issue3577$ 问题出现在当执行gcache.GetOrSetFuncLock , |
pr #3579 可以解决此bug |
#3579 can solve this bug |
嗯嗯,我就是切换到默认的了 |
只能先这样用了 |
Yeah, okay, I just switched to the default one. |
This is the only way to use it first |
Let me handle this. |
Go version
go1.22.1
GoFrame version
2.7.0
Can this bug be reproduced with the latest release?
Option Yes
What did you do?
gcache.GetOrSetFuncLock
What did you see happen?
使用gcache.GetOrSetFuncLock会死锁
What did you expect to see?
正常运行
The text was updated successfully, but these errors were encountered: