feat: enforce shared application resource quotas across namespaces
This commit is contained in:
@@ -72,7 +72,10 @@ func (s *ScheduleStore) tickOne(ctx context.Context, ns, id, queue core.ID) (int
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// 和任务执行一致先锁队列,再锁计划;其他扫描节点不等待同一计划所在队列。
|
||||
// 应用额度 → 队列 → 计划;忙碌资源留给下一批。
|
||||
if ok, err := lockApplicationResources(ctx, tx, ns, true); err != nil || !ok {
|
||||
return err
|
||||
}
|
||||
err = tx.QueryRowContext(ctx, `SELECT id FROM pulse_queues WHERE namespace_id=? AND id=? FOR UPDATE SKIP LOCKED`, ns, queue).Scan(&allowed)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil
|
||||
@@ -156,7 +159,7 @@ func (s *ScheduleStore) tickOne(ctx context.Context, ns, id, queue core.ID) (int
|
||||
backpressured := false
|
||||
for _, decision := range batch.Decisions {
|
||||
if err := s.saveOccurrence(ctx, tx, v, version, decision, now); err != nil {
|
||||
if errors.Is(err, fault.QueueFull) {
|
||||
if errors.Is(err, fault.QueueFull) || errors.Is(err, fault.ApplicationFull) {
|
||||
// 已提交本批较早的决定仍保留;满额的原触发点留待下次按冻结策略处理。
|
||||
t := decision.ScheduledAt
|
||||
next, backpressured = &t, true
|
||||
|
||||
Reference in New Issue
Block a user