Skip to content

Commit

Permalink
ddl: fix a data race on localRowCntListener Written() (#54484)
Browse files Browse the repository at this point in the history
close #54373
  • Loading branch information
River2000i authored Jul 26, 2024
1 parent e0e8f89 commit e366584
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/ddl/backfilling.go
Original file line number Diff line number Diff line change
Expand Up @@ -782,12 +782,17 @@ type localRowCntListener struct {
// prevPhysicalRowCnt records the row count from previous physical tables (partitions).
prevPhysicalRowCnt int64
// curPhysicalRowCnt records the row count of current physical table.
curPhysicalRowCnt int64
curPhysicalRowCnt struct {
cnt int64
mu sync.Mutex
}
}

func (s *localRowCntListener) Written(rowCnt int) {
s.curPhysicalRowCnt += int64(rowCnt)
s.reorgCtx.setRowCount(s.prevPhysicalRowCnt + s.curPhysicalRowCnt)
s.curPhysicalRowCnt.mu.Lock()
s.curPhysicalRowCnt.cnt += int64(rowCnt)
s.reorgCtx.setRowCount(s.prevPhysicalRowCnt + s.curPhysicalRowCnt.cnt)
s.curPhysicalRowCnt.mu.Unlock()
s.counter.Add(float64(rowCnt))
}

Expand Down

0 comments on commit e366584

Please sign in to comment.