Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-21.2: sql: use clear range to clean tables during rollback of create #79603

Merged
merged 1 commit into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 2 additions & 7 deletions pkg/sql/gcjob/table_garbage_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,12 @@ func ClearTableData(
sv *settings.Values,
table catalog.TableDescriptor,
) error {
// If DropTime isn't set, assume this drop request is from a version
// 1.1 server and invoke legacy code that uses DeleteRange and range GC.
// TODO(pbardea): Note that we never set the drop time for interleaved tables,
// but this check was added to be more explicit about it. This should get
// cleaned up.
if table.GetDropTime() == 0 || table.IsInterleaved() {
// If interleaved tables are used invoke legacy code that uses DeleteRange and range GC.
if table.IsInterleaved() {
log.Infof(ctx, "clearing data in chunks for table %d", table.GetID())
return sql.ClearTableDataInChunks(ctx, db, codec, sv, table, false /* traceKV */)
}
log.Infof(ctx, "clearing data for table %d", table.GetID())

tableKey := roachpb.RKey(codec.TablePrefix(uint32(table.GetID())))
tableSpan := roachpb.RSpan{Key: tableKey, EndKey: tableKey.PrefixEnd()}
return clearSpanData(ctx, db, distSender, tableSpan)
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/schema_changer.go
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,7 @@ func (sc *SchemaChanger) rollbackSchemaChange(ctx context.Context, err error) er

b := txn.NewBatch()
scTable.SetDropped()
scTable.DropTime = timeutil.Now().UnixNano()
if err := descsCol.WriteDescToBatch(ctx, false /* kvTrace */, scTable, b); err != nil {
return err
}
Expand Down