Uploaded image for project: 'Percona Server for MySQL'
  1. Percona Server for MySQL
  2. PS-1624

LP #1452397: Gaps in Retrieved_Gtid_Set while no gaps in Executed_Gtid_Set

    XMLWordPrintable

    Details

      Description

      **Reported in Launchpad by Sveta Smirnova last update 30-10-2015 09:22:21

      Under certain circumstances it is possible that Retrieved_Gtid_Set on slave will contain gaps while actually no gaps will be in Executed_Gtid_Set and slave binary logs.

      This happens when slave rotates relay log in such a way that last event contains record which sets GTID_NEXT, then following log contains few GTIDs, then slave restarts. After restart GTIDs for Retrieved_Gtid_Set executed wrongly and there are fantom gaps.

      How to repeat.

      Modify sources as follow (this is against MySQL from GitHub):

      diff --git a/sql/binlog.cc b/sql/binlog.cc
      index a02b987..9adb8bd 100644
      — a/sql/binlog.cc
      +++ b/sql/binlog.cc
      @@ -5057,6 +5057,7 @@ bool MYSQL_BIN_LOG::after_append_to_relay_log(Master_info *mi)
      DBUG_EVALUATE_IF("rotate_slave_debug_group", 500, max_size))
      {
      error= new_file_without_locking(mi->get_mi_description_event());
      + DBUG_EXECUTE_IF("gtid_next_bug", if (0 == max_size)

      {max_size = 1073741824;}

      );
      }
      }

      @@ -5092,7 +5093,7 @@ bool MYSQL_BIN_LOG::append_event(Log_event* ev, Master_info *mi)
      }

      -bool MYSQL_BIN_LOG::append_buffer(const char* buf, uint len, Master_info *mi)
      +bool MYSQL_BIN_LOG::append_buffer(const char* buf, uint len, Master_info *mi, Log_event_type event_type)
      {
      DBUG_ENTER("MYSQL_BIN_LOG::append_buffer");

      @@ -5101,6 +5102,8 @@ bool MYSQL_BIN_LOG::append_buffer(const char* buf, uint len, Master_info *mi)
      DBUG_ASSERT(is_relay_log);
      mysql_mutex_assert_owner(&LOCK_log);

      + DBUG_EXECUTE_IF("gtid_next_bug", if (GTID_LOG_EVENT == event_type)

      {max_size=0; fprintf(stderr, "executing\n");}

      );
      +
      // write data
      bool error= false;
      if (my_b_append(&log_file,(uchar*) buf,len) == 0)
      diff --git a/sql/binlog.h b/sql/binlog.h
      index 38efe64..4ecda34 100644
      — a/sql/binlog.h
      +++ b/sql/binlog.h
      @@ -607,7 +607,7 @@ public:
      bool is_query_in_union(THD *thd, query_id_t query_id_param);

      #ifdef HAVE_REPLICATION

      • bool append_buffer(const char* buf, uint len, Master_info *mi);
        + bool append_buffer(const char* buf, uint len, Master_info *mi, Log_event_type event_type);
        bool append_event(Log_event* ev, Master_info *mi);
        private:
        bool after_append_to_relay_log(Master_info *mi);
        diff --git a/sql/rpl_slave.cc b/sql/rpl_slave.cc
        index 30e85fc..b60e916 100644
          • a/sql/rpl_slave.cc
            +++ b/sql/rpl_slave.cc
            @@ -7051,7 +7051,7 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
            else
            {
            /* write the event to the relay log */
      • if (likely(rli->relay_log.append_buffer(buf, event_len, mi) == 0))
        + if (likely(rli->relay_log.append_buffer(buf, event_len, mi, event_type) == 0))
        {
        mi->set_master_log_pos(mi->get_master_log_pos() + inc_pos);
        DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->get_master_log_pos()));

      Run attached test case.

      You will see in the end:

      Retrieved_Gtid_Set 6030e94d-f416-11e4-bfd7-28b2bd7442fd:1-3:5-6
      Executed_Gtid_Set 6030e94d-f416-11e4-bfd7-28b2bd7442fd:1-6

        Smart Checklist

          Attachments

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              lpjirasync lpjirasync (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: