apache / apache/brpc

task control 中所有的 local queue is full 导致死锁&解决方案.

Open
#1,038 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
17.6k
Forks
4.1k
Avg merge
2d 12h
Merged PRs (30d)
69

Description

问题:
当请求量过大时,所有的local queue 都是 full 的状态,就会执行pthread 的 usleep,这样会导致死锁(这个问题以前有人提过).
====task_group_inl.h 代码如下=====
while (!_rq.push(tid)) {
flush_nosignal_tasks();
::usleep(1000);
}
方案
如果local queue 是full 的状态,当前线程直接执行,不尝试再次放到队列中(不进行 usleep)
伪代码如下:
while (!_rq.push(tid)) {
// 替换 usleep, push tid 失败,直接执行tid(不经过队列,直接切换栈)
TaskGroup::exchange( current_group , tid)
}
@jamesge @cdjingit 戈神,帮忙评估一下这个方案的风险性 ? 多谢.

Contributor guide

Open the contributing guide

Research direction

Start in task_group_inl.h at the _rq.push loop, and trace flush_nosignal_tasks(), the local-queue-full path, and TaskGroup::exchange. Assess the proposed direct execution path for scheduling and stack-safety risks; done means the deadlock is reproduced and resolved without breaking task execution under full local queues.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.