pt-table-checksum生成資料無法commit
環境:
mysql 5.7 關閉autocommit
perl-DBI-1.627-4.el7.x86_64
perl-DBD-MySQL-4.023-5.0.1.el7.x86_64
percona-toolkit-3.0.10-1.el7.x86_64
pt-table-checksum --nocheck-replication-filters --no-check-binlog-format --replicate=percona.checksums --recursion-method=processlist --databases=test h=192.168.135.135,u=percona,p=Percona.0101,P=13306
Checking if all tables can be checksummed ...
Starting checksum ...
Waiting to check replicas for differences: 0% 00:00 remain
Waiting to check replicas for differences: 0% 00:00 remain
Waiting to check replicas for differences: 0% 00:00 remain
Waiting to check replicas for differences: 0% 00:00 remain
Waiting to check replicas for differences: 0% 00:00 remain
Waiting to check replicas for differences: 0% 00:00 remain
Waiting to check replicas for differences: 0% 00:00 remain
Waiting to check replicas for differences: 0% 00:00 remain
Waiting to check replicas for differences: 0% 00:00 remain
Waiting to check replicas for differences: 0% 00:00 remain
Waiting to check replicas for differences: 0% 00:00 remain
Waiting to check replicas for differences: 0% 00:00 remain
Waiting to check replicas for differences: 0% 00:00 remain
Waiting to check replicas for differences: 0% 00:00 remain
Waiting to check replicas for differences: 0% 00:00 remain
Waiting to check replicas for differences: 0% 00:00 remain
Waiting to check replicas for differences: 0% 00:00 remain
Waiting to check replicas for differences: 0% 00:00 remain
Waiting to check replicas for differences: 0% 00:00 remain
Waiting to check replicas for differences: 0% 00:00 remain
Waiting to check replicas for differences: 0% 00:00 remain
Waiting to check replicas for differences: 0% 00:00 remain
Waiting to check replicas for differences: 0% 00:00 remain
執行pt-table-checksum資訊,一直沒有停止,一直等待。
[[email protected] 13:37:38]>show tables ;
+---------------------------+
| Tables_in_percona |
+---------------------------+
| checksums |
+---------------------------+
1 row in set (0.00 sec)
[[email protected] 13:37:40]>select * from checksums ;
Empty set (0.00 sec)
查詢percona.checksums表,為空的。
處理方法1:
1、開啟資料庫的autocommit=1
pt-table-checksum --nocheck-replication-filters --no-check-binlog-format --replicate=percona.checksums --recursion-method=processlist --databases=test h=192.168.136.135,u=percona,p=Percona.0101,P=13306
Checking if all tables can be checksummed ...
Starting checksum ...
TS ERRORS DIFFS ROWS DIFF_ROWS CHUNKS SKIPPED TIME TABLE
08-01T13:33:57 0 0 0 0 1 0 0.227 test.m
08-01T13:33:57 0 0 4 0 1 0 0.098 test.t
處理方法2:
1、修改pt-table-checksum指令碼
修改第一個地方:
$update_sth->execute(
# UPDATE repl_table SET
sprintf('%.6f', $tbl->{nibble_time}), # chunk_time
$crc, # master_crc
$cnt, # master_cnt
# WHERE
$tbl->{db},
$tbl->{tbl},
$chunk,
);
在以上程式碼後面新增
$master_dbh->do("commit");
修改第二個地方:
$sth->{nibble}->execute(
# REPLACE INTO repl_table SELECT
$tbl->{db}, # db
$tbl->{tbl}, # tbl
$chunk, # chunk (number)
$chunk_index, # chunk_index
$lb_quoted, # lower_boundary
$ub_quoted, # upper_boundary
# this_cnt, this_crc WHERE
@{$boundary->{lower}}, # upper boundary values
@{$boundary->{upper}}, # lower boundary values
);
在程式碼這後新增:
$dbh->do("commit");
修改之後,關閉autocommit ,並清空percona.checksums 。
pt-table-checksum --nocheck-replication-filters --no-check-binlog-format --replicate=percona.checksums --recursion-method=processlist --databases=test h=192.168.136.135,u=percona,p=Percona.0101,P=13306
Checking if all tables can be checksummed ...
Starting checksum ...
TS ERRORS DIFFS ROWS DIFF_ROWS CHUNKS SKIPPED TIME TABLE
08-01T13:33:57 0 0 0 0 1 0 0.227 test.m
08-01T13:33:57 0 0 4 0 1 0 0.098 test.t
可以正常使用。