[
https://issues.apache.org/jira/browse/RATIS-2665?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
wangqiang updated RATIS-2665:
-----------------------------
Description:
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.
was:
SegmentedRaftLogWorker polls its I/O task queue with a one-second timeout.
When close() is called while the worker is idle, it only sets running to false.
Since the worker is blocked in DataBlockingQueue.poll(), it cannot observe the
updated state until the poll times out. As a result, closing an idle
SegmentedRaftLogWorker may take up to one second.
This delay becomes significant when Raft groups are frequently created and
removed, since the delay is incurred for each group during shutdown.
The worker should be explicitly awakened during close without interrupting a
task that may be performing log I/O. A private wake-up task can be offered to
the queue after running is set to false. The worker recognizes this task and
exits before normal task execution, metrics, exception handling, or future
completion.
If the queue is full, offering the wake-up task may fail safely: the worker is
not blocked on an empty queue in that case and will observe running == false
after completing its current task.
> 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)