Caideyipi commented on code in PR #18663:
URL: https://github.com/apache/iotdb/pull/18663#discussion_r4033082977


##########
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/RegionBalancer.java:
##########
@@ -118,6 +130,14 @@ public CreateRegionGroupsPlan 
genRegionGroupsAllocationPlan(
       final int allotment = entry.getValue();
       final int replicationFactor =
           getClusterSchemaManager().getReplicationFactor(database, 
consensusGroupType);
+      final Integer requestPreferredDataNode =
+          preferredDataNodeMap == null ? null : 
preferredDataNodeMap.get(database);
+      final int preferredDataNodeId =
+          TConsensusGroupType.DataRegion.equals(consensusGroupType)
+              ? (requestPreferredDataNode != null
+                  ? requestPreferredDataNode
+                  : getPreferredDataNodeId(database))

Review Comment:
   [P1] Keep the DataNode preference for a single LOAD out of the persistent 
database schema
   
   When a request has no hint, this code falls back to the 
`preferredDataNodeId` persisted in the database schema. There is no mechanism 
to clear this field, so after a database is created by LOAD, later DataRegion 
expansion triggered by ordinary INSERTs, repair tasks, etc. will continue to 
favor the original DataNode. Even if `load_tsfile_prefer_local_node=false` is 
applied at runtime, `PartitionManager` still passes an empty map and this 
fallback remains active. With RF=1, subsequent Regions may even keep 
accumulating on the same node. Please keep the hint scoped to the request, or 
clear it after its first use.



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/ClusterPartitionFetcher.java:
##########
@@ -319,6 +319,14 @@ public DataPartition getOrCreateDataPartition(
   @Override
   public DataPartition getOrCreateDataPartition(
       final List<DataPartitionQueryParam> dataPartitionQueryParams, final 
String userName) {
+    return getOrCreateDataPartition(dataPartitionQueryParams, userName, -1);

Review Comment:
   [P2] Tablet conversion paths lose the preferred DataNode hint
   
   The existing two-argument overload is forwarded here with 
`preferredDataNodeId=-1`. However, small TsFiles are converted directly to 
`InsertTablet` before normal schema analysis, and conversion for type 
mismatches also uses the regular INSERT analysis API. These paths ultimately 
call that two-argument overload, so the local node will not be preferred even 
when LOAD creates a database or DataRegion. Please propagate the preferred ID 
into the partition requests for the converted tree-model and table-model 
inserts.



##########
iotdb-protocol/thrift-confignode/src/main/thrift/confignode.thrift:
##########
@@ -241,6 +241,7 @@ struct TDatabaseSchema {
     10: optional i64 timePartitionOrigin
     11: optional bool isTableModel
     12: optional bool needLastCache
+    13: optional i32 preferredDataNodeId

Review Comment:
   [P2] Do not propagate a cluster-local DataNodeId through Pipe in the 
database schema
   
   `TDatabaseSchema` is sent downstream through ConfigRegion Pipe as part of a 
`CreateDatabase` plan. The receiver replaces sender-local settings such as the 
replication factor and time partition configuration, but does not clear this 
field. DataNodeId is a cluster-local identifier. If a node with the same ID 
exists in the target cluster, subsequent DataRegions will incorrectly favor 
that node. Disabling `load_tsfile_prefer_local_node` on the target cluster does 
not prevent the schema fallback either. If this field is retained, the Pipe 
receiver should at least call `unsetPreferredDataNodeId()`.



-- 
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