Skip to content

Commit

Permalink
Fix queue diff metrics for disabled clusters (#2329)
Browse files Browse the repository at this point in the history
  • Loading branch information
yycptt authored Dec 29, 2021
1 parent 94ef184 commit 81ce604
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions service/history/replicationDLQHandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func (s *replicationDLQHandlerSuite) SetupTest() {
s.shardManager = s.mockResource.ShardMgr
s.config = tests.NewDynamicConfig()
s.clusterMetadata.EXPECT().GetCurrentClusterName().Return(cluster.TestCurrentClusterName).AnyTimes()
s.clusterMetadata.EXPECT().GetAllClusterInfo().Return(cluster.TestAllClusterInfo).AnyTimes()
s.taskExecutors = make(map[string]replicationTaskExecutor)
s.taskExecutor = NewMockreplicationTaskExecutor(s.controller)
s.sourceCluster = cluster.TestAlternativeClusterName
Expand Down
13 changes: 11 additions & 2 deletions service/history/shard/context_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -992,10 +992,15 @@ func (s *ContextImpl) updateShardInfoLocked() error {

func (s *ContextImpl) emitShardInfoMetricsLogsLocked() {
currentCluster := s.GetClusterMetadata().GetCurrentClusterName()
clusterInfo := s.GetClusterMetadata().GetAllClusterInfo()

minTransferLevel := s.shardInfo.ClusterTransferAckLevel[currentCluster]
maxTransferLevel := s.shardInfo.ClusterTransferAckLevel[currentCluster]
for _, v := range s.shardInfo.ClusterTransferAckLevel {
for clusterName, v := range s.shardInfo.ClusterTransferAckLevel {
if !clusterInfo[clusterName].Enabled {
continue
}

if v < minTransferLevel {
minTransferLevel = v
}
Expand All @@ -1007,7 +1012,11 @@ func (s *ContextImpl) emitShardInfoMetricsLogsLocked() {

minTimerLevel := timestamp.TimeValue(s.shardInfo.ClusterTimerAckLevel[currentCluster])
maxTimerLevel := timestamp.TimeValue(s.shardInfo.ClusterTimerAckLevel[currentCluster])
for _, v := range s.shardInfo.ClusterTimerAckLevel {
for clusterName, v := range s.shardInfo.ClusterTimerAckLevel {
if !clusterInfo[clusterName].Enabled {
continue
}

t := timestamp.TimeValue(v)
if t.Before(minTimerLevel) {
minTimerLevel = t
Expand Down
2 changes: 2 additions & 0 deletions service/history/timerQueueAckMgr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ func (s *timerQueueAckMgrSuite) TestReadCompleteUpdateTimerTasks() {
NextPageToken: nil,
}
s.mockClusterMetadata.EXPECT().GetCurrentClusterName().Return(cluster.TestCurrentClusterName).AnyTimes()
s.mockClusterMetadata.EXPECT().GetAllClusterInfo().Return(cluster.TestAllClusterInfo).AnyTimes()
s.mockExecutionMgr.EXPECT().GetTimerTasks(gomock.Any()).Return(response, nil)
s.mockExecutionMgr.EXPECT().GetTimerTasks(gomock.Any()).Return(&persistence.GetTimerTasksResponse{}, nil)
filteredTasks, lookAheadTask, moreTasks, err := s.timerQueueAckMgr.readTimerTasks()
Expand Down Expand Up @@ -784,6 +785,7 @@ func (s *timerQueueFailoverAckMgrSuite) TestReadCompleteUpdateTimerTasks() {
NextPageToken: nil,
}
s.mockClusterMetadata.EXPECT().GetCurrentClusterName().Return(cluster.TestCurrentClusterName).AnyTimes()
s.mockClusterMetadata.EXPECT().GetAllClusterInfo().Return(cluster.TestAllClusterInfo).AnyTimes()
s.mockExecutionMgr.EXPECT().GetTimerTasks(gomock.Any()).Return(response, nil)
filteredTasks, lookAheadTask, moreTasks, err := s.timerQueueFailoverAckMgr.readTimerTasks()
s.Nil(err)
Expand Down

0 comments on commit 81ce604

Please sign in to comment.