Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
D3Hunter committed May 17, 2024
1 parent 040a45c commit 738f11c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
6 changes: 1 addition & 5 deletions pkg/ddl/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1233,11 +1233,7 @@ func (d *ddl) DoDDLJob(ctx sessionctx.Context, job *model.Job) error {
recordLastDDLInfo(ctx, historyJob)
}()
i := 0
notifyCh, ok := d.getJobDoneCh(job.ID)
if !ok {
// shouldn't happen, just give it a dummy one
notifyCh = make(chan struct{})
}
notifyCh, _ := d.getJobDoneCh(job.ID)
for {
failpoint.Inject("storeCloseInLoop", func(_ failpoint.Value) {
_ = d.Stop()
Expand Down
18 changes: 6 additions & 12 deletions pkg/ddl/syncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,11 @@ func (v *nodeVersions) len() int {
return len(v.nodeVersions)
}

// matchOrSet onceMatchFn must be nil before calling this method.
func (v *nodeVersions) matchOrSet(fn func(nodeVersions map[string]int64) bool) {
v.Lock()
defer v.Unlock()
if ok := fn(v.nodeVersions); !ok {
// onceMatchFn must be nil before.
v.onceMatchFn = fn
}
}
Expand Down Expand Up @@ -501,23 +501,17 @@ func (s *schemaVersionSyncer) syncJobSchemaVer(ctx context.Context) {
return
}
s.mu.Lock()
// item might be saved and accessed outside, so we only clear data here, will
// clean up emptyAndNotUsed items later.
for _, item := range s.jobNodeVersions {
item.clearData()
}
s.mu.Unlock()
for _, oneKV := range resp.Kvs {
s.handleJobSchemaVerKV(oneKV, mvccpb.PUT)
}
s.mu.Lock()
// we might miss some DELETE events during retry, some items might be emptyAndNotUsed, remove them.
for jobID, item := range s.jobNodeVersions {
item.clearData()
// we might miss some DELETE events during retry, some items might be emptyAndNotUsed, remove them.
if item.emptyAndNotUsed() {
delete(s.jobNodeVersions, jobID)
}
}
s.mu.Unlock()
for _, oneKV := range resp.Kvs {
s.handleJobSchemaVerKV(oneKV, mvccpb.PUT)
}

startRev := resp.Header.Revision + 1
watchCtx, watchCtxCancel := context.WithCancel(ctx)
Expand Down

0 comments on commit 738f11c

Please sign in to comment.