deardeng commented on code in PR #66191:
URL: https://github.com/apache/doris/pull/66191#discussion_r3851762675


##########
fe/fe-core/src/main/java/org/apache/doris/clone/TabletScheduler.java:
##########
@@ -650,13 +661,33 @@ private void scheduleTablet(TabletSchedCtx tabletCtx, 
AgentBatchTask batchTask)
             tabletCtx.setVersionInfo(partition.getVisibleVersion(), 
partition.getCommittedVersion());
             tabletCtx.setSchemaHash(tbl.getSchemaHashByIndexId(idx.getId()));
             
tabletCtx.setStorageMedium(tbl.getPartitionInfo().getDataProperty(partition.getId()).getStorageMedium());
+            setBasePreferredDestPathIfNecessary(tabletCtx, partition, idx, 
tablet, tabletHealth.status);
 
             handleTabletByTypeAndStatus(tabletHealth.status, tabletCtx, 
batchTask);
         } finally {
             tbl.writeUnlock();
         }
     }
 
+    private void setBasePreferredDestPathIfNecessary(TabletSchedCtx tabletCtx, 
Partition partition,
+            MaterializedIndex idx, Tablet tablet, TabletStatus status) throws 
SchedException {
+        
tabletCtx.setBasePreferredDestPathHashByBackend(Collections.emptyMap());
+        if (idx.isRowBinlog() || idx.getId() != 
partition.getBaseIndex().getId()) {
+            return;
+        }
+        if (status != TabletStatus.REPLICA_MISSING && status != 
TabletStatus.REPLICA_RELOCATING) {
+            return;
+        }
+        Map<Long, Long> preferredDestPathHashByBackend;
+        try {
+            preferredDestPathHashByBackend = RowBinlogTabletLocality
+                    .getPreferredBaseRepairPathByBackend(partition, tablet, 
tabletCtx.getVisibleVersion());
+        } catch (IllegalStateException e) {
+            throw new SchedException(Status.UNRECOVERABLE, e.getMessage());
+        }
+        
tabletCtx.setBasePreferredDestPathHashByBackend(preferredDestPathHashByBackend);

Review Comment:
   Could we avoid storing basePreferredDestPathHashByBackend in TabletSchedCtx? 
It is computed immediately before dispatch and consumed only by 
handleReplicaMissing(), so this introduces transient mutable state and requires 
clearing it on every scheduling attempt to prevent stale values. It would be 
simpler to compute the preferred paths at the point of use and pass them 
directly to chooseBasePreferredDestPath(). Please make sure the indirect 
REPLICA_RELOCATING, VERSION_INCOMPLETE fallback, and REPLICA_MISSING_FOR_TAG 
paths retain the intended behavior.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to