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:10:34 UTC
[iotdb] branch master updated: 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 master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 52eb858616 Follower doesn't need to update last cache when using IoT_consensus (#9811)
52eb858616 is described below
commit 52eb858616ee235e7af2e8b7fbc40cc3a4d76ec0
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 bcb4078187..a9be788484 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
@@ -1146,7 +1146,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;
}
DataNodeSchemaCache.getInstance()
@@ -1186,7 +1188,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;
}
DataNodeSchemaCache.getInstance()
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