arshilkxwork commented on code in PR #3356:
URL: https://github.com/apache/hugegraph/pull/3356#discussion_r4355680030
##########
hugegraph-pd/hg-pd-core/src/main/java/org/apache/hugegraph/pd/TaskScheduleService.java:
##########
@@ -143,6 +186,29 @@ public void init() {
}
}, 2, 30,
TimeUnit.SECONDS);
+ if (pdConfig.isBalanceLeaderEnable()) {
+ long interval = pdConfig.getBalanceLeaderInterval();
+ int maxSkew = pdConfig.getBalanceLeaderMaxSkew();
+ if (interval > 0 && maxSkew >= 0) {
+ balanceLeaderTask = executor.scheduleWithFixedDelay(() -> {
+ try {
+ autoBalancePartitionLeader();
Review Comment:
Fixed in f8c3a952f with your first option. Only the periodic path calls the
planner with `immediately=false`; the REST, `/v1/balanceLeaders` and gRPC
entries all pass `true`. So the planner's wait now uses
`pd.balance-leader-interval` in place of the fixed 30 s, and the
`BalanceLeaderInterval` constant is gone. A 10 s setting now plans at most
every 10 s. The wait is still counted from the last plan of either kind, so the
first periodic plan after a manual balance waits one interval.
Tests, both with a 1 s interval:
- `testAutoBalancePartitionLeaderFollowsInterval`: a first run moves four
leaders, an immediate second run moves none, and a run 1.1 s later moves four
again.
- `testAutoBalancePartitionLeaderWaitsAfterManualBalance`: a manual
`balancePartitionLeader(true)` moves four, the periodic run right after it
moves none, and a run 1.1 s later moves four.
With the fixed 30 s wait both fail on the run 1.1 s later, with no
transfers. PD core suite: 213 tests, 0 failures, 2 skipped. The
`pd.balance-leader-interval` row in `configuration.md` now says it also spaces
out the plans.
--
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]