I have verified that the error was due to case sensitive comparison on the index name. When specify --chunk-index with index name that is of the same case as defined in the database, the tool does use it. Same behavior in 2.2.5 and latest 2.2.11. Since index name is not case sensitive on any platform, I think pt-table-checksum should use case-insensitive comparison to check index name.
Below is the detail of the test:
-------------------------------------------------
create table ptc_i_test
(col1 int,
col2 varchar(10),
col3 int,
key metric42294eae0e93c043fb083b1049e4fcbed9d7_idx (col1),
key metric8a56a17b007640471f0856e099e06401589f_idx (col3),
key metric8f60732102034046720ab81022c12e7c6cbf_idx (col2)
) engine = innodb;
# NibbleIterator:6444 28172 User wants to use index metric8f60732102034046720ab81022c12e7c6cbf_idx
# NibbleIterator:6464 28172 Wanted index is a possible index
# NibbleIterator:6482 28172 No PRIMARY or unique indexes; will use index with highest cardinality
# NibbleIterator:6513 28172 SHOW INDEXES FROM `test`.`ptc_i_test` WHERE Key_name = 'metric8f60732102034046720ab81022c12e7c6cbf_idx'
# NibbleIterator:6523 28172 Index metric8f60732102034046720ab81022c12e7c6cbf_idx cardinality: 4
# NibbleIterator:6502 28172 Best index: metric8f60732102034046720ab81022c12e7c6cbf_idx
I have verified that the error was due to case sensitive comparison on the index name. When specify --chunk-index with index name that is of the same case as defined in the database, the tool does use it. Same behavior in 2.2.5 and latest 2.2.11. Since index name is not case sensitive on any platform, I think pt-table-checksum should use case-insensitive comparison to check index name.
Below is the detail of the test: ------- ------- ------- ------- ------- ------- e93c043fb083b10 49e4fcbed9d7_ idx (col1), 07640471f0856e0 99e06401589f_ idx (col3), 2034046720ab810 22c12e7c6cbf_ idx (col2)
-------
create table ptc_i_test
(col1 int,
col2 varchar(10),
col3 int,
key metric42294eae0
key metric8a56a17b0
key metric8f6073210
) engine = innodb;
PTDEBUG=1 ./pt-table-checksum --no-check- binlog- format --chunk-index metric8f6073210 2034046720ab810 22c12e7c6cbf_ idx --tables test.ptc_i_test --recursion-method dsn=D=percona, t=dsns h=127.0. 0.1,P=13000, u=msandbox, p=msandbox >ptc.out 2>ptc.err
# NibbleIterator:6444 28172 User wants to use index metric8f6073210 2034046720ab810 22c12e7c6cbf_ idx 02034046720ab81 022c12e7c6cbf_ idx' 2034046720ab810 22c12e7c6cbf_ idx cardinality: 4 2034046720ab810 22c12e7c6cbf_ idx
# NibbleIterator:6464 28172 Wanted index is a possible index
# NibbleIterator:6482 28172 No PRIMARY or unique indexes; will use index with highest cardinality
# NibbleIterator:6513 28172 SHOW INDEXES FROM `test`.`ptc_i_test` WHERE Key_name = 'metric8f607321
# NibbleIterator:6523 28172 Index metric8f6073210
# NibbleIterator:6502 28172 Best index: metric8f6073210