Skip to content

Commit

Permalink
ddl: tiny update
Browse files Browse the repository at this point in the history
  • Loading branch information
zimulala committed May 9, 2019
1 parent 3bfae8b commit 4ceaff8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 47 deletions.
4 changes: 1 addition & 3 deletions ddl/ddl_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,10 +630,8 @@ func (w *worker) waitSchemaChanged(ctx context.Context, d *ddlCtx, waitTime time
if terror.ErrorEqual(err, context.DeadlineExceeded) {
return
}
go d.schemaSyncer.NotifyCleanExpiredPaths()
d.schemaSyncer.NotifyCleanExpiredPaths()
}
// TODO: test
d.schemaSyncer.NotifyCleanExpiredPaths()
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
45 changes: 1 addition & 44 deletions ddl/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ func (s *schemaVersionSyncer) OwnerCheckAllVersions(ctx context.Context, latestV
const (
opDefaultRetryCnt = 10
failedGetTTLLimit = 20
neededCleanTTL = 50
neededCleanTTL = -60
opDefaultTimeout = 3 * time.Second
opRetryInterval = 500 * time.Millisecond
)
Expand Down Expand Up @@ -497,47 +497,4 @@ func (s *schemaVersionSyncer) doCleanExpirePaths(leases []clientv3.LeaseStatus)
return true
}
return false

//
// resp, err := s.etcdCli.Get(ctx, TiDBPath, clientv3.WithPrefix())
// if err != nil {
// logutil.Logger(ddlLogCtx).Info("[ddl] syncer clean expired paths, failed to get.", zap.Error(err))
// }
//
// logutil.Logger(ddlLogCtx).Info("[ddl] syncer clean expired paths, get keys.", zap.Int("kvs", len(resp.Kvs)))
// for _, kv := range resp.Kvs {
// leaseIDStr := string(bytes.TrimPrefix(kv.Key, []byte(DDLOwnerKey+"/")))
// leaseID, err := strconv.ParseInt(leaseIDStr, 16, 64) //strconv.Atoi(leaseIDStr)
// if err != nil {
// logutil.Logger(ddlLogCtx).Info("[ddl] syncer clean expired paths, convert value to int failed.", zap.String("leaseID", leaseIDStr), zap.Error(err))
// continue
// }
// ttlResp, err := s.etcdCli.TimeToLive(ctx, clientv3.LeaseID(leaseID))
// if err != nil {
// logutil.Logger(ddlLogCtx).Info("[ddl] syncer clean expired paths, failed to get TTL.", zap.Int64("leaseID", leaseID), zap.Error(err))
// }
// if ttlResp.TTL >= 50 {
// // TODO: remove this log.
// logutil.Logger(ddlLogCtx).Info("[ddl] syncer clean expired paths, delete keys.",
// zap.Int64("leaseID", leaseID), zap.Int64("TTL", ttlResp.TTL), zap.ByteString("leaseID key", kv.Key),
// zap.String("schema version key", DDLAllSchemaVersions+"/"+string(kv.Value)), zap.Error(err))
// continue
// }
//
// txnResp, err := s.etcdCli.Txn(ctx).
// If(clientv3.Compare(clientv3.LeaseValue(leaseID), "=", clientv3.LeaseID(leaseID))).
// Then(
// clientv3.OpDelete(string(kv.Key)),
// clientv3.OpDelete(DDLAllSchemaVersions+"/"+string(kv.Value)),
// ).Commit()
// if err != nil {
// logutil.Logger(ddlLogCtx).Info("[ddl] syncer clean expired paths, failed to delete keys.",
// zap.Int64("leaseID", leaseID), zap.Int64("TTL", ttlResp.TTL), zap.ByteString("leaseID key", kv.Key),
// zap.ByteString("leaseID key", kv.Key), zap.String("schema version key", DDLAllSchemaVersions+string(kv.Value)), zap.Error(err))
// }
// logutil.Logger(ddlLogCtx).Info("[ddl] syncer clean expired paths,",
// zap.Int64("leaseID", leaseID), zap.Int64("TTL", ttlResp.TTL), zap.ByteString("leaseID key", kv.Key),
// zap.ByteString("leaseID key", kv.Key), zap.String("schema version key", DDLAllSchemaVersions+string(kv.Value)),
// zap.Bool("resp succ", txnResp.Succeeded), zap.Stringer("ops", txnResp.Responses[0]))
// }
}

0 comments on commit 4ceaff8

Please sign in to comment.