feat: enforce shared application resource quotas across namespaces

This commit is contained in:
2026-09-17 17:57:54 +08:00
parent 5c8825e4bc
commit 993786476e
43 changed files with 1606 additions and 49 deletions

View File

@@ -59,7 +59,10 @@ func (s *ExecutionStore) Recover(ctx context.Context, limit int) (worker.Recover
out.Examined++
var changed pulse.TaskState
err := WithTx(ctx, s.db, func(tx *sql.Tx) error {
// 队列 → 任务 → 尝试 → 许可;忙碌资源留给下一批。
// 应用额度 → 队列 → 任务 → 尝试 → 许可;忙碌资源留给下一批。
if ok, err := lockApplicationResources(ctx, tx, c.ns, true); err != nil || !ok {
return err
}
var queue core.ID
err := tx.QueryRowContext(ctx, `SELECT id FROM pulse_queues WHERE namespace_id=? AND id=? FOR UPDATE SKIP LOCKED`, c.ns, c.queue).Scan(&queue)
if errors.Is(err, sql.ErrNoRows) {