Merge lp:~percona-toolkit-dev/percona-toolkit/ptc-privs-bug-916168 into lp:percona-toolkit/2.1

Proposed by Daniel Nichter on 2012-07-21
Status: Merged
Merged at revision: 321
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/ptc-privs-bug-916168
Merge into: lp:percona-toolkit/2.1
Diff against target: 93 lines (+49/-11)
3 files modified
bin/pt-table-checksum (+2/-9)
t/pt-table-checksum/privs.t (+26/-2)
t/pt-table-checksum/samples/privs-bug-916168.sql (+21/-0)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/ptc-privs-bug-916168
Reviewer Review Type Date Requested Status
Daniel Nichter Approve on 2012-07-21
Review via email: mp+116123@code.launchpad.net
To post a comment you must log in.
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/pt-table-checksum'
2--- bin/pt-table-checksum 2012-07-20 20:25:10 +0000
3+++ bin/pt-table-checksum 2012-07-21 16:31:22 +0000
4@@ -8177,15 +8177,8 @@
5 }
6 else {
7 PTDEBUG && _d('--replicate table', $repl_table, 'already exists');
8- # Check it again but this time check the privs.
9- my $have_tbl_privs = $tp->check_table(
10- dbh => $dbh,
11- db => $db,
12- tbl => $tbl,
13- all_privs => 1,
14- );
15- die "User does not have all privileges on --replicate table "
16- . "$repl_table.\n" unless $have_tbl_privs;
17+ # We used to check the table privs here, but:
18+ # https://bugs.launchpad.net/percona-toolkit/+bug/916168
19 }
20
21 # Check and wait for the repl table to appear on all slaves.
22
23=== modified file 't/pt-table-checksum/privs.t'
24--- t/pt-table-checksum/privs.t 2012-06-09 18:43:33 +0000
25+++ t/pt-table-checksum/privs.t 2012-07-21 16:31:22 +0000
26@@ -42,7 +42,7 @@
27 plan skip_all => 'sakila database is not loaded';
28 }
29 else {
30- plan tests => 3;
31+ plan tests => 4;
32 }
33
34 # The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
35@@ -94,7 +94,31 @@
36 wait_until(
37 sub {
38 my $rows=$slave2_dbh->selectall_arrayref("SELECT user FROM mysql.user");
39- return !grep { ($_->[0] || '') ne 'ro_checksum_user' } @$rows;
40+ return !grep { ($_->[0] || '') eq 'ro_checksum_user' } @$rows;
41+ }
42+);
43+
44+# #############################################################################
45+# Bug 916168: bug in pt-table-checksum privileges check
46+# #############################################################################
47+`/tmp/12345/use -u root < $trunk/t/pt-table-checksum/samples/privs-bug-916168.sql`;
48+
49+$output = output(
50+ sub { $exit_status = pt_table_checksum::main(@args,
51+ "$master_dsn,u=test_user,p=foo", qw(-t sakila.country)) },
52+);
53+
54+is(
55+ PerconaTest::count_checksum_results($output, 'rows'),
56+ 109,
57+ "test_user privs work (bug 916168)"
58+);
59+
60+diag(`/tmp/12345/use -u root -e "drop user 'test_user'\@'%'"`);
61+wait_until(
62+ sub {
63+ my $rows=$slave2_dbh->selectall_arrayref("SELECT user FROM mysql.user");
64+ return !grep { ($_->[0] || '') eq 'test_user' } @$rows;
65 }
66 );
67
68
69=== added file 't/pt-table-checksum/samples/privs-bug-916168.sql'
70--- t/pt-table-checksum/samples/privs-bug-916168.sql 1970-01-01 00:00:00 +0000
71+++ t/pt-table-checksum/samples/privs-bug-916168.sql 2012-07-21 16:31:22 +0000
72@@ -0,0 +1,21 @@
73+grant select, replication slave, replication client, super, process on *.* to 'test_user'@'%' identified by 'foo';
74+grant all on percona.* to 'test_user'@'%';
75+create database if not exists percona;
76+use percona;
77+drop table if exists checksums;
78+CREATE TABLE `checksums` (
79+ `db` char(64) NOT NULL,
80+ `tbl` char(64) NOT NULL,
81+ `chunk` int(11) NOT NULL,
82+ `chunk_time` float DEFAULT NULL,
83+ `chunk_index` varchar(200) DEFAULT NULL,
84+ `lower_boundary` text,
85+ `upper_boundary` text,
86+ `this_crc` char(40) NOT NULL,
87+ `this_cnt` int(11) NOT NULL,
88+ `master_crc` char(40) DEFAULT NULL,
89+ `master_cnt` int(11) DEFAULT NULL,
90+ `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
91+ PRIMARY KEY (`db`,`tbl`,`chunk`),
92+ KEY `ts_db_tbl` (`ts`,`db`,`tbl`)
93+) ENGINE=InnoDB;

Subscribers

People subscribed via source and target branches