Skip to content

Commit ace2802

Browse files
committed
Merge remote-tracking branch 'pingcap/master' into truncate-partition-global-index
2 parents 8470761 + 5da9d1a commit ace2802

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+3520
-2670
lines changed

DEPS.bzl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5958,13 +5958,13 @@ def go_deps():
59585958
name = "com_github_prometheus_client_golang",
59595959
build_file_proto_mode = "disable_global",
59605960
importpath = "github.com/prometheus/client_golang",
5961-
sha256 = "cbd030de8f05e9b09cfe58890248629bc522f73a250ebacac26cb654dd88b709",
5962-
strip_prefix = "github.com/prometheus/[email protected].4",
5961+
sha256 = "b76de10864f49c87a347b9a3e6fe606c1f93ed091de7d0d1d17a5967a60f5ce2",
5962+
strip_prefix = "github.com/prometheus/[email protected].5",
59635963
urls = [
5964-
"http://bazel-cache.pingcap.net:8080/gomod/github.com/prometheus/client_golang/com_github_prometheus_client_golang-v1.20.4.zip",
5965-
"http://ats.apps.svc/gomod/github.com/prometheus/client_golang/com_github_prometheus_client_golang-v1.20.4.zip",
5966-
"https://cache.hawkingrei.com/gomod/github.com/prometheus/client_golang/com_github_prometheus_client_golang-v1.20.4.zip",
5967-
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/prometheus/client_golang/com_github_prometheus_client_golang-v1.20.4.zip",
5964+
"http://bazel-cache.pingcap.net:8080/gomod/github.com/prometheus/client_golang/com_github_prometheus_client_golang-v1.20.5.zip",
5965+
"http://ats.apps.svc/gomod/github.com/prometheus/client_golang/com_github_prometheus_client_golang-v1.20.5.zip",
5966+
"https://cache.hawkingrei.com/gomod/github.com/prometheus/client_golang/com_github_prometheus_client_golang-v1.20.5.zip",
5967+
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/prometheus/client_golang/com_github_prometheus_client_golang-v1.20.5.zip",
59685968
],
59695969
)
59705970
go_repository(

br/pkg/conn/conn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func NewMgr(
184184
return nil, errors.Errorf("unknown command type, comman code is %d", versionCheckerType)
185185
}
186186
if versionErr != nil {
187-
return nil, errors.Annotate(err, "running BR in incompatible version of cluster, "+
187+
return nil, errors.Annotate(versionErr, "running BR in incompatible version of cluster, "+
188188
"if you believe it's OK, use --check-requirements=false to skip.")
189189
}
190190
}

br/pkg/gluetidb/glue.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func (g Glue) startDomainAsNeeded(store kv.Storage) error {
111111
if err != nil {
112112
return err
113113
}
114-
return dom.Start()
114+
return dom.Start(ddl.Normal)
115115
}
116116

117117
func (g Glue) createTypesSession(store kv.Storage) (sessiontypes.Session, error) {

build/nogo_config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@
524524
"pkg/parser/ast/": "ignore parser/ast code",
525525
"pkg/parser/test_driver/": "ignore parser/test_driver code",
526526
"pkg/planner/core/plan_clone_generated.go": "ignore plan_clone_generated code",
527+
"pkg/planner/core/operator/logicalop/hash64_equals_generated.go": "ignore hash64_equals_generated code",
527528
".*_test\\.go$": "ignore generated code",
528529
".*_generated\\.go$": "ignore generated code",
529530
".*mock.go$": "ignore generated code",

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ require (
9191
github.com/pingcap/sysutil v1.0.1-0.20240311050922-ae81ee01f3a5
9292
github.com/pingcap/tidb/pkg/parser v0.0.0-20211011031125-9b13dc409c5e
9393
github.com/pingcap/tipb v0.0.0-20241008083645-0bcddae67837
94-
github.com/prometheus/client_golang v1.20.4
94+
github.com/prometheus/client_golang v1.20.5
9595
github.com/prometheus/client_model v0.6.1
9696
github.com/prometheus/common v0.57.0
9797
github.com/prometheus/prometheus v0.50.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,8 +698,8 @@ github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b/go.mod h1:Om
698698
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
699699
github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
700700
github.com/prometheus/client_golang v0.9.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
701-
github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI=
702-
github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
701+
github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
702+
github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
703703
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
704704
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
705705
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=

pkg/ddl/ddl.go

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,20 @@ var (
9393
detectJobVerInterval = 10 * time.Second
9494
)
9595

96+
// StartMode is an enum type for the start mode of the DDL.
97+
type StartMode string
98+
99+
const (
100+
// Normal mode, cluster is in normal state.
101+
Normal StartMode = "normal"
102+
// Bootstrap mode, cluster is during bootstrap.
103+
Bootstrap StartMode = "bootstrap"
104+
// Upgrade mode, cluster is during upgrade, we will force current node to be
105+
// the DDL owner, to make sure all upgrade related DDLs are run on new version
106+
// TiDB instance.
107+
Upgrade StartMode = "upgrade"
108+
)
109+
96110
// OnExist specifies what to do when a new object has a name collision.
97111
type OnExist uint8
98112

@@ -161,7 +175,7 @@ var (
161175
type DDL interface {
162176
// Start campaigns the owner and starts workers.
163177
// ctxPool is used for the worker's delRangeManager and creates sessions.
164-
Start(ctxPool *pools.ResourcePool) error
178+
Start(startMode StartMode, ctxPool *pools.ResourcePool) error
165179
// Stats returns the DDL statistics.
166180
Stats(vars *variable.SessionVars) (map[string]any, error)
167181
// GetScope gets the status variables scope.
@@ -746,10 +760,21 @@ func (d *ddl) newDeleteRangeManager(mock bool) delRangeManager {
746760
}
747761

748762
// Start implements DDL.Start interface.
749-
func (d *ddl) Start(ctxPool *pools.ResourcePool) error {
763+
func (d *ddl) Start(startMode StartMode, ctxPool *pools.ResourcePool) error {
750764
d.detectAndUpdateJobVersion()
765+
campaignOwner := config.GetGlobalConfig().Instance.TiDBEnableDDL.Load()
766+
if startMode == Upgrade {
767+
if !campaignOwner {
768+
return errors.New("DDL must be enabled when upgrading")
769+
}
770+
771+
logutil.DDLLogger().Info("DDL is in upgrade mode, force to be owner")
772+
if err := d.ownerManager.ForceToBeOwner(d.ctx); err != nil {
773+
return errors.Trace(err)
774+
}
775+
}
751776
logutil.DDLLogger().Info("start DDL", zap.String("ID", d.uuid),
752-
zap.Bool("runWorker", config.GetGlobalConfig().Instance.TiDBEnableDDL.Load()),
777+
zap.Bool("runWorker", campaignOwner),
753778
zap.Stringer("jobVersion", model.GetJobVerInUse()))
754779

755780
d.sessPool = sess.NewSessionPool(ctxPool)
@@ -784,7 +809,7 @@ func (d *ddl) Start(ctxPool *pools.ResourcePool) error {
784809

785810
// If tidb_enable_ddl is true, we need campaign owner and do DDL jobs. Besides, we also can do backfill jobs.
786811
// Otherwise, we needn't do that.
787-
if config.GetGlobalConfig().Instance.TiDBEnableDDL.Load() {
812+
if campaignOwner {
788813
if err := d.EnableDDL(); err != nil {
789814
return err
790815
}

pkg/ddl/executor.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import (
5151
pmodel "github.com/pingcap/tidb/pkg/parser/model"
5252
"github.com/pingcap/tidb/pkg/parser/mysql"
5353
"github.com/pingcap/tidb/pkg/parser/terror"
54+
parser_types "github.com/pingcap/tidb/pkg/parser/types"
5455
"github.com/pingcap/tidb/pkg/privilege"
5556
rg "github.com/pingcap/tidb/pkg/resourcegroup"
5657
"github.com/pingcap/tidb/pkg/sessionctx"
@@ -3962,6 +3963,10 @@ func checkAlterTableCharset(tblInfo *model.TableInfo, dbInfo *model.DBInfo, toCh
39623963
return doNothing, nil
39633964
}
39643965

3966+
if err = checkIndexLengthWithNewCharset(tblInfo, toCharset, toCollate); err != nil {
3967+
return doNothing, err
3968+
}
3969+
39653970
for _, col := range tblInfo.Columns {
39663971
if col.GetType() == mysql.TypeVarchar {
39673972
if err = types.IsVarcharTooBigFieldLength(col.GetFlen(), col.Name.O, toCharset); err != nil {
@@ -3985,6 +3990,30 @@ func checkAlterTableCharset(tblInfo *model.TableInfo, dbInfo *model.DBInfo, toCh
39853990
return doNothing, nil
39863991
}
39873992

3993+
func checkIndexLengthWithNewCharset(tblInfo *model.TableInfo, toCharset, toCollate string) error {
3994+
// Copy all columns and replace the charset and collate.
3995+
columns := make([]*model.ColumnInfo, 0, len(tblInfo.Columns))
3996+
for _, col := range tblInfo.Columns {
3997+
newCol := col.Clone()
3998+
if parser_types.HasCharset(&newCol.FieldType) {
3999+
newCol.SetCharset(toCharset)
4000+
newCol.SetCollate(toCollate)
4001+
} else {
4002+
newCol.SetCharset(charset.CharsetBin)
4003+
newCol.SetCollate(charset.CharsetBin)
4004+
}
4005+
columns = append(columns, newCol)
4006+
}
4007+
4008+
for _, indexInfo := range tblInfo.Indices {
4009+
err := checkIndexPrefixLength(columns, indexInfo.Columns)
4010+
if err != nil {
4011+
return err
4012+
}
4013+
}
4014+
return nil
4015+
}
4016+
39884017
// RenameIndex renames an index.
39894018
// In TiDB, indexes are case-insensitive (so index 'a' and 'A" are considered the same index),
39904019
// but index names are case-sensitive (we can rename index 'a' to 'A')

pkg/ddl/index_merge_tmp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ func (w *mergeIndexWorker) fetchTempIndexVals(
350350

351351
// Extract the operations on the original index and replay them later.
352352
for _, elem := range tempIdxVal {
353-
if elem.KeyVer == tables.TempIndexKeyTypeMerge || elem.KeyVer == tables.TempIndexKeyTypeDelete {
353+
if elem.KeyVer == tablecodec.TempIndexKeyTypeMerge || elem.KeyVer == tablecodec.TempIndexKeyTypeDelete {
354354
// For 'm' version kvs, they are double-written.
355355
// For 'd' version kvs, they are written in the delete-only state and can be dropped safely.
356356
continue

pkg/ddl/ingest/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ go_test(
7272
embed = [":ingest"],
7373
flaky = True,
7474
race = "on",
75-
shard_count = 21,
75+
shard_count = 22,
7676
deps = [
7777
"//pkg/config",
7878
"//pkg/ddl/ingest/testutil",

0 commit comments

Comments
 (0)