Merge lp:~percona-toolkit-dev/percona-toolkit/test-ptc-pk-bug-978432-2.0 into lp:percona-toolkit/2.0

Proposed by Daniel Nichter
Status: Merged
Merged at revision: 226
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/test-ptc-pk-bug-978432-2.0
Merge into: lp:percona-toolkit/2.0
Diff against target: 85 lines (+57/-1)
3 files modified
t/pt-table-checksum/chunk_index.t (+17/-1)
t/pt-table-checksum/samples/not-using-pk-bug.out (+20/-0)
t/pt-table-checksum/samples/not-using-pk-bug.sql (+20/-0)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/test-ptc-pk-bug-978432-2.0
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+105141@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Daniel Nichter (daniel-nichter) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 't/pt-table-checksum/chunk_index.t'
2--- t/pt-table-checksum/chunk_index.t 2012-02-03 18:38:20 +0000
3+++ t/pt-table-checksum/chunk_index.t 2012-05-08 22:36:20 +0000
4@@ -25,7 +25,7 @@
5 plan skip_all => 'Cannot connect to sandbox master';
6 }
7 else {
8- plan tests => 10;
9+ plan tests => 11;
10 }
11
12 # The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
13@@ -142,6 +142,22 @@
14 );
15
16 # #############################################################################
17+# Bug 978432: PK is ignored
18+# #############################################################################
19+$sb->load_file('master', "t/pt-table-checksum/samples/not-using-pk-bug.sql");
20+PerconaTest::wait_for_table($dbh, "test.multi_resource_apt", "apt_id=4 AND res_id=4");
21+warn "xxx";
22+ok(
23+ no_diff(
24+ sub { pt_table_checksum::main(@args,
25+ qw(-t test.multi_resource_apt --chunk-size 2 --explain --explain))
26+ },
27+ "t/pt-table-checksum/samples/not-using-pk-bug.out",
28+ ),
29+ "Smarter chunk index selection (bug 978432)"
30+);
31+
32+# #############################################################################
33 # Done.
34 # #############################################################################
35 $sb->wipe_clean($dbh);
36
37=== added file 't/pt-table-checksum/samples/not-using-pk-bug.out'
38--- t/pt-table-checksum/samples/not-using-pk-bug.out 1970-01-01 00:00:00 +0000
39+++ t/pt-table-checksum/samples/not-using-pk-bug.out 2012-05-08 22:36:20 +0000
40@@ -0,0 +1,20 @@
41+--
42+-- test.multi_resource_apt
43+--
44+
45+REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*) AS cnt, COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `apt_id`, `res_id`)) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `test`.`multi_resource_apt` FORCE INDEX(`PRIMARY`) WHERE ((`apt_id` > ?) OR (`apt_id` = ? AND `res_id` >= ?)) AND ((`apt_id` < ?) OR (`apt_id` = ? AND `res_id` <= ?)) /*checksum chunk*/
46+
47+REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*), '0' FROM `test`.`multi_resource_apt` FORCE INDEX(`PRIMARY`) WHERE ((`apt_id` < ?) OR (`apt_id` = ? AND `res_id` < ?)) ORDER BY `apt_id`, `res_id` /*past lower chunk*/
48+
49+REPLACE INTO `percona`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT ?, ?, ?, ?, ?, ?, COUNT(*), '0' FROM `test`.`multi_resource_apt` FORCE INDEX(`PRIMARY`) WHERE ((`apt_id` > ?) OR (`apt_id` = ? AND `res_id` > ?)) ORDER BY `apt_id`, `res_id` /*past upper chunk*/
50+
51+SELECT /*!40001 SQL_NO_CACHE */ `apt_id`, `apt_id`, `res_id` FROM `test`.`multi_resource_apt` FORCE INDEX(`PRIMARY`) WHERE ((`apt_id` > ?) OR (`apt_id` = ? AND `res_id` >= ?)) ORDER BY `apt_id`, `res_id` LIMIT ?, 2 /*next chunk boundary*/
52+
53+1 1,1,1 2,2,1
54+2 2,2,2 3,3,1
55+3 3,3,2 3,3,3
56+4 4,4,1 4,4,2
57+5 4,4,3 4,4,4
58+6 1,1,1
59+7 4,4,4
60+
61
62=== added file 't/pt-table-checksum/samples/not-using-pk-bug.sql'
63--- t/pt-table-checksum/samples/not-using-pk-bug.sql 1970-01-01 00:00:00 +0000
64+++ t/pt-table-checksum/samples/not-using-pk-bug.sql 2012-05-08 22:36:20 +0000
65@@ -0,0 +1,20 @@
66+DROP DATABASE IF EXISTS test;
67+CREATE DATABASE test;
68+USE test;
69+CREATE TABLE `multi_resource_apt` (
70+ `apt_id` int(10) unsigned NOT NULL DEFAULT '0',
71+ `res_id` int(10) unsigned NOT NULL DEFAULT '0',
72+ PRIMARY KEY (`apt_id`,`res_id`),
73+ KEY `resid` (`res_id`)
74+) ENGINE=InnoDB;
75+INSERT INTO multi_resource_apt VALUES
76+ (1, 1),
77+ (2, 1),
78+ (2, 2),
79+ (3, 1),
80+ (3, 2),
81+ (3, 3),
82+ (4, 1),
83+ (4, 2),
84+ (4, 3),
85+ (4, 4);

Subscribers

People subscribed via source and target branches