Skip to content

Commit

Permalink
diff: add config MaxIndexLength for tidb (#400)
Browse files Browse the repository at this point in the history
  • Loading branch information
WangXiangUSTC authored Nov 6, 2020
1 parent e47e0e1 commit 399be9f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions sync_diff_inspector/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/pingcap/tidb-tools/pkg/filter"
router "github.com/pingcap/tidb-tools/pkg/table-router"
"github.com/pingcap/tidb-tools/pkg/utils"
tidbconfig "github.com/pingcap/tidb/config"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -85,6 +86,8 @@ func NewDiff(ctx context.Context, cfg *Config) (diff *Diff, err error) {
}

func (df *Diff) init(cfg *Config) (err error) {
setTiDBCfg()

if len(cfg.DMAddr) != 0 {
subTaskCfgs, err := getDMTaskCfg(cfg.DMAddr, cfg.DMTask)
if err != nil {
Expand Down Expand Up @@ -611,3 +614,13 @@ func (df *Diff) InExcludeTables(exclude_tables []string, table string) bool {
}
return false
}

func setTiDBCfg() {
// to support long index key in TiDB
tidbCfg := tidbconfig.GetGlobalConfig()
// 3027 * 4 is the max value the MaxIndexLength can be set
tidbCfg.MaxIndexLength = 3027 * 4
tidbconfig.StoreGlobalConfig(tidbCfg)

fmt.Println("set tidb cfg")
}

0 comments on commit 399be9f

Please sign in to comment.