Skip to content

Commit

Permalink
br: modify how to parse the add index job args (#47456) (#47472)
Browse files Browse the repository at this point in the history
close #47451
  • Loading branch information
ti-chi-bot authored Oct 9, 2023
1 parent 1d2fd36 commit 04ac200
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
20 changes: 14 additions & 6 deletions br/pkg/restore/ingestrec/ingest_recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,15 @@ func (i *IngestRecorder) AddJob(job *model.Job) error {
return nil
}

var indexID int64 = 0
if err := job.DecodeArgs(&indexID); err != nil {
return errors.Trace(err)
allIndexIDs := make([]int64, 1)
// The job.Args is either `Multi-index: ([]int64, ...)`,
// or `Single-index: (int64, ...)`.
// TODO: it's better to use the public function to parse the
// job's Args.
if err := job.DecodeArgs(&allIndexIDs[0]); err != nil {
if err = job.DecodeArgs(&allIndexIDs); err != nil {
return errors.Trace(err)
}
}

tableindexes, exists := i.items[job.TableID]
Expand All @@ -92,9 +98,11 @@ func (i *IngestRecorder) AddJob(job *model.Job) error {

// the current information of table/index might be modified by other ddl jobs,
// therefore update the index information at last
tableindexes[indexID] = &IngestIndexInfo{
IsPrimary: job.Type == model.ActionAddPrimaryKey,
Updated: false,
for _, indexID := range allIndexIDs {
tableindexes[indexID] = &IngestIndexInfo{
IsPrimary: job.Type == model.ActionAddPrimaryKey,
Updated: false,
}
}

return nil
Expand Down
11 changes: 6 additions & 5 deletions br/pkg/stream/rewrite_meta_rawkv.go
Original file line number Diff line number Diff line change
Expand Up @@ -840,15 +840,16 @@ func (sr *SchemasReplace) deleteRange(job *model.Job) error {
zap.Int64("oldTableID", job.TableID))
return nil
}
var indexID int64
var ifExists bool
indexIDs := make([]int64, 1)
ifExists := make([]bool, 1)
var partitionIDs []int64
if err := job.DecodeArgs(&indexID, &ifExists, &partitionIDs); err != nil {
return errors.Trace(err)
if err := job.DecodeArgs(&indexIDs[0], &ifExists[0], &partitionIDs); err != nil {
if err = job.DecodeArgs(&indexIDs, &ifExists, &partitionIDs); err != nil {
return errors.Trace(err)
}
}

var elementID int64 = 1
indexIDs := []int64{indexID}

if len(partitionIDs) > 0 {
for _, oldPid := range partitionIDs {
Expand Down

0 comments on commit 04ac200

Please sign in to comment.