fix(通道流量阈值): AUG26-011 修复周期处理连接池自锁并补齐根池句柄验证与文档
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
This commit is contained in:
@@ -297,13 +297,25 @@ func (s *Service) markTaskConfirmed(ctx context.Context, lockID uint, task lockT
|
||||
return s.markTaskOutcome(ctx, lockID, task, domain.UnresolvedTaskStatuses(), domain.TaskStatusConfirmed, integrationID, "")
|
||||
}
|
||||
|
||||
// markAnomaly 把锁标记为需人工核对并退出自动扫描。
|
||||
// markAnomaly 把锁标记为需人工核对并退出自动扫描(使用服务自身连接池,调用方不得已持有该行锁)。
|
||||
// 只应在窗口超期且结果无法确认时调用;已标记的锁不再重复查询。
|
||||
func (s *Service) markAnomaly(ctx context.Context, lockID uint, reason string) (bool, error) {
|
||||
if s == nil || s.db == nil || lockID == 0 {
|
||||
if s == nil || s.db == nil {
|
||||
return false, nil
|
||||
}
|
||||
result := s.db.WithContext(ctx).Model(&model.CarrierTrafficThresholdLock{}).
|
||||
return s.markAnomalyInTx(ctx, s.db, lockID, reason)
|
||||
}
|
||||
|
||||
// markAnomalyInTx 在调用方事务内把锁标记为需人工核对(anomaly_flag=0 → 1 条件更新)。
|
||||
//
|
||||
// 调用方已在同一事务内写过该行时 MUST 使用本方法:改用服务自身连接池会让另一条连接
|
||||
// 等待本事务持有的行锁(自锁),表现为处理挂死到语句超时。返回 false 表示已被并发标记,
|
||||
// 调用方按幂等处理。
|
||||
func (s *Service) markAnomalyInTx(ctx context.Context, tx *gorm.DB, lockID uint, reason string) (bool, error) {
|
||||
if tx == nil || lockID == 0 {
|
||||
return false, nil
|
||||
}
|
||||
result := tx.WithContext(ctx).Model(&model.CarrierTrafficThresholdLock{}).
|
||||
Where("id = ? AND anomaly_flag = ?", lockID, domain.AnomalyFlagNone).
|
||||
Updates(map[string]any{
|
||||
"anomaly_flag": domain.AnomalyFlagManual,
|
||||
|
||||
Reference in New Issue
Block a user