5-Replica Registration

Details the initialization phase where a replica connects to the primary, authenticates, sends capabilities, and registers for updates.

Overview

The replica server, when properly configured with CHANGE MASTER TO ... , can start MariaDB replication with the START REPLICA statement.

After authentication, some COM_QUERY packets are exchanged before sending COM_REGISTER_SLAVE and COM_BINLOG_DUMP.

The following COM_QUERY packets come from MariaDB 10.X replicas using GTID:

  • SELECT UNIX_TIMESTAMP();

  • SHOW VARIABLES LIKE 'SERVER_ID';

  • SET @master_heartbeat_period= 30000001024;

  • SET @master_binlog_checksum= @@global.binlog_checksum;

  • SELECT @master_binlog_checksum;

  • SET @mariadb_slave_capability=4;

  • SELECT @@GLOBAL.gtid_domain_id GTID registration: domain ID;

  • SET @slave_connect_state='0-10201-9868' GTID registration: the requested GTID;

  • SET @slave_gtid_strict_mode=0 GTID registration: strict_mode;

  • SET @slave_gtid_ignore_duplicates=0 GTID registration: ignore_duplicates.

Then COM_REGISTER_SLAVE completes the registration.

The COM_BINLOG_DUMP marks the request of binlog events stream.

If semi-sync is in use, the request for the network protocol change is sent between COM_REGISTER_SLAVE and COM_BINLOG_DUMP.

Example Using 'ngrep'

COM_REGISTER_SLAVE, Semi-Sync and COM_BINLOG_DUMP:

In the example, we see that these two COM_QUERY commands are sent just after COM_REGISTER_SLAVE and before COM_BINLOG_DUMP:

  • SHOW VARIABLES LIKE 'rpl_semi_sync_master_enabled';

  • SET @rpl_semi_sync_slave= 1.

Complete Example with GTID Registration

The example shows output up to COM_BINLOG_DUMP request, No Semi-Sync:

Events Transmission After COM_BINLOG_DUMP

The MariaDB master always sends this, after the COM_BINLOG_DUMP:

After those first events, the master sends events related to changes in database to the connected replica binlog. The replica is just waiting for new events from master.

Complete Example of Event Transmission With CRC32

We can see:

  1. FAKE_ROTATE_EVENT packet: 30 00 00 01 ... d5 3f ea d7

  2. FORMAT_DESCRIPTION_EVENT packet: fd 00 00 02 00 ... 17 0b 12 63 FDE size is fc 00 00 00 (252) Next Pos in FDE is 00 01 00 00 = >256 = 4 + FDE size (252)

  3. FAKE_GTID_LIST_EVENT packet : 3c 00 00 03 00 ... b6 33 8a 22

  4. BINLOG_CHECKPOINT EVENT packet: 2c 00 00 04 ... 16 1f fe 3f

  5. GTID_LIST_EVENT packet: 2c 00 00 05 ... 4a 01 94 22

  6. GTID_EVENT packet: 2b 00 00 06 ... 22 87 c0 61

  7. QUERY_EVENT packet: 4c 00 00 07 ... 6e c8 89 60

This page is licensed: CC BY-SA / Gnu FDL

Last updated

Was this helpful?