Support a new read_consistency_level
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_READto theReadConsistencyLevelenum inReadConsistencyLevel.java, allowing the system to use follower replicas for read operations. - Updated the configuration logic in
ConfigNodeDescriptor.javaandIoTDBConfig.javato accept and validate the newfollower_readvalue, throwing exceptions for unknown values. [1] [2] - Enhanced the planner logic in
AbstractFragmentParallelPlanner.javato select follower replicas whenFOLLOWER_READis specified, ensuring the leader is skipped and a follower is chosen based on session ID. - Updated the configuration template in
iotdb-system.properties.templateto document the newfollower_readoption for users.
Refactoring and Logic Separation:
- Refactored the data node selection logic in
AbstractFragmentParallelPlanner.javaby 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:
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:
Codecov Report
:x: Patch coverage is 34.78261% with 15 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 38.67%. Comparing base (8d93384) to head (5df19d5).
:warning: Report is 2 commits behind head on master.
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
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code