pingcap/tidb-tools

sync diff cannot handle the table with int type primary key when clustered index is disabled

jackysp opened this issue · 2 comments

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
    If possible, provide a recipe for reproducing the error.
set tidb_enable_clustered_index = off;
create table t (i int auto_increment primary key) shard_row_id_bits=2;

./bin/sync_diff_inspector -config=config.toml

[data-sources]
[data-sources.mysql1]
    host = "120.92.92.145"
    port = 4000
    user = "root"
    password = ""

[data-sources.tidb0]
    host = "120.92.92.145"
    port = 4000
    user = "root"
    password = ""

[task]
    output-dir = "./output"
  1. What did you expect to see?
    no error

  2. What did you see instead?

github.com/pingcap/errors.AddStack
    /Users/yusp/go/pkg/mod/github.com/pingcap/errors@v0.11.5-0.20211224045212-9687c2b0f87c/errors.go:174
github.com/pingcap/errors.Trace
    /Users/yusp/go/pkg/mod/github.com/pingcap/errors@v0.11.5-0.20211224045212-9687c2b0f87c/juju_adaptor.go:15
github.com/pingcap/tidb/ddl.BuildTableInfoWithStmt
    /Users/yusp/go/pkg/mod/github.com/pingcap/tidb@v1.1.0-beta.0.20220918132100-29f83a0b2592/ddl/ddl_api.go:2228
github.com/pingcap/tidb/ddl.buildTableInfoWithCheck
    /Users/yusp/go/pkg/mod/github.com/pingcap/tidb@v1.1.0-beta.0.20220918132100-29f83a0b2592/ddl/ddl_api.go:2149
github.com/pingcap/tidb/ddl.BuildTableInfoFromAST
    /Users/yusp/go/pkg/mod/github.com/pingcap/tidb@v1.1.0-beta.0.20220918132100-29f83a0b2592/ddl/ddl_api.go:2143
github.com/pingcap/tidb-tools/pkg/dbutil.GetTableInfoBySQL
    /Users/yusp/work/tidb-tools/pkg/dbutil/table.go:59
github.com/pingcap/tidb-tools/pkg/dbutil.GetTableInfo
    /Users/yusp/work/tidb-tools/pkg/dbutil/table.go:47
github.com/pingcap/tidb-tools/sync_diff_inspector/source.initTables
    /Users/yusp/work/tidb-tools/sync_diff_inspector/source/source.go:323
github.com/pingcap/tidb-tools/sync_diff_inspector/source.NewSources
    /Users/yusp/work/tidb-tools/sync_diff_inspector/source/source.go:117
main.(*Diff).init
    /Users/yusp/work/tidb-tools/sync_diff_inspector/diff.go:139
main.NewDiff
    /Users/yusp/work/tidb-tools/sync_diff_inspector/diff.go:97
main.checkSyncState
    /Users/yusp/work/tidb-tools/sync_diff_inspector/main.go:117
main.main
    /Users/yusp/work/tidb-tools/sync_diff_inspector/main.go:104
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
    v4.0.12

  2. which tool are you using?

  3. what version of tool are you using (pump -V or tidb-lightning -V or syncer -V)?
    v4.0.12, v6.1.0

It works for v5.0 above, because it support clustered index and add a flag to the table schema.

v5.0

CREATE TABLE `t` (
  `i` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`i`) /*T![clustered_index] NONCLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T! SHARD_ROW_ID_BITS=2 */

v4.0

CREATE TABLE `t` (
  `i` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`i`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin/*!90000 SHARD_ROW_ID_BITS=2 */

need to modify
image
to make sync-diff know its a non-clustered table