修复调度器空缓存导致的竞态条件bug

当新分组创建后立即绑定账号时,调度器会错误地将空快照视为有效缓存命中,
导致返回没有可调度的账号。现在空快照会触发数据库回退查询。
This commit is contained in:
shaw
2026-01-28 17:26:32 +08:00
parent 269a659200
commit e12dd079fd

View File

@@ -58,7 +58,9 @@ func (c *schedulerCache) GetSnapshot(ctx context.Context, bucket service.Schedul
return nil, false, err return nil, false, err
} }
if len(ids) == 0 { if len(ids) == 0 {
return []*service.Account{}, true, nil // 空快照视为缓存未命中,触发数据库回退查询
// 这解决了新分组创建后立即绑定账号时的竞态条件问题
return nil, false, nil
} }
keys := make([]string, 0, len(ids)) keys := make([]string, 0, len(ids))