Skip to content

Conversation

JackieTien97
Copy link
Contributor

This pull request introduces support for a new read consistency level, follower_read, across the IoTDB codebase. The changes ensure that configuration, logic, and documentation now recognize and correctly handle this new option alongside the existing strong and weak levels.

Read Consistency Level Enhancements:

  • Added FOLLOWER_READ to the ReadConsistencyLevel enum in ReadConsistencyLevel.java, allowing the system to use follower replicas for read operations.
  • Updated the configuration logic in ConfigNodeDescriptor.java and IoTDBConfig.java to accept and validate the new follower_read value, throwing exceptions for unknown values. [1] [2]
  • Enhanced the planner logic in AbstractFragmentParallelPlanner.java to select follower replicas when FOLLOWER_READ is specified, ensuring the leader is skipped and a follower is chosen based on session ID.
  • Updated the configuration template in iotdb-system.properties.template to document the new follower_read option for users.

Refactoring and Logic Separation:

  • Refactored the data node selection logic in AbstractFragmentParallelPlanner.java by extracting target index determination into a separate method, improving readability and maintainability.

Supposing we have a 3C3D cluster and data replica number is set to 3, we execute the following sqls to prepare data:

create database test;
use test;
create table t1(device_id STRING TAG, s1 float);
insert into t1 values(now(),'d1', 1.0); 

Before this pr, if we do select * from t1; query, the query will always be routed to leader:
f374fca129e9c9da5bb8f5e86e53384f

After this pr, if we set read_consistency_level=follower_read and then restart the cluster, then the above query will always be routed to any follower:
edcf2ad9bdf44cb525d6ef196c171704

Copy link

codecov bot commented Oct 17, 2025

Codecov Report

❌ Patch coverage is 34.78261% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.67%. Comparing base (8d93384) to head (5df19d5).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
.../planner/plan/AbstractFragmentParallelPlanner.java 46.15% 7 Missing ⚠️
...ain/java/org/apache/iotdb/db/conf/IoTDBConfig.java 0.00% 5 Missing ⚠️
...he/iotdb/confignode/conf/ConfigNodeDescriptor.java 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #16604      +/-   ##
============================================
- Coverage     38.67%   38.67%   -0.01%     
  Complexity      207      207              
============================================
  Files          4937     4938       +1     
  Lines        326989   326996       +7     
  Branches      41503    41509       +6     
============================================
- Hits         126470   126453      -17     
- Misses       200519   200543      +24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Copy link
Contributor

@OneSizeFitsQuorum OneSizeFitsQuorum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for the code~

As for the name, strong, weak, and follower_read don't seem very consistent... but I can't think of better names either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants