Skip to content

Commit 23623e7

Browse files
branch-3.0: [fix](replica) skip missing version should care catchup #49999 (#50087)
Cherry-picked from #49999 Co-authored-by: Yongqiang YANG <yangyongqiang@selectdb.com>
1 parent 3996fe2 commit 23623e7

File tree

1 file changed

+18
-3
lines changed
  • fe/fe-core/src/main/java/org/apache/doris/catalog

1 file changed

+18
-3
lines changed

fe/fe-core/src/main/java/org/apache/doris/catalog/Tablet.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,23 +303,29 @@ protected Multimap<Long, Long> getNormalReplicaBackendPathMapCloud(String beEndp
303303
(rep, be) -> ((CloudReplica) rep).getBackendId(be));
304304
}
305305

306+
// When a BE reports a missing version, lastFailedVersion is set. When a write fails on a replica,
307+
// lastFailedVersion is set.
306308
// for query
307309
public List<Replica> getQueryableReplicas(long visibleVersion, Map<Long, Set<Long>> backendAlivePathHashs,
308-
boolean allowFailedVersion) {
310+
boolean allowMissingVersion) {
309311
List<Replica> allQueryableReplica = Lists.newArrayListWithCapacity(replicas.size());
310312
List<Replica> auxiliaryReplica = Lists.newArrayListWithCapacity(replicas.size());
311313
List<Replica> deadPathReplica = Lists.newArrayList();
314+
List<Replica> mayMissingVersionReplica = Lists.newArrayList();
315+
List<Replica> notCatchupReplica = Lists.newArrayList();
316+
312317
for (Replica replica : replicas) {
313318
if (replica.isBad()) {
314319
continue;
315320
}
316321

317-
// Skip the missing version replica
318-
if (replica.getLastFailedVersion() > 0 && !allowFailedVersion) {
322+
if (replica.getLastFailedVersion() > 0) {
323+
mayMissingVersionReplica.add(replica);
319324
continue;
320325
}
321326

322327
if (!replica.checkVersionCatchUp(visibleVersion, false)) {
328+
notCatchupReplica.add(replica);
323329
continue;
324330
}
325331

@@ -345,6 +351,15 @@ public List<Replica> getQueryableReplicas(long visibleVersion, Map<Long, Set<Lon
345351
allQueryableReplica = deadPathReplica;
346352
}
347353

354+
if (allQueryableReplica.isEmpty()) {
355+
// If be misses a version, be would report failure.
356+
allQueryableReplica = mayMissingVersionReplica;
357+
}
358+
359+
if (allQueryableReplica.isEmpty() && allowMissingVersion) {
360+
allQueryableReplica = notCatchupReplica;
361+
}
362+
348363
if (Config.skip_compaction_slower_replica && allQueryableReplica.size() > 1) {
349364
long minVersionCount = allQueryableReplica.stream().mapToLong(Replica::getVisibleVersionCount)
350365
.filter(count -> count != -1).min().orElse(Long.MAX_VALUE);

0 commit comments

Comments
 (0)