Skip to content

Commit 9fed5f4

Browse files
fix: Fixed issue with database locked (#9898)
Refs #9896
1 parent b3a55ea commit 9fed5f4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

agent/app/repo/app_tag.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type IAppTagRepo interface {
1717
GetByAppId(appId uint) ([]model.AppTag, error)
1818
GetByTagIds(tagIds []uint) ([]model.AppTag, error)
1919
DeleteBy(ctx context.Context, opts ...DBOption) error
20-
GetFirst(opts ...DBOption) (*model.AppTag, error)
20+
GetFirst(ctx context.Context, opts ...DBOption) (*model.AppTag, error)
2121

2222
WithByTagID(tagID uint) DBOption
2323
WithByAppID(appId uint) DBOption
@@ -71,9 +71,9 @@ func (a AppTagRepo) DeleteBy(ctx context.Context, opts ...DBOption) error {
7171
return getTx(ctx, opts...).Delete(&model.AppTag{}).Error
7272
}
7373

74-
func (a AppTagRepo) GetFirst(opts ...DBOption) (*model.AppTag, error) {
74+
func (a AppTagRepo) GetFirst(ctx context.Context, opts ...DBOption) (*model.AppTag, error) {
7575
var appTag model.AppTag
76-
if err := getDb(opts...).First(&appTag).Error; err != nil {
76+
if err := getTx(ctx, opts...).First(&appTag).Error; err != nil {
7777
return nil, err
7878
}
7979
return &appTag, nil

agent/app/service/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ func (a AppService) SyncAppListFromRemote(taskID string) (err error) {
10741074
for _, tag := range app.TagsKey {
10751075
tagId, ok := tagMap[tag]
10761076
if ok {
1077-
exist, _ := appTagRepo.GetFirst(appTagRepo.WithByTagID(tagId), appTagRepo.WithByAppID(app.ID))
1077+
exist, _ := appTagRepo.GetFirst(ctx, appTagRepo.WithByTagID(tagId), appTagRepo.WithByAppID(app.ID))
10781078
if exist != nil {
10791079
appTags = append(appTags, &model.AppTag{
10801080
AppId: app.ID,

0 commit comments

Comments
 (0)