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 167acb7  Fix leader change haven't updated prevTermLeader when lost 
the leader (#353)
167acb7 is described below

commit 167acb7c0509f1f6b9f5744869a7225f9095eb86
Author: superchee <[email protected]>
AuthorDate: Sun Sep 28 13:52:20 2025 +0800

    Fix leader change haven't updated prevTermLeader when lost the leader (#353)
---
 controller/controller.go | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/controller/controller.go b/controller/controller.go
index 179353f..806c34a 100644
--- a/controller/controller.go
+++ b/controller/controller.go
@@ -127,8 +127,8 @@ func (c *Controller) syncLoop(ctx context.Context) {
        prevTermLeader := ""
        if c.clusterStore.IsLeader() {
                c.becomeLeader(ctx, prevTermLeader)
-               prevTermLeader = c.clusterStore.ID()
        }
+       prevTermLeader = c.clusterStore.Leader()
 
        c.readyCh <- struct{}{}
        for {
@@ -144,6 +144,7 @@ func (c *Controller) syncLoop(ctx context.Context) {
                                        continue
                                }
                                c.suspend()
+                               prevTermLeader = c.clusterStore.Leader()
                                logger.Get().Warn("Lost the leader, suspend the 
controller")
                        }
                case <-c.closeCh:

Reply via email to