Commit ba062ef
[Enhancement] Reject agent-task enqueue on a demoted (non-leader) node
The addTask() demotion guard only checked isLeaderDemoting(), leaving a window AFTER
the demotion completed: a straggling leader-session thread (e.g. a user DDL that
passed its admission checks before the demotion began) could still enqueue on the
now-follower node. The waiter would then sit out its full timeout, and the stale
queue entry would survive into a later re-election where it shadows a same-signature
task (addTask de-dups by signature, so BE finish reports resolve to the stale object
and the new waiter never completes).
Extend the guard to also reject when feType is FOLLOWER / OBSERVER / UNKNOWN (the
demotion target roles). Verified every legitimate enqueue happens with feType ==
LEADER: activation flips feType to LEADER before the leader-only daemons start, DDL
threads pass leader admission first, and the replay paths never enqueue (e.g.
OlapTable.onDrop guards sendDropAutoIncrementMapTask with !replay). INIT stays
admitted so bootstrap, checkpoint-image GlobalStateMgr instances, and plain unit
tests are unaffected; a fully mocked GlobalStateMgr (null feType) is also admitted.
Add AgentTaskTest.testAddTaskRejectedAfterDemotionCompleted.
Signed-off-by: gengjun-git <gengjun@starrocks.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 1697260 commit ba062ef
2 files changed
Lines changed: 36 additions & 6 deletions
File tree
- fe/fe-core/src
- main/java/com/starrocks/task
- test/java/com/starrocks/task
Lines changed: 19 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
84 | 97 | | |
85 | | - | |
| 98 | + | |
86 | 99 | | |
87 | 100 | | |
88 | 101 | | |
| |||
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
529 | 529 | | |
530 | 530 | | |
531 | 531 | | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
532 | 549 | | |
533 | 550 | | |
534 | 551 | | |
| |||
0 commit comments