[
https://issues.apache.org/jira/browse/RATIS-2665?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18107300#comment-18107300
]
wangqiang edited comment on RATIS-2665 at 8/24/26 9:53 AM:
-----------------------------------------------------------
Solution:
When closing SegmentedRaftLogWorker, set running to false and then offer an
internal wake-up task to the queue. This immediately wakes an idle worker
blocked in DataBlockingQueue.poll().
The worker exits as soon as it receives the wake-up task, without passing it
through normal task execution, exception handling, metrics, or future
completion.
This approach does not interrupt the worker, so active flush or log-sync
operations are unaffected. If the queue is full, the wake-up task may not be
accepted, but the worker is not waiting on an empty queue in that case and
will exit after completing its current task.
The optimization does not change any public API and adds only an identity
comparison to the normal task-processing path.
was (Author: JIRAUSER314434):
Solution:
{{When closing SegmentedRaftLogWorker, set running to false and then offer an
internal wake-up task to the queue. This immediately wakes an idle worker
blocked in DataBlockingQueue.poll().
The worker exits as soon as it receives the wake-up task, without passing it
through normal task execution, exception handling, metrics, or future
completion.
This approach does not interrupt the worker, so active flush or log-sync
operations are unaffected. If the queue is full, the wake-up task may not be
accepted, but the worker is not waiting on an empty queue in that case and
will exit after completing its current task.
The optimization does not change any public API and adds only an identity
comparison to the normal task-processing path.}}
> SegmentedRaftLogWorker close may wait for the task queue poll timeout
> ---------------------------------------------------------------------
>
> Key: RATIS-2665
> URL: https://issues.apache.org/jira/browse/RATIS-2665
> Project: Ratis
> Issue Type: Improvement
> Affects Versions: 3.2.2
> Reporter: wangqiang
> Assignee: wangqiang
> Priority: Major
>
> SegmentedRaftLogWorker polls its I/O task queue with a one-second timeout.
> When close() is called while the worker is idle, the worker may still be
> blocked in DataBlockingQueue.poll(). It cannot observe the updated running
> state until the poll returns or times out. Therefore, closing an idle
> SegmentedRaftLogWorker may take up to one second.
> This delay is particularly noticeable when Raft groups are frequently created
> and removed, because each group shutdown may incur the same delay.
> Steps to reproduce:
> 1. Start a SegmentedRaftLog with no pending I/O tasks.
> 2. Wait until SegmentedRaftLogWorker is polling an empty task queue.
> 3. Close the SegmentedRaftLog.
> 4. Measure the close duration.
> The close operation typically takes approximately one second when the worker
> is idle.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)