Skip to content

Commit

Permalink
fix rowcontainer data race
Browse files Browse the repository at this point in the history
  • Loading branch information
wshwsh12 committed Feb 6, 2020
1 parent 2aeb4a6 commit 36ecd38
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions util/chunk/row_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,14 @@ type SpillDiskAction struct {
once sync.Once
c *RowContainer
fallbackAction memory.ActionOnExceed
m sync.Mutex
}

// Action sends a signal to trigger spillToDisk method of RowContainer
// and if it is already triggered before, call its fallbackAction.
func (a *SpillDiskAction) Action(t *memory.Tracker) {
a.m.Lock()
defer a.m.Unlock()
if a.c.AlreadySpilledSafe() {
if a.fallbackAction != nil {
a.fallbackAction.Action(t)
Expand All @@ -237,10 +240,14 @@ func (a *SpillDiskAction) SetLogHook(hook func(uint64)) {}

// ResetOnce resets the spill action so that it can be triggered next time.
func (a *SpillDiskAction) ResetOnce() {
a.m.Lock()
defer a.m.Unlock()
a.once = sync.Once{}
}

// SetRowContainer sets the RowContainer for the SpillDiskAction.
func (a *SpillDiskAction) SetRowContainer(c *RowContainer) {
a.m.Lock()
defer a.m.Unlock()
a.c = c
}

0 comments on commit 36ecd38

Please sign in to comment.