Skip to content

Commit

Permalink
compactor: fix data race (#3417)
Browse files Browse the repository at this point in the history
  • Loading branch information
GMHDBJD authored and lance6716 committed Dec 30, 2021
1 parent c7c01b5 commit e7e3657
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions dm/syncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,11 @@ func (s *Syncer) addJob(job *job) error {
s.tctx.L().Info("All jobs is completed before syncer close, the coming job will be reject", zap.Any("job", job))
return nil
}
switch job.tp {

// avoid job.type data race with compactor.run()
// simply copy the opType for performance, though copy a new job in compactor is better
tp := job.tp
switch tp {
case xid:
s.waitXIDJob.CAS(int64(waiting), int64(waitComplete))
s.saveGlobalPoint(job.location)
Expand Down Expand Up @@ -978,7 +982,7 @@ func (s *Syncer) addJob(job *job) error {
return nil
}

switch job.tp {
switch tp {
case ddl:
failpoint.Inject("ExitAfterDDLBeforeFlush", func() {
s.tctx.L().Warn("exit triggered", zap.String("failpoint", "ExitAfterDDLBeforeFlush"))
Expand Down Expand Up @@ -1015,7 +1019,7 @@ func (s *Syncer) addJob(job *job) error {
}
}

if needFlush || job.tp == ddl {
if needFlush || tp == ddl {
// interrupted after save checkpoint and before flush checkpoint.
failpoint.Inject("FlushCheckpointStage", func(val failpoint.Value) {
err := handleFlushCheckpointStage(4, val.(int), "before flush checkpoint")
Expand Down

0 comments on commit e7e3657

Please sign in to comment.