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

Unload tasklist when no poller recently #519

Merged
merged 3 commits into from
Jan 26, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion service/matching/pollerHistory.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type (
)

type pollerHistory struct {
// // poller ID -> last access time
// poller ID -> last access time
// pollers map[pollerID]time.Time
history cache.Cache
}
Expand Down
2 changes: 2 additions & 0 deletions service/matching/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Config struct {
RangeSize int64
GetTasksBatchSize int
UpdateAckInterval time.Duration
IdleTasklistCheckInterval time.Duration
MinTaskThrottlingBurstSize int

// taskWriter configuration
Expand All @@ -53,6 +54,7 @@ func NewConfig() *Config {
RangeSize: 100000,
GetTasksBatchSize: 1000,
UpdateAckInterval: 10 * time.Second,
IdleTasklistCheckInterval: 5 * time.Minute,
OutstandingTaskAppendsThreshold: 250,
MaxTaskBatchSize: 100,
MinTaskThrottlingBurstSize: 10000,
Expand Down
10 changes: 10 additions & 0 deletions service/matching/taskListManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@ func (c *taskListManagerImpl) getTasksPump() {

go c.deliverBufferTasksForPoll()
updateAckTimer := time.NewTimer(c.config.UpdateAckInterval)
checkPollerTimer := time.NewTimer(c.config.IdleTasklistCheckInterval)
getTasksPumpLoop:
for {
select {
Expand Down Expand Up @@ -716,10 +717,19 @@ getTasksPumpLoop:
c.signalNewTask() // periodically signal pump to check persistence for tasks
updateAckTimer = time.NewTimer(c.config.UpdateAckInterval)
}
case <-checkPollerTimer.C:
{
pollers := c.GetAllPollerInfo()
if len(pollers) == 0 {
c.Stop()
}
checkPollerTimer = time.NewTimer(c.config.IdleTasklistCheckInterval)
}
}
}

updateAckTimer.Stop()
checkPollerTimer.Stop()
}

// Retry operation on transient error and on rangeID change. On rangeID update by another process calls c.Stop().
Expand Down