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

ddl, parser: fix the DDL job version using issue (#47915) #47936

Merged
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
2 changes: 1 addition & 1 deletion pkg/ddl/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1407,7 +1407,7 @@ func GetDDLInfoWithNewTxn(s sessionctx.Context) (*Info, error) {
return info, err
}

// GetDDLInfo returns DDL information.
// GetDDLInfo returns DDL information and only uses for testing.
func GetDDLInfo(s sessionctx.Context) (*Info, error) {
var err error
info := &Info{}
Expand Down
1 change: 1 addition & 0 deletions pkg/ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -8993,5 +8993,6 @@ func NewDDLReorgMeta(ctx sessionctx.Context) *model.DDLReorgMeta {
WarningsCount: make(map[errors.ErrorID]int64),
Location: &model.TimeZoneLocation{Name: tzName, Offset: tzOffset},
ResourceGroupName: ctx.GetSessionVars().ResourceGroupName,
Version: model.CurrentReorgMetaVersion,
}
}
13 changes: 12 additions & 1 deletion pkg/ddl/reorg.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ func (w *worker) runReorgJob(reorgInfo *reorgInfo, tblInfo *model.TableInfo,
Warnings: make(map[errors.ErrorID]*terror.Error),
WarningsCount: make(map[errors.ErrorID]int64),
Location: &model.TimeZoneLocation{Name: time.UTC.String(), Offset: 0},
Version: model.CurrentReorgMetaVersion,
}
}

Expand Down Expand Up @@ -892,5 +893,15 @@ func CleanupDDLReorgHandles(job *model.Job, s *sess.Session) {

// GetDDLReorgHandle gets the latest processed DDL reorganize position.
func (r *reorgHandler) GetDDLReorgHandle(job *model.Job) (element *meta.Element, startKey, endKey kv.Key, physicalTableID int64, err error) {
return getDDLReorgHandle(r.s, job)
element, startKey, endKey, physicalTableID, err = getDDLReorgHandle(r.s, job)
if job.ReorgMeta != nil && job.ReorgMeta.Version == model.ReorgMetaVersion0 && err == nil {
logutil.BgLogger().Info("job get table range for old version ReorgMetas", zap.String("category", "ddl"),
zap.Int64("jobID", job.ID), zap.Int64("job ReorgMeta version", job.ReorgMeta.Version), zap.Int64("physical table ID", physicalTableID),
zap.String("startKey", hex.EncodeToString(startKey)),
zap.String("current endKey", hex.EncodeToString(endKey)),
zap.String("endKey next", hex.EncodeToString(endKey.Next())))
endKey = endKey.Next()
}

return
}
9 changes: 9 additions & 0 deletions pkg/parser/model/reorg.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,17 @@ type DDLReorgMeta struct {
ReorgTp ReorgType `json:"reorg_tp"`
IsDistReorg bool `json:"is_dist_reorg"`
ResourceGroupName string `json:"resource_group_name"`
Version int64 `json:"version"`
}

const (
// ReorgMetaVersion0 is the minimum version of DDLReorgMeta.
ReorgMetaVersion0 = int64(0)
// CurrentReorgMetaVersion is the current version of DDLReorgMeta.
// For fix #46306(whether end key is included or not in the table range) to add the version to 1.
CurrentReorgMetaVersion = int64(1)
)

// ReorgType indicates which process is used for the data reorganization.
type ReorgType int8

Expand Down