fix(admission): 按候选唤醒同步队列头
同步准入释放容量后,分别唤醒每个独立平台模型队列的 FIFO 队头;只有任务实际绑定用户组时才同时约束用户组队头,避免一个已饱和候选阻塞其他候选补位。\n\n调度器单次最多处理 256 个真实队头,不唤醒整个等待队列。新增 PostgreSQL 集成测试覆盖无用户组的双候选并行唤醒,以及共享用户组下仍保持组级 FIFO。\n\n验证:gofmt;Store/Runner 聚焦测试;一次性 PostgreSQL 集成测试;git diff --check。
This commit is contained in:
@@ -713,10 +713,11 @@ LIMIT $1`, limit)
|
||||
return taskIDs, rows.Err()
|
||||
}
|
||||
|
||||
// ListWaitingTaskAdmissionIDs returns a bounded set of FIFO leaders across
|
||||
// platform-model and user-group queues. It is used after capacity is released
|
||||
// so API processes wake only plausible queue heads instead of every
|
||||
// synchronous waiter.
|
||||
// ListWaitingTaskAdmissionIDs returns one FIFO leader for every independent
|
||||
// platform-model queue, additionally requiring the task to lead its user-group
|
||||
// queue when one exists. It is used after capacity is released so API
|
||||
// processes can refill every candidate without waking every synchronous
|
||||
// waiter or allowing one saturated candidate to block another.
|
||||
func (s *Store) ListWaitingTaskAdmissionIDs(ctx context.Context, limit int) ([]string, error) {
|
||||
if limit <= 0 {
|
||||
limit = 256
|
||||
@@ -724,6 +725,7 @@ func (s *Store) ListWaitingTaskAdmissionIDs(ctx context.Context, limit int) ([]s
|
||||
rows, err := s.pool.Query(ctx, `
|
||||
WITH ranked AS (
|
||||
SELECT task_id,
|
||||
user_group_id,
|
||||
priority,
|
||||
enqueued_at,
|
||||
row_number() OVER (
|
||||
@@ -740,8 +742,8 @@ WITH ranked AS (
|
||||
)
|
||||
SELECT task_id::text
|
||||
FROM ranked
|
||||
WHERE platform_rank <= $1
|
||||
AND group_rank <= $1
|
||||
WHERE platform_rank = 1
|
||||
AND (user_group_id IS NULL OR group_rank = 1)
|
||||
ORDER BY priority ASC, enqueued_at ASC, task_id ASC
|
||||
LIMIT $1`, limit)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user