[
https://issues.apache.org/jira/browse/RATIS-2228?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Tsz-wo Sze updated RATIS-2228:
------------------------------
Description:
-In LogAppenderBase.nextAppendEntriesRequest,-
# -it reads N entries from RaftLog and offers them to the buffer queue.-
# -Then, it pulls M protos from the buffer queue.-
# -Finally, it returns a ReferenceCountedObject using the N offered entries
and the M pulled protos.-
-The problem is that M and N could be unequal.-
Actually, there is no problem since the finally-block below will clean up the
remaining entries.
{code}
} finally {
for (EntryWithData entry : buffer) {
// Release remaining entries.
Optional.ofNullable(offered.remove(entry.getIndex())).ifPresent(ReferenceCountedObject::release);
}
buffer.clear();
}
{code}
Let's take this opportunity to clean up the code.
was:
In LogAppenderBase.nextAppendEntriesRequest,
- it reads N entries from RaftLog and offers them to the buffer queue.
- Then, it pulls M protos from the buffer queue.
- Finally, it returns a ReferenceCountedObject using the N offered entries and
the M pulled protos.
The problem is that M and N could be unequal.
Summary: Refactor the offered map in
LogAppenderBase.nextAppendEntriesRequest (was:
LogAppenderBase.nextAppendEntriesRequest may return an inconsistent
ReferenceCountedObject)
> Refactor the offered map in LogAppenderBase.nextAppendEntriesRequest
> --------------------------------------------------------------------
>
> Key: RATIS-2228
> URL: https://issues.apache.org/jira/browse/RATIS-2228
> Project: Ratis
> Issue Type: Sub-task
> Components: server
> Reporter: Tsz-wo Sze
> Assignee: Tsz-wo Sze
> Priority: Major
>
> -In LogAppenderBase.nextAppendEntriesRequest,-
> # -it reads N entries from RaftLog and offers them to the buffer queue.-
> # -Then, it pulls M protos from the buffer queue.-
> # -Finally, it returns a ReferenceCountedObject using the N offered entries
> and the M pulled protos.-
> -The problem is that M and N could be unequal.-
> Actually, there is no problem since the finally-block below will clean up the
> remaining entries.
> {code}
> } finally {
> for (EntryWithData entry : buffer) {
> // Release remaining entries.
>
> Optional.ofNullable(offered.remove(entry.getIndex())).ifPresent(ReferenceCountedObject::release);
> }
> buffer.clear();
> }
> {code}
> Let's take this opportunity to clean up the code.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)