Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-253 Multi-source replication
  3. MDEV-552

Multi-source: Slave allows multiple masters to have the same server id (might be bad for complicated replication setups)

    XMLWordPrintable

    Details

    • Type: Technical task
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Currently multisource replication setup is possible even if masters have the same server_id: the slave doesn't complain either on configuration or on replication start. As a result, there might be problems with further replication, e.g. if we want to setup master1,master2 => slave => master2 configuration: updates from master1 won't be replicated on master2, because they will have the same server_id in the slave binary log.

      The safer way would be not to allow to configure or start replication from several masters with the same server-id.

      The test below shows it. It's not ready to be put into the test suite as is, because if the problem is fixed, the second slave startup won't happen, and the remaining part of the test will be redundant; that's why the test doesn't have a "cleanup" part. However, it can be used as a stub of the future test. Please note that the test requires its own cnf file (also provided here).

      cat suite/multi_source/same_server_id.cnf

      # cat t/multisource1.cnf
      !include include/default_mysqld.cnf
      !include include/default_client.cnf
       
      [mysqld.1]
      server-id=1
      log-bin=master-bin
       
      [mysqld.2]
      server-id=1
      log-bin=master-bin
       
      [mysqld.3]
      server-id=3
      log-slave-updates
      log-bin=master-bin
       
      [ENV]
      SERVER_MYPORT_1= @mysqld.1.port
      SERVER_MYSOCK_1= @mysqld.1.socket
      SERVER_MYPORT_2= @mysqld.2.port
      SERVER_MYSOCK_2= @mysqld.2.socket
      SERVER_MYPORT_3= @mysqld.3.port
      SERVER_MYSOCK_3= @mysqld.3.socket

      cat suite/multi_source/same_server_id.test

      # In the cnf file for this test, mysqld.1 and mysqld.2 have
      # the same server-id=1, and mysqld.3 has server-id=3
       
      --connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3)
       
      # Start replication from the first master
       
      --replace_result $SERVER_MYPORT_1 MYPORT_1
      eval change master 'master1' to
      master_port=$SERVER_MYPORT_1,
      master_host='127.0.0.1',
      master_user='root';
       
      start slave 'master1';
      set default_master_connection = 'master1';
      --source include/wait_for_slave_to_start.inc
       
      # Start replication from the second master
       
      --replace_result $SERVER_MYPORT_2 MYPORT_2
      eval change master 'master2' to
      master_port=$SERVER_MYPORT_2,
      master_host='127.0.0.1',
      master_user='root';
       
      start slave 'master2';
      set default_master_connection = 'master2';
      --source include/wait_for_slave_to_start.inc
       
      set default_master_connection = '';
       
      --connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1)
      --disable_warnings
      drop table if exists t1;
      --enable_warnings
      create table t1 (i int) engine=MyISAM;
      --save_master_pos
       
      --connection slave
      --sync_with_master 0,'master1'
       
      --connect (master2,127.0.0.1,root,,,$SERVER_MYPORT_2)
      --disable_warnings
      drop table if exists t2;
      --enable_warnings
      create table t2 (j int) engine=MyISAM;
      --save_master_pos
       
      --connection slave
      --sync_with_master 0,'master2'
       
      --echo
      --echo # See that all entries are written with the same
      --echo # server_id = 1
      show binlog events;
       
      --save_master_pos
       
      # Now set up replication from the slave to the second master
      # (the 'circular' part)
       
      --connection master2
       
      --replace_result $SERVER_MYPORT_3 MYPORT_3
      eval change master to
      master_port=$SERVER_MYPORT_3,
      master_host='127.0.0.1',
      master_user='root';
       
      start slave;
      --sync_with_master 0
       
      --echo
      --echo # See that t1 was not replicated
      --echo # (because the entry had the same server_id)
      show tables;

        Attachments

          Activity

            People

            Assignee:
            monty Michael Widenius
            Reporter:
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.