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

sqlccl: remove external storage dependency on RESTORE cleanup #21559

Merged
merged 1 commit into from Jan 19, 2018
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
30 changes: 14 additions & 16 deletions pkg/ccl/sqlccl/restore.go
Expand Up @@ -1133,6 +1133,16 @@ func doRestorePlan(
return err
}

var tables []*sqlbase.TableDescriptor
for _, desc := range sqlDescs {
if tableDesc := desc.GetTable(); tableDesc != nil {
tables = append(tables, tableDesc)
}
}
if err := rewriteTableDescs(tables, tableRewrites); err != nil {
return err
}

_, errCh, err := p.ExecCfg().JobRegistry.StartJob(ctx, resultsCh, jobs.Record{
Description: description,
Username: p.User(),
Expand All @@ -1146,6 +1156,7 @@ func doRestorePlan(
EndTime: endTime,
TableRewrites: tableRewrites,
URIs: from,
TableDescs: tables,
},
})
if err != nil {
Expand Down Expand Up @@ -1217,23 +1228,10 @@ func (r *restoreResumer) OnFailOrCancel(ctx context.Context, txn *client.Txn, jo
if err := txn.SetSystemConfigTrigger(); err != nil {
return err
}
_, sqlDescs, err := loadBackupSQLDescs(ctx, details, r.settings)
if err != nil {
return err
}
var tables []*sqlbase.TableDescriptor
for _, desc := range sqlDescs {
if tableDesc := desc.GetTable(); tableDesc != nil {
tableDesc.State = sqlbase.TableDescriptor_DROP
tables = append(tables, tableDesc)
}
}
if err := rewriteTableDescs(tables, details.TableRewrites); err != nil {
return err
}
b := txn.NewBatch()
for _, desc := range tables {
b.CPut(sqlbase.MakeDescMetadataKey(desc.ID), sqlbase.WrapDescriptor(desc), nil)
for _, tableDesc := range details.TableDescs {
tableDesc.State = sqlbase.TableDescriptor_DROP
b.CPut(sqlbase.MakeDescMetadataKey(tableDesc.ID), sqlbase.WrapDescriptor(tableDesc), nil)
}
return txn.Run(ctx, b)
}
Expand Down
211 changes: 131 additions & 80 deletions pkg/sql/jobs/jobs.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/sql/jobs/jobs.proto
Expand Up @@ -58,6 +58,7 @@ message RestoreDetails {
(gogoproto.castkey) = "github.com/cockroachdb/cockroach/pkg/sql/sqlbase.ID"
];
repeated string uris = 3 [(gogoproto.customname) = "URIs"];
repeated sqlbase.TableDescriptor table_descs = 5;
}

message ImportDetails {
Expand Down