Skip to content

Commit

Permalink
Merge pull request #20777 from spencerkimball/fix-20745
Browse files Browse the repository at this point in the history
sql: ensure that the GC deadline has expired before truncating table
  • Loading branch information
spencerkimball authored Dec 20, 2017
2 parents 782217a + 374fd70 commit 90078d2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/sql/schema_changer.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,12 @@ func (sc *SchemaChanger) maybeAddDropRename(
return false, nil
}

// This can happen if a change other than the drop originally
// scheduled the changer for this table. If that's the case,
// we still need to wait for the deadline to expire.
if d := table.GCDeadline; d != 0 && timeutil.Since(timeutil.Unix(0, d)) < 0 {
return false, nil
}
// Do all the hard work of deleting the table data and the table ID.
if err := truncateTableInChunks(ctx, table, &sc.db, false /* traceKV */); err != nil {
return false, err
Expand Down Expand Up @@ -1048,7 +1054,7 @@ func (s *SchemaChangeManager) Start(stopper *stop.Stopper) {
table := union.Table
table.MaybeUpgradeFormatVersion()
if err := table.ValidateTable(); err != nil {
log.Errorf(ctx, "%s: received invalid table descriptor: %v", kv.Key, table)
log.Errorf(ctx, "%s: received invalid table descriptor: %v: %s", kv.Key, table, err)
continue
}

Expand Down

0 comments on commit 90078d2

Please sign in to comment.