This is an automated email from the ASF dual-hosted git repository.

hulk pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks-controller.git


The following commit(s) were added to refs/heads/unstable by this push:
     new 61b3665  Enhance the slave node promotion (#340)
61b3665 is described below

commit 61b3665f472c7cc0121d2375aa92960ffd05dc5c
Author: Raphael <[email protected]>
AuthorDate: Fri Sep 19 17:50:33 2025 +0800

    Enhance the slave node promotion (#340)
---
 store/cluster_shard.go | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/store/cluster_shard.go b/store/cluster_shard.go
index bfb60e3..8ae7a18 100644
--- a/store/cluster_shard.go
+++ b/store/cluster_shard.go
@@ -156,7 +156,8 @@ func (shard *Shard) getNewMasterNodeIndex(ctx 
context.Context, masterNodeIndex i
                if i == masterNodeIndex {
                        continue
                }
-               clusterNodeInfo, err := node.GetClusterNodeInfo(ctx)
+
+               _, err := node.GetClusterInfo(ctx)
                if err != nil {
                        logger.Get().With(
                                zap.Error(err),
@@ -165,6 +166,33 @@ func (shard *Shard) getNewMasterNodeIndex(ctx 
context.Context, masterNodeIndex i
                        ).Warn("Skip the node due to failed to get cluster 
info")
                        continue
                }
+
+               clusterNodeInfo, err := node.GetClusterNodeInfo(ctx)
+               if err != nil {
+                       logger.Get().With(
+                               zap.Error(err),
+                               zap.String("id", node.ID()),
+                               zap.String("addr", node.Addr()),
+                       ).Warn("Skip the node due to failed to get info of 
node")
+                       continue
+               }
+               if clusterNodeInfo.Role != RoleSlave || 
clusterNodeInfo.Sequence == 0 {
+                       logger.Get().With(
+                               zap.String("id", node.ID()),
+                               zap.String("addr", node.Addr()),
+                               zap.String("role", clusterNodeInfo.Role),
+                               zap.Uint64("sequence", 
clusterNodeInfo.Sequence),
+                       ).Warn("Skip the node due to role or sequence invalid")
+                       continue
+               }
+
+               logger.Get().With(
+                       zap.String("id", node.ID()),
+                       zap.String("addr", node.Addr()),
+                       zap.String("role", clusterNodeInfo.Role),
+                       zap.Uint64("sequence", clusterNodeInfo.Sequence),
+               ).Info("Get slave node info successfully")
+
                // If the preferredNodeID is not empty, we will use it as the 
new master node.
                if preferredNodeID != "" && node.ID() == preferredNodeID {
                        newMasterNodeIndex = i

Reply via email to