Skip to content

Commit

Permalink
Merge pull request #8567 from influxdata/jw-monitor-lock
Browse files Browse the repository at this point in the history
Reduce lock contention when disabling compactions
  • Loading branch information
jwilder authored Jul 6, 2017
2 parents 7374e4e + 9ac042b commit 16af32b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tsdb/engine/tsm1/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,16 @@ func (e *Engine) SetCompactionsEnabled(enabled bool) {
// 'wait' signifies that a corresponding call to disableLevelCompactions(true) was made at some
// point, and the associated task that required disabled compactions is now complete
func (e *Engine) enableLevelCompactions(wait bool) {
// If we don't need to wait, see if we're already enabled
if !wait {
e.mu.RLock()
if e.done != nil {
e.mu.RUnlock()
return
}
e.mu.RUnlock()
}

e.mu.Lock()
if wait {
e.levelWorkers -= 1
Expand Down Expand Up @@ -263,6 +273,15 @@ func (e *Engine) disableLevelCompactions(wait bool) {
}

func (e *Engine) enableSnapshotCompactions() {
// Check if already enabled under read lock
e.mu.RLock()
if e.snapDone != nil {
e.mu.RUnlock()
return
}
e.mu.RUnlock()

// Check again under write lock
e.mu.Lock()
if e.snapDone != nil {
e.mu.Unlock()
Expand Down

0 comments on commit 16af32b

Please sign in to comment.