This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new d5d8316 [Optimize][Clone] Take version count into consideration when
choosing src replica for clone task (#6513)
d5d8316 is described below
commit d5d8316ff3c89febd1e7ba44e9b219ccf306c8d8
Author: weizuo93 <[email protected]>
AuthorDate: Mon Aug 30 18:52:41 2021 +0800
[Optimize][Clone] Take version count into consideration when choosing src
replica for clone task (#6513)
Fix #6512
If there is missing replica for a tablet, clone task will be executed to
restore missing replica from a healthy replica. Src replica selector will
randomly choose a healthy replica as src replica.
It's better to choose the health replica with min version count as src
replica so that it could avoid repetitive compaction task. In addition, replica
with less version count is good for query performance.
---
.../org/apache/doris/clone/TabletSchedCtx.java | 24 +++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/clone/TabletSchedCtx.java
b/fe/fe-core/src/main/java/org/apache/doris/clone/TabletSchedCtx.java
index fd36689..8e3ab51 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/clone/TabletSchedCtx.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/clone/TabletSchedCtx.java
@@ -489,8 +489,10 @@ public class TabletSchedCtx implements
Comparable<TabletSchedCtx> {
if (candidates.isEmpty()) {
throw new SchedException(Status.UNRECOVERABLE, "unable to find
source replica");
}
-
+
// choose a replica which slot is available from candidates.
+ long minVersionCount = Long.MAX_VALUE;
+ boolean findSrcReplica = false;
for (Replica srcReplica : candidates) {
PathSlot slot =
backendsWorkingSlots.get(srcReplica.getBackendId());
if (slot == null) {
@@ -499,10 +501,26 @@ public class TabletSchedCtx implements
Comparable<TabletSchedCtx> {
long srcPathHash = slot.takeSlot(srcReplica.getPathHash());
if (srcPathHash != -1) {
- setSrc(srcReplica);
- return;
+ if (!findSrcReplica) {
+ // version count is set by report process, so it may not
be set yet and default value is -1.
+ // so we need to check it.
+ minVersionCount = srcReplica.getVersionCount() == -1 ?
Long.MAX_VALUE : srcReplica.getVersionCount();
+ setSrc(srcReplica);
+ findSrcReplica = true;
+ } else {
+ long curVerCount = srcReplica.getVersionCount() == -1 ?
Long.MAX_VALUE : srcReplica.getVersionCount();
+ if (curVerCount < minVersionCount) {
+ minVersionCount = curVerCount;
+ setSrc(srcReplica);
+ findSrcReplica = true;
+ }
+ }
}
}
+
+ if (findSrcReplica) {
+ return;
+ }
throw new SchedException(Status.SCHEDULE_FAILED, "unable to find
source slot");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]