Skip to content

Commit

Permalink
Fix failover marker update lock (cadence-workflow#3412)
Browse files Browse the repository at this point in the history
  • Loading branch information
yux0 authored Jul 27, 2020
1 parent 2db63ea commit 713a7a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions service/history/failover/marker_notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,14 @@ func (m *markerNotifierImpl) Stop() {

func (m *markerNotifierImpl) notifyPendingFailoverMarker() {

ticker := time.NewTicker(m.config.NotifyFailoverMarkerInterval())
defer ticker.Stop()

for {
select {
case <-m.shutdownCh:
return
default:
case <-ticker.C:
markers, err := m.shard.ValidateAndUpdateFailoverMarkers()
if err != nil {
m.logger.Error("Failed to update pending failover markers in shard info.", tag.Error(err))
Expand All @@ -110,7 +113,6 @@ func (m *markerNotifierImpl) notifyPendingFailoverMarker() {
if len(markers) > 0 {
m.failoverCoordinator.NotifyFailoverMarkers(int32(m.shard.GetShardID()), markers)
}
time.Sleep(m.config.NotifyFailoverMarkerInterval())
}
}
}
1 change: 1 addition & 0 deletions service/history/shard/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,7 @@ func (s *contextImpl) ValidateAndUpdateFailoverMarkers() ([]*replicator.Failover
}

if len(completedFailoverMarkers) == 0 {
s.RUnlock()
return s.pendingFailoverMarkers, nil
}
s.RUnlock()
Expand Down

0 comments on commit 713a7a9

Please sign in to comment.