Duong created RATIS-2001:
----------------------------
Summary: TransactionContext is wrongly reused
Key: RATIS-2001
URL: https://issues.apache.org/jira/browse/RATIS-2001
Project: Ratis
Issue Type: Bug
Reporter: Duong
After RATIS-1897, TransactionContext is
[created|https://github.com/apache/ratis/blob/master/ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLog.java#L477]
during {{{}appendEntries{}}}.
{code:java}
// in SegmentedRaftLog#appendImpl
for (int i = index; i < entries.size(); i++) {
final LogEntryProto entry = entries.get(i);
futures.add(appendEntry(entry, server.getTransactionContext(entry,
true)));
} {code}
The created transaction is cached in TransactionManager, keyed by index only.
This opens a possibility of error, e.g. uncommitted logs can be reverted when
leader changes, and the index can be reused for another entirely different log
entry in another term. This will make the cached `TransactionContext` obsolete
but still be used for the later entry.
A sample error and details discussion can be found in this
[PR|https://github.com/apache/ratis/pull/1011#issuecomment-1894374538].
--
This message was sent by Atlassian Jira
(v8.20.10#820010)