JackieTien97 opened a new pull request, #16604:
URL: https://github.com/apache/iotdb/pull/16604

   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]](diffhunk://#diff-3ed021394fbf9a40c9ad48c24dfb3ba90ebb20aba5bdcf9a7763ebe0cca5e70dL362-R364)
 
[[2]](diffhunk://#diff-30d3dc10c256a0068e3b87dd128011b653b4a8ecd0f0bf1149979022b5d92ea7L3345-R3351)
   * 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:
   <img width="2900" height="1800" alt="f374fca129e9c9da5bb8f5e86e53384f" 
src="https://github.com/user-attachments/assets/cbad4ec8-3486-4c6c-afbe-cbe571ac1043";
 />
   
   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:
   <img width="2748" height="1468" alt="edcf2ad9bdf44cb525d6ef196c171704" 
src="https://github.com/user-attachments/assets/34106086-bd3a-4b9d-8497-de701bc06de0";
 />


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to