You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2023/05/11 08:01:31 UTC
[iotdb] 01/01: Fix only update last cache on follower
This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch fix_follower_no_last_cache
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 00524993a8225d1fe9bbf95f290688adc8f4d587
Author: HTHou <hh...@outlook.com>
AuthorDate: Thu May 11 16:01:09 2023 +0800
Fix only update last cache on follower
---
.../java/org/apache/iotdb/db/engine/storagegroup/DataRegion.java | 6 ++++--
.../iotdb/db/mpp/plan/planner/plan/node/write/InsertNode.java | 5 +++--
2 files changed, 7 insertions(+), 4 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 91b440ab851..7da25c217fd 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
@@ -1149,7 +1149,8 @@ public class DataRegion implements IDataRegionForQuery {
private void tryToUpdateBatchInsertLastCache(InsertTabletNode node, long latestFlushedTime) {
if (!IoTDBDescriptor.getInstance().getConfig().isLastCacheEnabled()
|| (config.getDataRegionConsensusProtocolClass().equals(ConsensusFactory.IOT_CONSENSUS)
- && !node.isFromLeaderWhenUsingIoTConsensus())) {
+ && node.isSyncFromLeaderWhenUsingIoTConsensus())) {
+ // disable updating last cache on follower
return;
}
String[] measurements = node.getMeasurements();
@@ -1202,7 +1203,8 @@ public class DataRegion implements IDataRegionForQuery {
private void tryToUpdateInsertLastCache(InsertRowNode node, long latestFlushedTime) {
if (!IoTDBDescriptor.getInstance().getConfig().isLastCacheEnabled()
|| (config.getDataRegionConsensusProtocolClass().equals(ConsensusFactory.IOT_CONSENSUS)
- && !node.isFromLeaderWhenUsingIoTConsensus())) {
+ && node.isSyncFromLeaderWhenUsingIoTConsensus())) {
+ // disable updating last cache on follower
return;
}
String[] measurements = node.getMeasurements();
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 a82685ed6a9..07c4b86c061 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
@@ -294,9 +294,10 @@ public abstract class InsertNode extends WritePlanNode {
/**
* Notice: Call this method ONLY when using IOT_CONSENSUS, other consensus protocol cannot
- * distinguish whether the insertNode is from leader by this method.
+ * distinguish whether the insertNode sync from leader by this method.
+ * isSyncFromLeaderWhenUsingIoTConsensus == true means this node is a follower
*/
- public boolean isFromLeaderWhenUsingIoTConsensus() {
+ public boolean isSyncFromLeaderWhenUsingIoTConsensus() {
return searchIndex == ConsensusReqReader.DEFAULT_SEARCH_INDEX;
}