Skip to content

Commit

Permalink
Update ns version history in handover state (#3456)
Browse files Browse the repository at this point in the history
  • Loading branch information
meiliang86 authored and dnr committed Oct 10, 2022
1 parent e2e7474 commit f089fda
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
11 changes: 1 addition & 10 deletions common/namespace/handler.go
Expand Up @@ -846,16 +846,7 @@ func (d *HandlerImpl) maybeUpdateFailoverHistory(
d.logger.Debug("updateReplicationConfig was nil")
return failoverHistory
}
desiredReplicationState := updateReplicationConfig.State
if desiredReplicationState == enumspb.REPLICATION_STATE_UNSPECIFIED {
desiredReplicationState = namespaceDetail.ReplicationConfig.State
}
// N.B., UNSPECIFIED is the same as NORMAL
if desiredReplicationState != enumspb.REPLICATION_STATE_NORMAL &&
desiredReplicationState != enumspb.REPLICATION_STATE_UNSPECIFIED {
d.logger.Debug("Replication state not NORMAL", tag.NewAnyTag("state", updateReplicationConfig.State))
return failoverHistory
}

lastFailoverVersion := int64(-1)
if l := len(namespaceDetail.ReplicationConfig.FailoverHistory); l > 0 {
lastFailoverVersion = namespaceDetail.ReplicationConfig.FailoverHistory[l-1].FailoverVersion
Expand Down
6 changes: 6 additions & 0 deletions common/namespace/handler_test.go
Expand Up @@ -608,6 +608,12 @@ func (s *namespaceHandlerCommonSuite) TestUpdateNamespace_UpdateActiveClusterWit
ActiveClusterName: clusterName2,
Clusters: []string{clusterName1, clusterName2},
State: enumspb.REPLICATION_STATE_HANDOVER,
FailoverHistory: []*persistencespb.FailoverStatus{
{
FailoverTime: timestamp.TimePtr(update1Time),
FailoverVersion: 2,
},
},
},
ConfigVersion: int64(0),
FailoverNotificationVersion: version,
Expand Down

0 comments on commit f089fda

Please sign in to comment.