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 851ae37  Relax the cluster version check when updating the cluster 
(#238)
851ae37 is described below

commit 851ae37a340c61c3aaac2a581f58e3531cf15f4a
Author: hulk <[email protected]>
AuthorDate: Tue Dec 24 09:52:10 2024 +0800

    Relax the cluster version check when updating the cluster (#238)
    
    Before this PR, we require the cluster shouldn't be modified when
    updating, but users might modify the cluster information via the redis
    client during this period. To allow this, we only check if the current
    version is newer than the store.
---
 store/store.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/store/store.go b/store/store.go
index 6c64980..f0f6672 100644
--- a/store/store.go
+++ b/store/store.go
@@ -180,7 +180,7 @@ func (s *ClusterStore) UpdateCluster(ctx context.Context, 
ns string, clusterInfo
        if err != nil {
                return err
        }
-       if oldCluster.Version.Load() != clusterInfo.Version.Load() {
+       if oldCluster.Version.Load() > clusterInfo.Version.Load() {
                return fmt.Errorf("the cluster has been updated by others")
        }
 
@@ -212,7 +212,7 @@ func (s *ClusterStore) SetCluster(ctx context.Context, ns 
string, clusterInfo *C
        if err != nil {
                return err
        }
-       if oldCluster.Version.Load() != clusterInfo.Version.Load() {
+       if oldCluster.Version.Load() > clusterInfo.Version.Load() {
                return fmt.Errorf("the cluster has been updated by others")
        }
 

Reply via email to