You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by xi...@apache.org on 2023/05/10 14:17:33 UTC
[iotdb] 01/01: Follower doesn't need to update last cache when using IoT_consensus (#9811)
This is an automated email from the ASF dual-hosted git repository.
xingtanzjr pushed a commit to branch disable_last_cache_follower_rel_1.1
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 99ad64675c6f0b74ffdeb785906ef2622330f7c8
Author: Haonan <hh...@outlook.com>
AuthorDate: Wed May 10 22:10:26 2023 +0800
Follower doesn't need to update last cache when using IoT_consensus (#9811)
---
.../java/org/apache/iotdb/db/engine/storagegroup/DataRegion.java | 8 ++++++--
.../iotdb/db/mpp/plan/planner/plan/node/write/InsertNode.java | 8 ++++++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/DataRegion.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/DataRegion.java
index 7aa38a3a68..7730aeef5e 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/DataRegion.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/DataRegion.java
@@ -1143,7 +1143,9 @@ public class DataRegion implements IDataRegionForQuery {
}
private void tryToUpdateBatchInsertLastCache(InsertTabletNode node, long latestFlushedTime) {
- if (!IoTDBDescriptor.getInstance().getConfig().isLastCacheEnabled()) {
+ if (!IoTDBDescriptor.getInstance().getConfig().isLastCacheEnabled()
+ || (config.getDataRegionConsensusProtocolClass().equals(ConsensusFactory.IOT_CONSENSUS)
+ && !node.isFromLeaderWhenUsingIoTConsensus())) {
return;
}
for (int i = 0; i < node.getColumns().length; i++) {
@@ -1184,7 +1186,9 @@ public class DataRegion implements IDataRegionForQuery {
}
private void tryToUpdateInsertLastCache(InsertRowNode node, long latestFlushedTime) {
- if (!IoTDBDescriptor.getInstance().getConfig().isLastCacheEnabled()) {
+ if (!IoTDBDescriptor.getInstance().getConfig().isLastCacheEnabled()
+ || (config.getDataRegionConsensusProtocolClass().equals(ConsensusFactory.IOT_CONSENSUS)
+ && !node.isFromLeaderWhenUsingIoTConsensus())) {
return;
}
for (int i = 0; i < node.getValues().length; i++) {
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/write/InsertNode.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/write/InsertNode.java
index 0994935c95..a82685ed6a 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/write/InsertNode.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/write/InsertNode.java
@@ -292,6 +292,14 @@ public abstract class InsertNode extends WritePlanNode {
public abstract Object getFirstValueOfIndex(int index);
+ /**
+ * Notice: Call this method ONLY when using IOT_CONSENSUS, other consensus protocol cannot
+ * distinguish whether the insertNode is from leader by this method.
+ */
+ public boolean isFromLeaderWhenUsingIoTConsensus() {
+ return searchIndex == ConsensusReqReader.DEFAULT_SEARCH_INDEX;
+ }
+
// region partial insert
/**
* Mark failed measurement, measurements[index], dataTypes[index] and values/columns[index] would