szetszwo commented on code in PR #1081:
URL: https://github.com/apache/ratis/pull/1081#discussion_r1596170847
##########
ratis-server/src/main/java/org/apache/ratis/server/raftlog/RaftLogBase.java:
##########
@@ -516,20 +514,11 @@ public LogEntryProto getEntry(TimeDuration timeout)
throws RaftLogIOException, T
if (LogProtoUtils.isStateMachineDataEmpty(entryProto)) {
final String err = getName() + ": State machine data not set for " +
this;
LOG.error(err);
- data.release();
throw new RaftLogIOException(err);
Review Comment:
@duongkame , we should also catch `RaftLogIOException` and release all the
entries in that case.
```java
final List<LogEntryProto> protos;
try {
protos = buffer.pollList(getHeartbeatWaitTimeMs(),
EntryWithData::getEntry,
(entry, time, exception) -> LOG.warn("Failed to get {} in {}",
entry, time.toString(TimeUnit.MILLISECONDS, 3), exception));
} catch (RaftLogIOException e) {
for (ReferenceCountedObject<EntryWithData> ref : offered.values()) {
ref.release();
}
offered.clear();
throw e;
} finally {
for (EntryWithData entry : buffer) {
// Release remaining entries.
offered.remove(entry.getIndex()).release();
}
buffer.clear();
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]