Compare commits

..

3 Commits

Author SHA1 Message Date
ning
36569af554 fix: target update sync 2026-03-04 20:50:54 +08:00
ning
2b89ccf43c fix: doris timeout 2026-03-04 11:30:02 +08:00
ning
6a9ecee1bc fix: doris timeout 2026-03-04 11:25:21 +08:00
3 changed files with 18 additions and 5 deletions

View File

@@ -191,6 +191,7 @@ func HandleHeartbeat(c *gin.Context, ctx *ctx.Context, engineName string, metaSe
}
if targetNeedUpdate {
newTarget.UpdateAt = time.Now().Unix()
err := models.DB(ctx).Model(&target).Updates(newTarget).Error
if err != nil {
logger.Errorf("update target fields failed, err: %v", err)

View File

@@ -201,7 +201,7 @@ func (d *Doris) NewWriteConn(ctx context.Context, database string) (*sql.DB, err
func (d *Doris) createTimeoutContext(ctx context.Context) (context.Context, context.CancelFunc) {
timeout := d.Timeout
if timeout == 0 {
timeout = 60
timeout = 60000
}
return context.WithTimeout(ctx, time.Duration(timeout)*time.Millisecond)
}

View File

@@ -87,7 +87,7 @@ func TargetBindBgids(ctx *ctx.Context, idents []string, bgids []int64, tags []st
}
return DB(ctx).Transaction(func(tx *gorm.DB) error {
if err := DB(ctx).Clauses(cl).CreateInBatches(&lst, 10).Error; err != nil {
if err := tx.Clauses(cl).CreateInBatches(&lst, 10).Error; err != nil {
return err
}
if targets, err := TargetsGetByIdents(ctx, idents); err != nil {
@@ -100,13 +100,24 @@ func TargetBindBgids(ctx *ctx.Context, idents []string, bgids []int64, tags []st
}
}
// update target.update_at so that syncTargets can detect the change and refresh GroupIds cache
if err := tx.Model(&Target{}).Where("ident in ?", idents).Update("update_at", updateAt).Error; err != nil {
return err
}
return nil
})
}
func TargetUnbindBgids(ctx *ctx.Context, idents []string, bgids []int64) error {
return DB(ctx).Where("target_ident in ? and group_id in ?",
idents, bgids).Delete(&TargetBusiGroup{}).Error
return DB(ctx).Transaction(func(tx *gorm.DB) error {
if err := tx.Where("target_ident in ? and group_id in ?",
idents, bgids).Delete(&TargetBusiGroup{}).Error; err != nil {
return err
}
// update target.update_at so that syncTargets can detect the change and refresh GroupIds cache
return tx.Model(&Target{}).Where("ident in ?", idents).Update("update_at", time.Now().Unix()).Error
})
}
func TargetDeleteBgids(tx *gorm.DB, idents []string) error {
@@ -150,7 +161,8 @@ func TargetOverrideBgids(ctx *ctx.Context, idents []string, bgids []int64, tags
return err
}
if len(tags) == 0 {
return nil
// update target.update_at so that syncTargets can detect the change and refresh GroupIds cache
return tx.Model(&Target{}).Where("ident IN ?", idents).Update("update_at", updateAt).Error
}
return tx.Model(Target{}).Where("ident IN ?", idents).Updates(map[string]interface{}{