Uploaded image for project: 'Percona Toolkit'
  1. Percona Toolkit
  2. PT-1739

disable-qrt-plugin option of pt-table-checksum is broken

Details

    • Bug
    • Status: Done
    • High
    • Resolution: Fixed
    • 3.0.10, 3.0.11, 3.0.12, 3.0.13
    • 3.5.0
    • pt-table-checksum
    • None
    • 1

    Description

      As of percona toolkit 3.0.10, the release notes state that pt-table-checksum disables the QRT plugin.  Presumably this was to be a configurable option, based on the --disable-qrt-plugin command-line flag.

      However, pt-table-checksum forcibly disables QRT on all slaves, regardless of the value of this option - and unless this option was explicitly set to TRUE, it remains OFF.

      Disabling QRT on the master is controlled by an if() statement - if ($o->get('disable-qrt-plugin') on line 10158 (this is PT 3.0.13)

      But there is no such if() statement for the slaves, beginning on line 10492.

            for my $slave (@$slaves) {
                my $qrt_plugin_status;
                eval {
                    ($qrt_plugin_status) = $slave->{dbh}->selectrow_arrayref('SELECT @@QUERY_RESPONSE_TIME_SESSION_STATS' );
                };
                if ($EVAL_ERROR) {
                    PTDEBUG && _d('QRT plugin is not installed on slave '.$slave->{dsn_name});
                    $slave->{qrt_plugin_status} = undef;
                    next;
                }
                $slave->{qrt_plugin_status} = $qrt_plugin_status->[0];
                if ($slave->{qrt_plugin_status}) {
                    PTDEBUG && _d("Disabling qrt plugin state on slave ".$slave->{dsn_name});
                    $slave->{dbh}->do('SET GLOBAL query_response_time_stats = off');
                }
            } 

      Then on line 11523, when the QRT plugin is reset back to its original value, once again the code is wrapped in a conditional:

         # Restore origin QRT pligin state
         if ($o->get('disable-qrt-plugin')) {
             eval {
                 if ($original_qrt_plugin_master_status) {
                     PTDEBUG && _d("Restoring qrt plugin state on master server");
                     $master_dbh->do("SET GLOBAL query_response_time_stats = $original_qrt_plugin_master_status->[0]");
                 }
                 for my $slave (@$slaves) {
                     if ($slave->{qrt_plugin_status}) {
                         PTDEBUG && _d("Restoring qrt plugin state on slave ".$slave->{dsn_name});
                         $slave->{dbh}->do("SET GLOBAL query_response_time_stats = $slave->{qrt_plugin_status}");
                     }
                 }
             };
             if ($EVAL_ERROR) {
                 warn "Cannot restore qrt_plugin status: $EVAL_ERROR";
             }
         } 

      So, QRT silently gets shut off and it never comes back on - and should your slave get promoted to master, you'll be wondering why you suddenly have no metrics.

      The fix for this is trivial - wrap that loop over the slaves in an "if $o->get('disable-qrt-plugin') { .. }"

      Attachments

        Issue Links

          Activity

            People

              sveta.smirnova Sveta Smirnova
              ravyn440 Ernie Souhrada
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Smart Checklist