You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "yujun777 (via GitHub)" <gi...@apache.org> on 2023/06/15 15:08:14 UTC

[GitHub] [doris] yujun777 commented on a diff in pull request #20872: [fix](replica) do not delete the only one replica

yujun777 commented on code in PR #20872:
URL: https://github.com/apache/doris/pull/20872#discussion_r1231161100


##########
fe/fe-core/src/main/java/org/apache/doris/clone/TabletScheduler.java:
##########
@@ -1113,6 +1103,21 @@ private void deleteReplicaInternal(TabletSchedCtx tabletCtx,
             }
         }
 
+        List<Replica> replicas = tabletCtx.getTablet().getReplicas();
+        int matchupReplicaCount = 0;
+        for (Replica tmpReplica : replicas) {
+            if (tmpReplica.getVersion() >= replica.getVersion()) {
+                matchupReplicaCount++;
+            }
+        }
+
+        if (matchupReplicaCount <= 1) {
+            LOG.info("can not delete only one replica, tabletId = {} replicaId = {}", tabletCtx.getTabletId(),
+                     replica.getId());
+            throw new SchedException(Status.FINISHED, "the only one latest replia can not be dropped, tabletId = "
+                                        + tabletCtx.getTabletId() + ", replicaId = " + replica.getId());
+        }
+

Review Comment:
   Can move the-only-one check to the begining of this function ?  Otherwise this replica will change to  decommission state.



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org