Merge lp:~percona-toolkit-dev/percona-toolkit/pt-table-checksum-compatibility-with-pxc-1399789 into lp:~percona-toolkit-dev/percona-toolkit/release-2.2.13
- pt-table-checksum-compatibility-with-pxc-1399789
- Merge into release-2.2.13
Status: | Merged |
---|---|
Approved by: | Daniel Nichter |
Approved revision: | 612 |
Merged at revision: | 618 |
Proposed branch: | lp:~percona-toolkit-dev/percona-toolkit/pt-table-checksum-compatibility-with-pxc-1399789 |
Merge into: | lp:~percona-toolkit-dev/percona-toolkit/release-2.2.13 |
Diff against target: |
605 lines (+302/-56) 11 files modified
bin/pt-config-diff (+29/-4) bin/pt-deadlock-logger (+29/-4) bin/pt-fk-error-logger (+29/-4) bin/pt-kill (+29/-4) bin/pt-online-schema-change (+30/-8) bin/pt-table-checksum (+32/-12) bin/pt-upgrade (+29/-4) lib/Cxn.pm (+32/-7) lib/Percona/XtraDB/Cluster.pm (+1/-7) sandbox/servers/pxc/5.6/my.sandbox.cnf (+42/-0) t/pt-table-checksum/pxc.t (+20/-2) |
To merge this branch: | bzr merge lp:~percona-toolkit-dev/percona-toolkit/pt-table-checksum-compatibility-with-pxc-1399789 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel Nichter | Needs Information | ||
Review via email: mp+245236@code.launchpad.net |
Commit message
Description of the change
Problem:
pt-table-checksum needed unique id for clusters to be able to discard dupes. server_id was unreliable since clusters often use the same id. wsrep_incoming_
Solution:
Use a concatenation of various variables,
wsrep_local_index , server_id , wsrep_sst_
Also added get_id function to Cxn module to keep id generation in one place.
Frank Cizmich (frank-cizmich) wrote : | # |
Daniel Nichter (daniel-nichter) wrote : | # |
Changes in this MP include another MP, e.g. use Term::ReadKey and the ask_pass in Cxn.
Daniel Nichter (daniel-nichter) wrote : | # |
Does this create some kind of backwards-
- 612. By Frank Cizmich
-
unique-id function for cluster nodes. added pxc5.6 config. modified pxc test
Frank Cizmich (frank-cizmich) wrote : | # |
> Changes in this MP include another MP, e.g. use Term::ReadKey and the ask_pass
> in Cxn.
Fixed
Frank Cizmich (frank-cizmich) wrote : | # |
> Does this create some kind of backwards-
> wsrep_incoming_
> from 2.2.9, for example, to 2.2.13 everything will work normally, no problems?
Actually all it does is instead of relying on wsrep_node_
It should not affect other tools or upgrades because the id function is used internally.
The concept of a unique id value for nodes was discussed with raghu, and no single value was considered "unique enough"
Preview Diff
1 | === modified file 'bin/pt-config-diff' |
2 | --- bin/pt-config-diff 2014-11-11 13:28:27 +0000 |
3 | +++ bin/pt-config-diff 2015-01-14 20:09:38 +0000 |
4 | @@ -2393,9 +2393,37 @@ |
5 | return $self->{hostname} || $self->{dsn_name} || 'unknown host'; |
6 | } |
7 | |
8 | +sub get_id { |
9 | + my ($self, $cxn) = @_; |
10 | + |
11 | + $cxn ||= $self; |
12 | + |
13 | + my $unique_id; |
14 | + if ($cxn->is_cluster_node()) { # for cluster we concatenate various variables to maximize id 'uniqueness' across versions |
15 | + my $sql = q{SHOW STATUS LIKE 'wsrep\_local\_index'}; |
16 | + my (undef, $wsrep_local_index) = $cxn->dbh->selectrow_array($sql); |
17 | + PTDEBUG && _d("Got cluster wsrep_local_index: ",$wsrep_local_index); |
18 | + $unique_id = $wsrep_local_index."|"; |
19 | + foreach my $val ('server\_id', 'wsrep\_sst\_receive\_address', 'wsrep\_node\_name', 'wsrep\_node\_address') { |
20 | + my $sql = "SHOW VARIABLES LIKE '$val'"; |
21 | + PTDEBUG && _d($cxn->name, $sql); |
22 | + my (undef, $val) = $cxn->dbh->selectrow_array($sql); |
23 | + $unique_id .= "|$val"; |
24 | + } |
25 | + } else { |
26 | + my $sql = 'SELECT @@SERVER_ID'; |
27 | + PTDEBUG && _d($sql); |
28 | + $unique_id = $cxn->dbh->selectrow_array($sql); |
29 | + } |
30 | + PTDEBUG && _d("Generated unique id for cluster:", $unique_id); |
31 | + return $unique_id; |
32 | +} |
33 | + |
34 | + |
35 | sub is_cluster_node { |
36 | my ($self, $cxn) = @_; |
37 | |
38 | + $cxn ||= $self; |
39 | my $sql = "SHOW VARIABLES LIKE 'wsrep\_on'"; |
40 | PTDEBUG && _d($cxn->name, $sql); |
41 | my $row = $cxn->dbh->selectrow_arrayref($sql); |
42 | @@ -2412,11 +2440,8 @@ |
43 | my @trimmed_cxns; |
44 | |
45 | for my $cxn ( @cxns ) { |
46 | - my $dbh = $cxn->dbh(); |
47 | |
48 | - my $sql = $self->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id}; |
49 | - PTDEBUG && _d($sql); |
50 | - my ($id) = $dbh->selectrow_array($sql); |
51 | + my $id = $cxn->get_id(); |
52 | PTDEBUG && _d('Server ID for ', $cxn->name, ': ', $id); |
53 | |
54 | if ( ! $seen_ids->{$id}++ ) { |
55 | |
56 | === modified file 'bin/pt-deadlock-logger' |
57 | --- bin/pt-deadlock-logger 2014-11-11 13:28:27 +0000 |
58 | +++ bin/pt-deadlock-logger 2015-01-14 20:09:38 +0000 |
59 | @@ -2737,9 +2737,37 @@ |
60 | return $self->{hostname} || $self->{dsn_name} || 'unknown host'; |
61 | } |
62 | |
63 | +sub get_id { |
64 | + my ($self, $cxn) = @_; |
65 | + |
66 | + $cxn ||= $self; |
67 | + |
68 | + my $unique_id; |
69 | + if ($cxn->is_cluster_node()) { # for cluster we concatenate various variables to maximize id 'uniqueness' across versions |
70 | + my $sql = q{SHOW STATUS LIKE 'wsrep\_local\_index'}; |
71 | + my (undef, $wsrep_local_index) = $cxn->dbh->selectrow_array($sql); |
72 | + PTDEBUG && _d("Got cluster wsrep_local_index: ",$wsrep_local_index); |
73 | + $unique_id = $wsrep_local_index."|"; |
74 | + foreach my $val ('server\_id', 'wsrep\_sst\_receive\_address', 'wsrep\_node\_name', 'wsrep\_node\_address') { |
75 | + my $sql = "SHOW VARIABLES LIKE '$val'"; |
76 | + PTDEBUG && _d($cxn->name, $sql); |
77 | + my (undef, $val) = $cxn->dbh->selectrow_array($sql); |
78 | + $unique_id .= "|$val"; |
79 | + } |
80 | + } else { |
81 | + my $sql = 'SELECT @@SERVER_ID'; |
82 | + PTDEBUG && _d($sql); |
83 | + $unique_id = $cxn->dbh->selectrow_array($sql); |
84 | + } |
85 | + PTDEBUG && _d("Generated unique id for cluster:", $unique_id); |
86 | + return $unique_id; |
87 | +} |
88 | + |
89 | + |
90 | sub is_cluster_node { |
91 | my ($self, $cxn) = @_; |
92 | |
93 | + $cxn ||= $self; |
94 | my $sql = "SHOW VARIABLES LIKE 'wsrep\_on'"; |
95 | PTDEBUG && _d($cxn->name, $sql); |
96 | my $row = $cxn->dbh->selectrow_arrayref($sql); |
97 | @@ -2756,11 +2784,8 @@ |
98 | my @trimmed_cxns; |
99 | |
100 | for my $cxn ( @cxns ) { |
101 | - my $dbh = $cxn->dbh(); |
102 | |
103 | - my $sql = $self->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id}; |
104 | - PTDEBUG && _d($sql); |
105 | - my ($id) = $dbh->selectrow_array($sql); |
106 | + my $id = $cxn->get_id(); |
107 | PTDEBUG && _d('Server ID for ', $cxn->name, ': ', $id); |
108 | |
109 | if ( ! $seen_ids->{$id}++ ) { |
110 | |
111 | === modified file 'bin/pt-fk-error-logger' |
112 | --- bin/pt-fk-error-logger 2014-11-11 13:28:27 +0000 |
113 | +++ bin/pt-fk-error-logger 2015-01-14 20:09:38 +0000 |
114 | @@ -1889,9 +1889,37 @@ |
115 | return $self->{hostname} || $self->{dsn_name} || 'unknown host'; |
116 | } |
117 | |
118 | +sub get_id { |
119 | + my ($self, $cxn) = @_; |
120 | + |
121 | + $cxn ||= $self; |
122 | + |
123 | + my $unique_id; |
124 | + if ($cxn->is_cluster_node()) { # for cluster we concatenate various variables to maximize id 'uniqueness' across versions |
125 | + my $sql = q{SHOW STATUS LIKE 'wsrep\_local\_index'}; |
126 | + my (undef, $wsrep_local_index) = $cxn->dbh->selectrow_array($sql); |
127 | + PTDEBUG && _d("Got cluster wsrep_local_index: ",$wsrep_local_index); |
128 | + $unique_id = $wsrep_local_index."|"; |
129 | + foreach my $val ('server\_id', 'wsrep\_sst\_receive\_address', 'wsrep\_node\_name', 'wsrep\_node\_address') { |
130 | + my $sql = "SHOW VARIABLES LIKE '$val'"; |
131 | + PTDEBUG && _d($cxn->name, $sql); |
132 | + my (undef, $val) = $cxn->dbh->selectrow_array($sql); |
133 | + $unique_id .= "|$val"; |
134 | + } |
135 | + } else { |
136 | + my $sql = 'SELECT @@SERVER_ID'; |
137 | + PTDEBUG && _d($sql); |
138 | + $unique_id = $cxn->dbh->selectrow_array($sql); |
139 | + } |
140 | + PTDEBUG && _d("Generated unique id for cluster:", $unique_id); |
141 | + return $unique_id; |
142 | +} |
143 | + |
144 | + |
145 | sub is_cluster_node { |
146 | my ($self, $cxn) = @_; |
147 | |
148 | + $cxn ||= $self; |
149 | my $sql = "SHOW VARIABLES LIKE 'wsrep\_on'"; |
150 | PTDEBUG && _d($cxn->name, $sql); |
151 | my $row = $cxn->dbh->selectrow_arrayref($sql); |
152 | @@ -1908,11 +1936,8 @@ |
153 | my @trimmed_cxns; |
154 | |
155 | for my $cxn ( @cxns ) { |
156 | - my $dbh = $cxn->dbh(); |
157 | |
158 | - my $sql = $self->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id}; |
159 | - PTDEBUG && _d($sql); |
160 | - my ($id) = $dbh->selectrow_array($sql); |
161 | + my $id = $cxn->get_id(); |
162 | PTDEBUG && _d('Server ID for ', $cxn->name, ': ', $id); |
163 | |
164 | if ( ! $seen_ids->{$id}++ ) { |
165 | |
166 | === modified file 'bin/pt-kill' |
167 | --- bin/pt-kill 2014-11-11 13:28:27 +0000 |
168 | +++ bin/pt-kill 2015-01-14 20:09:38 +0000 |
169 | @@ -5256,9 +5256,37 @@ |
170 | return $self->{hostname} || $self->{dsn_name} || 'unknown host'; |
171 | } |
172 | |
173 | +sub get_id { |
174 | + my ($self, $cxn) = @_; |
175 | + |
176 | + $cxn ||= $self; |
177 | + |
178 | + my $unique_id; |
179 | + if ($cxn->is_cluster_node()) { # for cluster we concatenate various variables to maximize id 'uniqueness' across versions |
180 | + my $sql = q{SHOW STATUS LIKE 'wsrep\_local\_index'}; |
181 | + my (undef, $wsrep_local_index) = $cxn->dbh->selectrow_array($sql); |
182 | + PTDEBUG && _d("Got cluster wsrep_local_index: ",$wsrep_local_index); |
183 | + $unique_id = $wsrep_local_index."|"; |
184 | + foreach my $val ('server\_id', 'wsrep\_sst\_receive\_address', 'wsrep\_node\_name', 'wsrep\_node\_address') { |
185 | + my $sql = "SHOW VARIABLES LIKE '$val'"; |
186 | + PTDEBUG && _d($cxn->name, $sql); |
187 | + my (undef, $val) = $cxn->dbh->selectrow_array($sql); |
188 | + $unique_id .= "|$val"; |
189 | + } |
190 | + } else { |
191 | + my $sql = 'SELECT @@SERVER_ID'; |
192 | + PTDEBUG && _d($sql); |
193 | + $unique_id = $cxn->dbh->selectrow_array($sql); |
194 | + } |
195 | + PTDEBUG && _d("Generated unique id for cluster:", $unique_id); |
196 | + return $unique_id; |
197 | +} |
198 | + |
199 | + |
200 | sub is_cluster_node { |
201 | my ($self, $cxn) = @_; |
202 | |
203 | + $cxn ||= $self; |
204 | my $sql = "SHOW VARIABLES LIKE 'wsrep\_on'"; |
205 | PTDEBUG && _d($cxn->name, $sql); |
206 | my $row = $cxn->dbh->selectrow_arrayref($sql); |
207 | @@ -5275,11 +5303,8 @@ |
208 | my @trimmed_cxns; |
209 | |
210 | for my $cxn ( @cxns ) { |
211 | - my $dbh = $cxn->dbh(); |
212 | |
213 | - my $sql = $self->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id}; |
214 | - PTDEBUG && _d($sql); |
215 | - my ($id) = $dbh->selectrow_array($sql); |
216 | + my $id = $cxn->get_id(); |
217 | PTDEBUG && _d('Server ID for ', $cxn->name, ': ', $id); |
218 | |
219 | if ( ! $seen_ids->{$id}++ ) { |
220 | |
221 | === modified file 'bin/pt-online-schema-change' |
222 | --- bin/pt-online-schema-change 2014-11-11 13:28:27 +0000 |
223 | +++ bin/pt-online-schema-change 2015-01-14 20:09:38 +0000 |
224 | @@ -3853,9 +3853,37 @@ |
225 | return $self->{hostname} || $self->{dsn_name} || 'unknown host'; |
226 | } |
227 | |
228 | +sub get_id { |
229 | + my ($self, $cxn) = @_; |
230 | + |
231 | + $cxn ||= $self; |
232 | + |
233 | + my $unique_id; |
234 | + if ($cxn->is_cluster_node()) { # for cluster we concatenate various variables to maximize id 'uniqueness' across versions |
235 | + my $sql = q{SHOW STATUS LIKE 'wsrep\_local\_index'}; |
236 | + my (undef, $wsrep_local_index) = $cxn->dbh->selectrow_array($sql); |
237 | + PTDEBUG && _d("Got cluster wsrep_local_index: ",$wsrep_local_index); |
238 | + $unique_id = $wsrep_local_index."|"; |
239 | + foreach my $val ('server\_id', 'wsrep\_sst\_receive\_address', 'wsrep\_node\_name', 'wsrep\_node\_address') { |
240 | + my $sql = "SHOW VARIABLES LIKE '$val'"; |
241 | + PTDEBUG && _d($cxn->name, $sql); |
242 | + my (undef, $val) = $cxn->dbh->selectrow_array($sql); |
243 | + $unique_id .= "|$val"; |
244 | + } |
245 | + } else { |
246 | + my $sql = 'SELECT @@SERVER_ID'; |
247 | + PTDEBUG && _d($sql); |
248 | + $unique_id = $cxn->dbh->selectrow_array($sql); |
249 | + } |
250 | + PTDEBUG && _d("Generated unique id for cluster:", $unique_id); |
251 | + return $unique_id; |
252 | +} |
253 | + |
254 | + |
255 | sub is_cluster_node { |
256 | my ($self, $cxn) = @_; |
257 | |
258 | + $cxn ||= $self; |
259 | my $sql = "SHOW VARIABLES LIKE 'wsrep\_on'"; |
260 | PTDEBUG && _d($cxn->name, $sql); |
261 | my $row = $cxn->dbh->selectrow_arrayref($sql); |
262 | @@ -3872,11 +3900,8 @@ |
263 | my @trimmed_cxns; |
264 | |
265 | for my $cxn ( @cxns ) { |
266 | - my $dbh = $cxn->dbh(); |
267 | |
268 | - my $sql = $self->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id}; |
269 | - PTDEBUG && _d($sql); |
270 | - my ($id) = $dbh->selectrow_array($sql); |
271 | + my $id = $cxn->get_id(); |
272 | PTDEBUG && _d('Server ID for ', $cxn->name, ': ', $id); |
273 | |
274 | if ( ! $seen_ids->{$id}++ ) { |
275 | @@ -7662,10 +7687,7 @@ |
276 | my @trimmed_cxns; |
277 | |
278 | for my $cxn ( @cxns ) { |
279 | - my $dbh = $cxn->dbh(); |
280 | - my $sql = $self->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id}; |
281 | - PTDEBUG && _d($sql); |
282 | - my ($id) = $dbh->selectrow_array($sql); |
283 | + my $id = $cxn->get_id(); |
284 | PTDEBUG && _d('Server ID for ', $cxn->name, ': ', $id); |
285 | |
286 | if ( ! $seen_ids->{$id}++ ) { |
287 | |
288 | === modified file 'bin/pt-table-checksum' |
289 | --- bin/pt-table-checksum 2014-11-11 13:28:27 +0000 |
290 | +++ bin/pt-table-checksum 2015-01-14 20:09:38 +0000 |
291 | @@ -3631,9 +3631,37 @@ |
292 | return $self->{hostname} || $self->{dsn_name} || 'unknown host'; |
293 | } |
294 | |
295 | +sub get_id { |
296 | + my ($self, $cxn) = @_; |
297 | + |
298 | + $cxn ||= $self; |
299 | + |
300 | + my $unique_id; |
301 | + if ($cxn->is_cluster_node()) { # for cluster we concatenate various variables to maximize id 'uniqueness' across versions |
302 | + my $sql = q{SHOW STATUS LIKE 'wsrep\_local\_index'}; |
303 | + my (undef, $wsrep_local_index) = $cxn->dbh->selectrow_array($sql); |
304 | + PTDEBUG && _d("Got cluster wsrep_local_index: ",$wsrep_local_index); |
305 | + $unique_id = $wsrep_local_index."|"; |
306 | + foreach my $val ('server\_id', 'wsrep\_sst\_receive\_address', 'wsrep\_node\_name', 'wsrep\_node\_address') { |
307 | + my $sql = "SHOW VARIABLES LIKE '$val'"; |
308 | + PTDEBUG && _d($cxn->name, $sql); |
309 | + my (undef, $val) = $cxn->dbh->selectrow_array($sql); |
310 | + $unique_id .= "|$val"; |
311 | + } |
312 | + } else { |
313 | + my $sql = 'SELECT @@SERVER_ID'; |
314 | + PTDEBUG && _d($sql); |
315 | + $unique_id = $cxn->dbh->selectrow_array($sql); |
316 | + } |
317 | + PTDEBUG && _d("Generated unique id for cluster:", $unique_id); |
318 | + return $unique_id; |
319 | +} |
320 | + |
321 | + |
322 | sub is_cluster_node { |
323 | my ($self, $cxn) = @_; |
324 | |
325 | + $cxn ||= $self; |
326 | my $sql = "SHOW VARIABLES LIKE 'wsrep\_on'"; |
327 | PTDEBUG && _d($cxn->name, $sql); |
328 | my $row = $cxn->dbh->selectrow_arrayref($sql); |
329 | @@ -3650,11 +3678,8 @@ |
330 | my @trimmed_cxns; |
331 | |
332 | for my $cxn ( @cxns ) { |
333 | - my $dbh = $cxn->dbh(); |
334 | |
335 | - my $sql = $self->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id}; |
336 | - PTDEBUG && _d($sql); |
337 | - my ($id) = $dbh->selectrow_array($sql); |
338 | + my $id = $cxn->get_id(); |
339 | PTDEBUG && _d('Server ID for ', $cxn->name, ': ', $id); |
340 | |
341 | if ( ! $seen_ids->{$id}++ ) { |
342 | @@ -3812,10 +3837,7 @@ |
343 | my @trimmed_cxns; |
344 | |
345 | for my $cxn ( @cxns ) { |
346 | - my $dbh = $cxn->dbh(); |
347 | - my $sql = $self->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id}; |
348 | - PTDEBUG && _d($sql); |
349 | - my ($id) = $dbh->selectrow_array($sql); |
350 | + my $id = $cxn->get_id(); |
351 | PTDEBUG && _d('Server ID for ', $cxn->name, ': ', $id); |
352 | |
353 | if ( ! $seen_ids->{$id}++ ) { |
354 | @@ -9323,10 +9345,8 @@ |
355 | my %seen_ids; |
356 | for my $cxn ($master_cxn, @$slaves) { |
357 | my $dbh = $cxn->dbh(); |
358 | - # if it's a cluster node we use its incoming address as id ( see https://bugs.launchpad.net/percona-toolkit/+bug/1217466 ) |
359 | - my $sql = $cluster->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id}; |
360 | - PTDEBUG && _d($cxn, $dbh, $sql); |
361 | - my ($id) = $dbh->selectrow_array($sql); |
362 | + # get server/node unique id ( https://bugs.launchpad.net/percona-toolkit/+bug/1217466 ) |
363 | + my $id = $cxn->get_id(); |
364 | $seen_ids{$id}++; |
365 | } |
366 | |
367 | |
368 | === modified file 'bin/pt-upgrade' |
369 | --- bin/pt-upgrade 2014-11-11 13:28:27 +0000 |
370 | +++ bin/pt-upgrade 2015-01-14 20:09:38 +0000 |
371 | @@ -2562,9 +2562,37 @@ |
372 | return $self->{hostname} || $self->{dsn_name} || 'unknown host'; |
373 | } |
374 | |
375 | +sub get_id { |
376 | + my ($self, $cxn) = @_; |
377 | + |
378 | + $cxn ||= $self; |
379 | + |
380 | + my $unique_id; |
381 | + if ($cxn->is_cluster_node()) { # for cluster we concatenate various variables to maximize id 'uniqueness' across versions |
382 | + my $sql = q{SHOW STATUS LIKE 'wsrep\_local\_index'}; |
383 | + my (undef, $wsrep_local_index) = $cxn->dbh->selectrow_array($sql); |
384 | + PTDEBUG && _d("Got cluster wsrep_local_index: ",$wsrep_local_index); |
385 | + $unique_id = $wsrep_local_index."|"; |
386 | + foreach my $val ('server\_id', 'wsrep\_sst\_receive\_address', 'wsrep\_node\_name', 'wsrep\_node\_address') { |
387 | + my $sql = "SHOW VARIABLES LIKE '$val'"; |
388 | + PTDEBUG && _d($cxn->name, $sql); |
389 | + my (undef, $val) = $cxn->dbh->selectrow_array($sql); |
390 | + $unique_id .= "|$val"; |
391 | + } |
392 | + } else { |
393 | + my $sql = 'SELECT @@SERVER_ID'; |
394 | + PTDEBUG && _d($sql); |
395 | + $unique_id = $cxn->dbh->selectrow_array($sql); |
396 | + } |
397 | + PTDEBUG && _d("Generated unique id for cluster:", $unique_id); |
398 | + return $unique_id; |
399 | +} |
400 | + |
401 | + |
402 | sub is_cluster_node { |
403 | my ($self, $cxn) = @_; |
404 | |
405 | + $cxn ||= $self; |
406 | my $sql = "SHOW VARIABLES LIKE 'wsrep\_on'"; |
407 | PTDEBUG && _d($cxn->name, $sql); |
408 | my $row = $cxn->dbh->selectrow_arrayref($sql); |
409 | @@ -2581,11 +2609,8 @@ |
410 | my @trimmed_cxns; |
411 | |
412 | for my $cxn ( @cxns ) { |
413 | - my $dbh = $cxn->dbh(); |
414 | |
415 | - my $sql = $self->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id}; |
416 | - PTDEBUG && _d($sql); |
417 | - my ($id) = $dbh->selectrow_array($sql); |
418 | + my $id = $cxn->get_id(); |
419 | PTDEBUG && _d('Server ID for ', $cxn->name, ': ', $id); |
420 | |
421 | if ( ! $seen_ids->{$id}++ ) { |
422 | |
423 | === modified file 'lib/Cxn.pm' |
424 | --- lib/Cxn.pm 2014-11-05 22:21:51 +0000 |
425 | +++ lib/Cxn.pm 2015-01-14 20:09:38 +0000 |
426 | @@ -226,11 +226,42 @@ |
427 | return $self->{hostname} || $self->{dsn_name} || 'unknown host'; |
428 | } |
429 | |
430 | +# This returns the server_id. |
431 | +# For cluster nodes, since server_id is unreliable, we use a combination of |
432 | +# variables to create an id string that is unique. |
433 | +sub get_id { |
434 | + my ($self, $cxn) = @_; |
435 | + |
436 | + $cxn ||= $self; |
437 | + |
438 | + my $unique_id; |
439 | + if ($cxn->is_cluster_node()) { # for cluster we concatenate various variables to maximize id 'uniqueness' across versions |
440 | + my $sql = q{SHOW STATUS LIKE 'wsrep\_local\_index'}; |
441 | + my (undef, $wsrep_local_index) = $cxn->dbh->selectrow_array($sql); |
442 | + PTDEBUG && _d("Got cluster wsrep_local_index: ",$wsrep_local_index); |
443 | + $unique_id = $wsrep_local_index."|"; |
444 | + foreach my $val ('server\_id', 'wsrep\_sst\_receive\_address', 'wsrep\_node\_name', 'wsrep\_node\_address') { |
445 | + my $sql = "SHOW VARIABLES LIKE '$val'"; |
446 | + PTDEBUG && _d($cxn->name, $sql); |
447 | + my (undef, $val) = $cxn->dbh->selectrow_array($sql); |
448 | + $unique_id .= "|$val"; |
449 | + } |
450 | + } else { |
451 | + my $sql = 'SELECT @@SERVER_ID'; |
452 | + PTDEBUG && _d($sql); |
453 | + $unique_id = $cxn->dbh->selectrow_array($sql); |
454 | + } |
455 | + PTDEBUG && _d("Generated unique id for cluster:", $unique_id); |
456 | + return $unique_id; |
457 | +} |
458 | + |
459 | + |
460 | # This is used to help remove_duplicate_cxns detect cluster nodes |
461 | # (which often have unreliable server_id's) |
462 | sub is_cluster_node { |
463 | my ($self, $cxn) = @_; |
464 | |
465 | + $cxn ||= $self; |
466 | my $sql = "SHOW VARIABLES LIKE 'wsrep\_on'"; |
467 | PTDEBUG && _d($cxn->name, $sql); |
468 | my $row = $cxn->dbh->selectrow_arrayref($sql); |
469 | @@ -257,14 +288,8 @@ |
470 | my @trimmed_cxns; |
471 | |
472 | for my $cxn ( @cxns ) { |
473 | - my $dbh = $cxn->dbh(); |
474 | |
475 | - # Very often cluster nodes are configured with matching server_id's |
476 | - # So in that case we'll use its incoming address as its unique identifier |
477 | - # Note: this relies on "seen_ids" being populated using the same strategy |
478 | - my $sql = $self->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id}; |
479 | - PTDEBUG && _d($sql); |
480 | - my ($id) = $dbh->selectrow_array($sql); |
481 | + my $id = $cxn->get_id(); |
482 | PTDEBUG && _d('Server ID for ', $cxn->name, ': ', $id); |
483 | |
484 | if ( ! $seen_ids->{$id}++ ) { |
485 | |
486 | === modified file 'lib/Percona/XtraDB/Cluster.pm' |
487 | --- lib/Percona/XtraDB/Cluster.pm 2014-10-23 17:32:34 +0000 |
488 | +++ lib/Percona/XtraDB/Cluster.pm 2015-01-14 20:09:38 +0000 |
489 | @@ -137,13 +137,7 @@ |
490 | my @trimmed_cxns; |
491 | |
492 | for my $cxn ( @cxns ) { |
493 | - my $dbh = $cxn->dbh(); |
494 | - # Very often cluster nodes are configured with matching server_id's |
495 | - # So in that case we'll use its incoming address as its unique identifier |
496 | - # Note: This relies on "seen_ids" being populated using the same strategy |
497 | - my $sql = $self->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id}; |
498 | - PTDEBUG && _d($sql); |
499 | - my ($id) = $dbh->selectrow_array($sql); |
500 | + my $id = $cxn->get_id(); |
501 | PTDEBUG && _d('Server ID for ', $cxn->name, ': ', $id); |
502 | |
503 | if ( ! $seen_ids->{$id}++ ) { |
504 | |
505 | === added directory 'sandbox/servers/pxc/5.6' |
506 | === added file 'sandbox/servers/pxc/5.6/my.sandbox.cnf' |
507 | --- sandbox/servers/pxc/5.6/my.sandbox.cnf 1970-01-01 00:00:00 +0000 |
508 | +++ sandbox/servers/pxc/5.6/my.sandbox.cnf 2015-01-14 20:09:38 +0000 |
509 | @@ -0,0 +1,42 @@ |
510 | +[client] |
511 | +user = msandbox |
512 | +password = msandbox |
513 | +port = PORT |
514 | +socket = /tmp/PORT/mysql_sandboxPORT.sock |
515 | + |
516 | +[mysqld] |
517 | +port = PORT |
518 | +socket = /tmp/PORT/mysql_sandboxPORT.sock |
519 | +pid-file = /tmp/PORT/data/mysql_sandboxPORT.pid |
520 | +basedir = PERCONA_TOOLKIT_SANDBOX |
521 | +datadir = /tmp/PORT/data |
522 | +key_buffer_size = 16M |
523 | +innodb_buffer_pool_size = 16M |
524 | +innodb_data_home_dir = /tmp/PORT/data |
525 | +innodb_log_group_home_dir = /tmp/PORT/data |
526 | +innodb_data_file_path = ibdata1:10M:autoextend |
527 | +innodb_log_file_size = 5M |
528 | +log-bin = mysql-bin |
529 | +relay_log = mysql-relay-bin |
530 | +log_slave_updates |
531 | +server-id = PORT |
532 | +report-host = 127.0.0.1 |
533 | +report-port = PORT |
534 | +log-error = /tmp/PORT/data/mysqld.log |
535 | +innodb_lock_wait_timeout = 3 |
536 | +general_log |
537 | +general_log_file = genlog |
538 | + |
539 | +binlog_format = ROW |
540 | +wsrep_provider = LIBGALERA |
541 | +wsrep_cluster_address = CLUSTER_AD |
542 | +wsrep_sst_receive_address = ADDR:RECEIVE_PRT |
543 | +wsrep_node_incoming_address= ADDR:PORT |
544 | +wsrep_slave_threads = 2 |
545 | +wsrep_cluster_name = CLUSTER_NAME |
546 | +wsrep_provider_options = "gmcast.listen_addr=tcp://ADDR:LISTEN_PRT;" |
547 | +wsrep_sst_method = rsync |
548 | +wsrep_node_name = PORT |
549 | +innodb_locks_unsafe_for_binlog = 1 |
550 | +innodb_autoinc_lock_mode = 2 |
551 | +wsrep-replicate-myisam |
552 | |
553 | === modified file 't/pt-table-checksum/pxc.t' |
554 | --- t/pt-table-checksum/pxc.t 2014-11-07 20:14:54 +0000 |
555 | +++ t/pt-table-checksum/pxc.t 2015-01-14 20:09:38 +0000 |
556 | @@ -88,8 +88,8 @@ |
557 | ); |
558 | |
559 | ok ( |
560 | - $output =~ qr/WARNING/i && !$exit_status, |
561 | - "Warns but doesn't die if --recursion-method=none - issue #1373937" |
562 | + $output !~ qr/no other nodes or regular replicas were found/i && !$exit_status, |
563 | + "checksums even if --recursion-method=none - issue 1373937" |
564 | ); |
565 | |
566 | for my $args ( |
567 | @@ -159,6 +159,7 @@ |
568 | my $same_ids = shift; |
569 | |
570 | my ($orig_id_1, $orig_id_2, $orig_id_3); |
571 | + my ($orig_ia_1, $orig_ia_2, $orig_ia_3); |
572 | |
573 | if ($same_ids) { |
574 | # save original values |
575 | @@ -171,6 +172,19 @@ |
576 | $node1->do($sql); |
577 | $node2->do($sql); |
578 | $node3->do($sql); |
579 | + |
580 | + # since we're testing server id issues, set wsrep_node_incoming_address=AUTO ( https://bugs.launchpad.net/percona-toolkit/+bug/1399789 ) |
581 | + # save original values |
582 | + $sql = 'SELECT @@wsrep_node_incoming_address'; |
583 | + ($orig_ia_1) = $node1->selectrow_array($sql); |
584 | + ($orig_ia_2) = $node2->selectrow_array($sql); |
585 | + ($orig_ia_3) = $node3->selectrow_array($sql); |
586 | + # set wsrep_node_incoming_address value to AUTO on all nodes |
587 | + $sql = 'SET GLOBAL wsrep_node_incoming_address = AUTO'; |
588 | + $node1->do($sql); |
589 | + $node2->do($sql); |
590 | + $node3->do($sql); |
591 | + |
592 | } |
593 | |
594 | for my $args ( |
595 | @@ -227,6 +241,10 @@ |
596 | $node1->do("SET GLOBAL server_id = $orig_id_1"); |
597 | $node2->do("SET GLOBAL server_id = $orig_id_2"); |
598 | $node3->do("SET GLOBAL server_id = $orig_id_3"); |
599 | + # reset node wsrep_node_incoming_address to original values |
600 | + $node1->do("SET GLOBAL wsrep_node_incoming_address = $orig_ia_1"); |
601 | + $node2->do("SET GLOBAL wsrep_node_incoming_address = $orig_ia_2"); |
602 | + $node3->do("SET GLOBAL wsrep_node_incoming_address = $orig_ia_3"); |
603 | } |
604 | |
605 | } |
Also added PXC5.6 config file for sandbox