Skip to content

Commit 59a0543

Browse files
authored
Reset replication state when active cluster changed (#8233)
## What changed? Reset replication state when active cluster changed ## Why? When the active cluster changes, we treat it a failover happens, graceful or forceful. It should clean the state. ## How did you test it? - [ ] built - [ ] run locally and tested manually - [ ] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s)
1 parent 11e54a1 commit 59a0543

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

service/frontend/namespace_handler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ func (d *namespaceHandler) UpdateNamespace(
513513
if updateReplicationConfig.GetActiveClusterName() != "" {
514514
activeClusterChanged = true
515515
replicationConfig.ActiveClusterName = updateReplicationConfig.GetActiveClusterName()
516+
replicationConfig.State = enumspb.REPLICATION_STATE_NORMAL
516517
}
517518
}
518519

@@ -884,7 +885,7 @@ func (d *namespaceHandler) createResponse(
884885
replicationConfigResult := &replicationpb.NamespaceReplicationConfig{
885886
ActiveClusterName: replicationConfig.ActiveClusterName,
886887
Clusters: clusters,
887-
State: replicationConfig.State,
888+
State: replicationConfig.GetState(),
888889
}
889890

890891
var failoverHistory []*replicationpb.FailoverStatus

service/frontend/namespace_handler_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ func (s *namespaceHandlerCommonSuite) TestUpdateNamespace_UpdateActiveClusterWit
679679
ReplicationConfig: &persistencespb.NamespaceReplicationConfig{
680680
ActiveClusterName: clusterName2,
681681
Clusters: []string{clusterName1, clusterName2},
682-
State: enumspb.REPLICATION_STATE_HANDOVER,
682+
State: enumspb.REPLICATION_STATE_NORMAL,
683683
FailoverHistory: []*persistencespb.FailoverStatus{
684684
{
685685
FailoverTime: timestamppb.New(update1Time),
@@ -754,6 +754,7 @@ func (s *namespaceHandlerCommonSuite) TestUpdateNamespace_ChangeActiveClusterWit
754754
ReplicationConfig: &persistencespb.NamespaceReplicationConfig{
755755
ActiveClusterName: clusterName2,
756756
Clusters: []string{clusterName1, clusterName2},
757+
State: enumspb.REPLICATION_STATE_NORMAL,
757758
FailoverHistory: []*persistencespb.FailoverStatus{
758759
{
759760
FailoverTime: timestamppb.New(update1Time),
@@ -865,6 +866,7 @@ func (s *namespaceHandlerCommonSuite) TestUpdateNamespace_UpdateActiveCluster_Li
865866
ReplicationConfig: &persistencespb.NamespaceReplicationConfig{
866867
ActiveClusterName: clusterName2,
867868
Clusters: []string{clusterName1, clusterName2},
869+
State: enumspb.REPLICATION_STATE_NORMAL,
868870
FailoverHistory: sizeLimitedFailoverHistory,
869871
},
870872
ConfigVersion: 0,
@@ -1147,6 +1149,7 @@ func (s *namespaceHandlerCommonSuite) TestUpdateLocalNamespace_AllAttrSet() {
11471149
ReplicationConfig: &persistencespb.NamespaceReplicationConfig{
11481150
ActiveClusterName: activeClusterName,
11491151
Clusters: []string{activeClusterName},
1152+
State: enumspb.REPLICATION_STATE_NORMAL,
11501153
},
11511154
ConfigVersion: 1,
11521155
FailoverNotificationVersion: 0,
@@ -1666,6 +1669,7 @@ func (s *namespaceHandlerCommonSuite) TestFailoverGlobalNamespace_NotMaster() {
16661669
ReplicationConfig: &persistencespb.NamespaceReplicationConfig{
16671670
ActiveClusterName: clusterName2,
16681671
Clusters: []string{clusterName1, clusterName2},
1672+
State: enumspb.REPLICATION_STATE_NORMAL,
16691673
FailoverHistory: []*persistencespb.FailoverStatus{
16701674
{
16711675
FailoverTime: timestamppb.New(update1Time),

0 commit comments

Comments
 (0)