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

Allow both --replicate-same-server-id=on and --log-slave-updates=on to be enabled at the same time

    XMLWordPrintable

Details

    • Task
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Not a Bug
    • N/A
    • Replication
    • None

    Description

      Enabling both log-slave-updates and replicate-same-server-id simultaneously is possible in MySQL 8.0+ thanks to GTID.

      This is a useful feature to guarantee durability in certain replication configurations. MariaDB should add this capability. This requires adding new code to gracefully ignore duplicated GTIDs.

      I am willing to write this code but request advice from upstream core contributors on how to properly do it.

      Research

      • MariaDB 10.6 forbids the combination of log-slave-updates and replicate-same-server-id as a vestige of old code from MySQL, even though it always writes GTID to the binlog.
      • MySQL <8.0 forbade this combination entirely. An enhancement in MySQL >=8.0 allows it if GTID logging is enabled, because logging GTIDs should permit the identification and deduplication of repeated transactions

      Testing

      I modified MariaDB 10.6 to allow the combination of these two flags:

       --- a/sql/mysqld.cc
       +++ b/sql/mysqld.cc
       @@ -4853,24 +4853,6 @@
          DBUG_ASSERT((uint)global_system_variables.binlog_format <=
                      array_elements(binlog_format_names)-1);
        
       -#ifdef HAVE_REPLICATION
       -  if (opt_log_slave_updates && replicate_same_server_id)
       -  {
       -    if (opt_bin_log)
       -    {
       -      sql_print_error("using --replicate-same-server-id in conjunction with "
       -                      "--log-slave-updates is impossible, it would lead to "
       -                      "infinite loops in this server.");
       -      unireg_abort(1);
       -    }
       -    else
       -      sql_print_warning("using --replicate-same-server-id in conjunction with "
       -                        "--log-slave-updates would lead to infinite loops in "
       -                        "this server. However this will be ignored as the "
       -                        "--log-bin option is not defined.");
       -  }
       -#endif
       -
          if (opt_bin_log)
          {
            /* Reports an error and aborts, if the --log-bin's path 
       @@ -6552,9 +6534,7 @@
           0, 0, 0, GET_STR | GET_ASK_ADDR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
        #ifdef HAVE_REPLICATION
          {"replicate-same-server-id", 0,
       -   "In replication, if set to 1, do not skip events having our server id. "
       -   "Default value is 0 (to break infinite loops in circular replication). "
       -   "Can't be set to 1 if --log-slave-updates is used.",
       +   "In replication, if set to 1, do not skip events having our server id.",
           &replicate_same_server_id, &replicate_same_server_id,
           0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
        #endif
      

      Then I set the combination of the two flags in rpl_circular_for_4_hosts.test, an MTR test of circular replication with a 4-server configuration:

       --- a/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.cnf
       +++ b/mysql-test/suite/rpl/t/rpl_circular_for_4_hosts.cnf
       @@ -2,18 +2,22 @@
        
        [mysqld.1]
        log-slave-updates
       +replicate-same-server-id
        loose-innodb
        
        [mysqld.2]
        log-slave-updates
       +replicate-same-server-id
        loose-innodb
        
        [mysqld.3]
        log-slave-updates
       +replicate-same-server-id
        loose-innodb
        
        [mysqld.4]
        log-slave-updates
       +replicate-same-server-id
        loose-innodb
        
        [ENV]
      

      With both of these flags, the servers start up successfully, but the test fails after one of the slaves is stopped and attempts to restart. This is due to errors with duplicate transactions:

      2022-04-07 16:23:44 11 [ERROR] Slave SQL: Error 'Duplicate entry '1' for key 'PRIMARY'' on query. Default database: 'test'. Query: 'INSERT INTO t2 (b,c) VALUES('MDEV-515', 100)', Gtid 0-1-3, Internal MariaDB error code: 1062
      2022-04-07 16:23:44 11 [Warning] Slave: Duplicate entry '1' for key 'PRIMARY' Error_code: 1062
      

      The above might be solvable by gracefully dropping duplicate GTIDs, but I need upstream guidance on how to properly proceed with this.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              dlenski Daniel Lenski
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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