~percona-toolkit-dev/percona-toolkit/use-local-mysql-versions-for-testing

« back to all changes in this revision

Viewing changes to lib/Percona/XtraDB/Cluster.pm

  • Committer: Frank Cizmich
  • Date: 2014-11-18 21:41:23 UTC
  • mfrom: (608.1.31 release-2.2.12)
  • Revision ID: frank.cizmich@percona.com-20141118214123-hyj5wno2onb5wo6o
merged release-2.2.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
132
132
sub remove_duplicate_cxns {
133
133
   my ($self, %args) = @_;
134
134
   my @cxns     = @{$args{cxns}};
135
 
   my $seen_ids = $args{seen_ids};
136
 
   return Cxn->remove_duplicate_cxns(%args);
 
135
   my $seen_ids = $args{seen_ids} || {};
 
136
   PTDEBUG && _d("Removing duplicates nodes from ", join(" ", map { $_->name } @cxns));
 
137
   my @trimmed_cxns;
 
138
 
 
139
   for my $cxn ( @cxns ) {
 
140
      my $dbh  = $cxn->dbh();
 
141
      # Very often cluster nodes are configured with matching server_id's
 
142
      # So in that case we'll use its incoming address as its unique identifier
 
143
      # Note: This relies on "seen_ids" being populated using the same strategy  
 
144
      my $sql  = $self->is_cluster_node($cxn) ? q{SELECT @@wsrep_node_incoming_address} : q{SELECT @@server_id};
 
145
      PTDEBUG && _d($sql);
 
146
      my ($id) = $dbh->selectrow_array($sql);
 
147
      PTDEBUG && _d('Server ID for ', $cxn->name, ': ', $id);
 
148
 
 
149
      if ( ! $seen_ids->{$id}++ ) {
 
150
         push @trimmed_cxns, $cxn
 
151
      }
 
152
      else {
 
153
         PTDEBUG && _d("Removing ", $cxn->name,
 
154
                       ", ID ", $id, ", because we've already seen it");
 
155
      }
 
156
   }
 
157
   return \@trimmed_cxns;
137
158
}
138
159
 
139
160
sub same_cluster {