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:08:19 UTC

[iotdb] branch fix_follower_no_last_cache_11 created (now 2000e12c95e)

This is an automated email from the ASF dual-hosted git repository.

haonan pushed a change to branch fix_follower_no_last_cache_11
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at 2000e12c95e Fix only update last cache on follower

This branch includes the following new commits:

     new 2000e12c95e Fix only update last cache on follower

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 01/01: Fix only update last cache on follower

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch fix_follower_no_last_cache_11
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 2000e12c95e89234918dcdb5e7ba38a7476bfc5e
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 7730aeef5ee..e3023a131ad 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
@@ -1145,7 +1145,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;
     }
     for (int i = 0; i < node.getColumns().length; i++) {
@@ -1188,7 +1189,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;
     }
     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 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;
   }