Skip to content

sqlbase: generalize IMPORTING state to OFFLINE #39723

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

Merged
merged 1 commit into from
Aug 20, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions pkg/ccl/importccl/import_stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ type importResumer struct {
statsRefresher *stats.Refresher

testingKnobs struct {
forceFailure bool
afterImport func() error
}
}

Expand Down Expand Up @@ -686,7 +686,9 @@ func prepareNewTableDescsForIngestion(
}

for i := range tableDescs {
tableDescs[i].State = sqlbase.TableDescriptor_IMPORTING
tableDescs[i].State = sqlbase.TableDescriptor_OFFLINE
tableDescs[i].OfflineReason = "importing"

}

var seqValKVs []roachpb.KeyValue
Expand Down Expand Up @@ -730,7 +732,8 @@ func prepareExistingTableDescForIngestion(
// Take the table offline for import.
// TODO(dt): audit everywhere we get table descs (leases or otherwise) to
// ensure that filtering by state handles IMPORTING correctly.
importing.State = sqlbase.TableDescriptor_IMPORTING
importing.State = sqlbase.TableDescriptor_OFFLINE
importing.OfflineReason = "importing"
// TODO(dt): de-validate all the FKs.

if err := txn.SetSystemConfigTrigger(); err != nil {
Expand Down Expand Up @@ -923,8 +926,10 @@ func (r *importResumer) Resume(
if err != nil {
return err
}
if r.testingKnobs.forceFailure {
return errors.New("testing injected failure")
if r.testingKnobs.afterImport != nil {
if err := r.testingKnobs.afterImport(); err != nil {
return err
}
}

r.res = res
Expand Down
Loading