This is an automated email from the ASF dual-hosted git repository.
tanxinyu pushed a commit to branch multi_leader_duplicate_entry_debug
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to
refs/heads/multi_leader_duplicate_entry_debug by this push:
new 1098035cf7 fix gap from wal bug
1098035cf7 is described below
commit 1098035cf75727eb9163ef573a39e80a5191015a
Author: OneSizeFitQuorum <[email protected]>
AuthorDate: Wed Nov 16 10:30:51 2022 +0800
fix gap from wal bug
Signed-off-by: OneSizeFitQuorum <[email protected]>
---
.../multileader/logdispatcher/LogDispatcher.java | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git
a/consensus/src/main/java/org/apache/iotdb/consensus/multileader/logdispatcher/LogDispatcher.java
b/consensus/src/main/java/org/apache/iotdb/consensus/multileader/logdispatcher/LogDispatcher.java
index 5aea9d6c7a..fe536a2220 100644
---
a/consensus/src/main/java/org/apache/iotdb/consensus/multileader/logdispatcher/LogDispatcher.java
+++
b/consensus/src/main/java/org/apache/iotdb/consensus/multileader/logdispatcher/LogDispatcher.java
@@ -389,11 +389,14 @@ public class LogDispatcher {
// Prevents gap between logs. For example, some requests are not
written into the queue when
// the queue is full. In this case, requests need to be loaded from
the WAL
- constructBatchFromWAL(startIndex, prev.getSearchIndex(), batches);
- if (!batches.canAccumulate()) {
- batches.buildIndex();
- logger.debug("{} : accumulated a {} from wal",
impl.getThisNode().getGroupId(), batches);
- return batches;
+ if (startIndex != prev.getSearchIndex()) {
+ constructBatchFromWAL(startIndex, prev.getSearchIndex(), batches);
+ if (!batches.canAccumulate()) {
+ batches.buildIndex();
+ logger.debug(
+ "{} : accumulated a {} from wal",
impl.getThisNode().getGroupId(), batches);
+ return batches;
+ }
}
if (!batches.isEmpty()
@@ -421,7 +424,7 @@ public class LogDispatcher {
// Prevents gap between logs. For example, some logs are not written
into the queue when
// the queue is full. In this case, requests need to be loaded from
the WAL
if (current.getSearchIndex() != prev.getSearchIndex() + 1) {
- constructBatchFromWAL(prev.getSearchIndex(),
current.getSearchIndex(), batches);
+ constructBatchFromWAL(prev.getSearchIndex() + 1,
current.getSearchIndex(), batches);
if (!batches.canAccumulate()) {
batches.buildIndex();
logger.debug(