Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-16886

mysqdump --master-data=N crashes when SELECT BINLOG_GTID_POS() returns NULL for current master coordinates, for whatever reason

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.2.11, 10.2.16
    • 10.2(EOL)
    • Backup, Scripts & Clients
    • None
    • RHEL with kernel 3.10.0-862.3.2.el7.x86_64

    Description

      Sometimes it happens so that SELECT BINLOG_GTID_POS() returns NULL for specific master coordinates that come from SHOW MASTER STATUS:

      MariaDB [(none)]> show master status;
      +------------------+-----------+--------------+------------------+
      | File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
      +------------------+-----------+--------------+------------------+
      | mysql-bin.001552 | 313974469 | | |
      +------------------+-----------+--------------+------------------+
       
      MariaDB [(none)]> SELECT BINLOG_GTID_POS("mysql-bin.001552",313974469);
      +-----------------------------------------------+
      | BINLOG_GTID_POS("mysql-bin.001552",313974469) |
      +-----------------------------------------------+
      | NULL |
      +-----------------------------------------------+
      

      It seems the code of mysqldump is not ready for this, see https://github.com/MariaDB/server/blob/10.2/client/mysqldump.c#L1298:

      static int
      get_gtid_pos(char *out_gtid_pos, int master)
      {
        MYSQL_RES *res;
        MYSQL_ROW row;
        int found;
       
        if (mysql_query_with_error_report(mysql, &res,
                                          (master ?
                                           "SELECT @@GLOBAL.gtid_binlog_pos" :
                                           "SELECT @@GLOBAL.gtid_slave_pos")))
          return 1;
       
        found= 0;
        if ((row= mysql_fetch_row(res)))
        {
          strmake(out_gtid_pos, row[0], MAX_GTID_LENGTH-1);
          found++;
        }
        mysql_free_result(res);
       
        return (found != 1);
      }
      

      As a result, it crashes with the following backtrace:

      gdb --args /apps/hpbx_db_prod/mysql/bin/mysqldump --single-transaction --default-character-set utf8 --add-drop-table --routines --master-data=2 -uroot -p******* --databases test --socket=/apps/hpbx_db_prod/mysql/mysql_pPBX1.sock
      GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-110.el7
      Copyright (C) 2013 Free Software Foundation, Inc.
      License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law. Type "show copying"
      and "show warranty" for details.
      This GDB was configured as "x86_64-redhat-linux-gnu".
      For bug reporting instructions, please see:
      <http://www.gnu.org/software/gdb/bugs/>...
      Reading symbols from /apps/hpbx_db_prod/mariadb-10.2.11-linux-x86_64/bin/mysqldump...done.
      (gdb) run
      Starting program: /apps/hpbx_db_prod/mysql/bin/mysqldump --single-transaction --default-character-set utf8 --add-drop-table --routines --master-data=2 -uroot ...
      [Thread debugging using libthread_db enabled]
      Using host libthread_db library "/lib64/libthread_db.so.1".
      -- MySQL dump 10.16 Distrib 10.2.11-MariaDB, for Linux (x86_64)
      --
      -- Host: localhost Database: test
      -- ------------------------------------------------------
      -- Server version 10.2.11-MariaDB-log
       
      /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
      /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
      /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
      /*!40101 SET NAMES utf8 */;
      /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
      /*!40103 SET TIME_ZONE='+00:00' */;
      /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
      /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
      /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
      /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
       
      Program received signal SIGSEGV, Segmentation fault.
      strmake (dst=0x7fffffffd550 "", src=0x0, length=1022) at /home/buildbot/buildbot/build/strings/strmake.c:36
      36 /home/buildbot/buildbot/build/strings/strmake.c: No such file or directory.
      Missing separate debuginfos, use: debuginfo-install glibc-2.17-222.el7.x86_64 libgcc-4.8.5-28.0.1.el7_5.1.x86_64 libstdc++-4.8.5-28.0.1.el7_5.1.x86_64
      (gdb) bt
      #0 strmake (dst=0x7fffffffd550 "", src=0x0, length=1022) at /home/buildbot/buildbot/build/strings/strmake.c:36
      #1 0x0000000000411efa in get_binlog_gtid_pos (out_gtid_pos=<optimized out>, binlog_pos_offset=<optimized out>, binlog_pos_file=<optimized out>)
      at /home/buildbot/buildbot/build/client/mysqldump.c:1295
      #2 do_show_master_status (mysql_con=<optimized out>, consistent_binlog_pos=1, have_mariadb_gtid=1, use_gtid=0)
      at /home/buildbot/buildbot/build/client/mysqldump.c:5115
      #3 0x000000000041ba70 in main (argc=1, argv=0xb556a0) at /home/buildbot/buildbot/build/client/mysqldump.c:6094
      

      becasue src in strmake call is 0. This should be checked and crash should be prevented. It's better to generate CHANGE MASTER with normal binary log name and position coordinates (and output a warning about the problem with getting GTID) than just crash silently.

      Attachments

        Issue Links

          Activity

            People

              bnestere Brandon Nesterenko
              valerii Valerii Kravchuk
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.