Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: deadlock when domain failover #919

Merged
merged 5 commits into from
Jul 3, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions common/cache/domainCache.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,11 @@ func (c *domainCache) GetAllDomain() map[string]*DomainCacheEntry {
for ite.HasNext() {
entry := ite.Next()
id := entry.Key().(string)
domainCacheEntry := entry.Value().(*DomainCacheEntry).duplicate()
result[id] = domainCacheEntry
domainCacheEntry := entry.Value().(*DomainCacheEntry)
domainCacheEntry.RLock()
dup := domainCacheEntry.duplicate()
domainCacheEntry.RUnlock()
result[id] = dup
}
return result
}
Expand All @@ -185,13 +188,13 @@ func (c *domainCache) GetAllDomain() map[string]*DomainCacheEntry {
// afterCallback will be invoked when NOT holding the domain cache lock.
func (c *domainCache) RegisterDomainChangeCallback(shard int, initialNotificationVersion int64, beforeCallback CallbackFn, afterCallback CallbackFn) {
c.Lock()
defer c.Unlock()

c.beforeCallbacks[shard] = beforeCallback
c.afterCallbacks[shard] = afterCallback
domainNotificationVersion := c.domainNotificationVersion
c.Unlock()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like both before and after callbacks were called within the lock before this change and now they are called outside of the lock. Do we even need 2 separate callbacks?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do not really need a 2 type of callbacks, one before one after, i thought providing 2 type of callbacks can be useful


// this section is trying to make the shard catch up with domain changes
if c.domainNotificationVersion > initialNotificationVersion {
if domainNotificationVersion > initialNotificationVersion {
domains := DomainCacheEntries{}
for _, domain := range c.GetAllDomain() {
domains = append(domains, domain)
Expand Down
1 change: 0 additions & 1 deletion service/history/timerQueueProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ func (t *timerQueueProcessorImpl) FailoverDomain(domainID string) {
failoverTimerProcessor := newTimerQueueFailoverProcessor(t.shard, t.historyService, domainID,
standbyClusterName, minLevel, maxLevel, t.matchingClient, t.logger)
failoverTimerProcessor.Start()
failoverTimerProcessor.timerQueueProcessorBase.readAndFanoutTimerTasks()
}

func (t *timerQueueProcessorImpl) getTimerFiredCount(clusterName string) uint64 {
Expand Down
1 change: 0 additions & 1 deletion service/history/transferQueueProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ func (t *transferQueueProcessorImpl) FailoverDomain(domainID string) {
domainID, standbyClusterName, minLevel, maxLevel, t.logger,
)
failoverTaskProcessor.Start()
failoverTaskProcessor.notifyNewTask()
}

func (t *transferQueueProcessorImpl) completeTransferLoop() {
Expand Down