Skip to content

Commit

Permalink
ddl: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zimulala committed May 30, 2019
1 parent 6e932a2 commit 268ea04
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions ddl/ddl_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,11 @@ func (w *worker) waitSchemaChanged(ctx context.Context, d *ddlCtx, waitTime time
return
}
d.schemaSyncer.NotifyCleanExpiredPaths()
// Wait until timeout.
select {
case <-ctx.Done():
return
}
}
logutil.Logger(w.logCtx).Info("[ddl] wait latest schema version changed", zap.Int64("ver", latestSchemaVersion), zap.Duration("takeTime", time.Since(timeStart)), zap.String("job", job.String()))
}
Expand Down
6 changes: 2 additions & 4 deletions ddl/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,7 @@ func (s *schemaVersionSyncer) StartCleanWork() {
continue
}

isFinished := s.doCleanExpirePaths(resp.Leases)
if isFinished {
if isFinished := s.doCleanExpirePaths(resp.Leases); isFinished {
break
}
time.Sleep(opRetryInterval)
Expand Down Expand Up @@ -458,7 +457,6 @@ func (s *schemaVersionSyncer) NotifyCleanExpiredPaths() {
}

func (s *schemaVersionSyncer) doCleanExpirePaths(leases []clientv3.LeaseStatus) bool {
ctx := context.Background()
failedGetIDs := 0
failedRevokeIDs := 0
startTime := time.Now()
Expand All @@ -471,7 +469,7 @@ func (s *schemaVersionSyncer) doCleanExpirePaths(leases []clientv3.LeaseStatus)
// The DDL owner key uses '%x', so here print it too.
leaseID := fmt.Sprintf("%x, %d", lease.ID, lease.ID)
childCtx, cancelFunc := context.WithTimeout(context.Background(), opDefaultTimeout)
ttlResp, err := s.etcdCli.TimeToLive(ctx, lease.ID)
ttlResp, err := s.etcdCli.TimeToLive(childCtx, lease.ID)
cancelFunc()
if err != nil {
logutil.Logger(ddlLogCtx).Info("[ddl] syncer clean expired paths, failed to get TTL.", zap.String("leaseID", leaseID), zap.Error(err))
Expand Down

0 comments on commit 268ea04

Please sign in to comment.