imbajin commented on code in PR #3359:
URL: https://github.com/apache/hugegraph/pull/3359#discussion_r4308747096


##########
hugegraph-pd/hg-pd-service/src/main/java/org/apache/hugegraph/pd/service/PDRestService.java:
##########
@@ -137,11 +138,38 @@ public Map<Integer, Metapb.ShardGroup> 
getShardGroupCache() {
     }
 
     public List<Metapb.Store> patrolStores() throws PDException {
-        return monitorService.patrolStores();
+        return runLeaderTask(() -> monitorService.patrolStores());
     }
 
     public List<Metapb.Partition> patrolPartitions() throws PDException {
-        return monitorService.patrolPartitions();
+        return runLeaderTask(() -> monitorService.patrolPartitions());
+    }
+
+    public TaskScheduleService.PartitionPatrolResult 
patrolPartitionsWithResult() throws PDException {
+        return runLeaderTask(() -> 
monitorService.patrolPartitionsWithResult());
+    }
+
+    private <T> T runLeaderTask(LeaderTask<T> task) throws PDException {
+        checkTaskLeader();
+        T result = task.run();

Review Comment:
   ⚠️ Important. Blocking: no. Summary: If this PD loses and regains leadership 
between these two checks, a task that the scheduler declined can still be 
reported as successful. Evidence: `TaskScheduleService.dbCompaction()` returns 
`false` when the node is not leader, but the compaction lambda discards that 
result; if the final check sees the node re-elected, `TaskAPI.dbCompaction()` 
returns `compact ok`. Please propagate the scheduler's refusal or fence 
execution to the leader term captured at entry.



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