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

[PATCH] Slave cannot replicate signed integer-type values with high bit set to 1

    Details

      Description

      Let's create a simple table on our master server:

      CREATE DATABASE slave_conversion_test;
       
      CREATE TABLE slave_conversion_test.tab (
      	id int(10) unsigned NOT NULL,
      	data varchar(50),
      	PRIMARY KEY(id)
      );

      And then we can insert some data. To reproduce this issue, we need to make sure that the most significant bit of one of the integer values is '1':

      INSERT INTO slave_conversion_test.tab (id, data) VALUES (1, 'str');
      INSERT INTO slave_conversion_test.tab (id, data) VALUES (2147483647, 'str');
      INSERT INTO slave_conversion_test.tab (id, data) VALUES (4294967295, 'str');

      Now let's change the 'id' column to 'bigint' on the slave:

      STOP SLAVE;
      ALTER TABLE slave_conversion_test.tab MODIFY id BIGINT NOT NULL;

      We also need to set slave_type_conversions to ALL_NON_LOSSY to make this work:

      SET GLOBAL slave_type_conversions=ALL_NON_LOSSY;
      START SLAVE;

      Now back on the master, let's try to update these rows:

      UPDATE slave_conversion_test.tab SET data='newstr' WHERE id=2147483647;
      UPDATE slave_conversion_test.tab SET data='newstr' WHERE id=4294967295;

      Now what data do we see on the slave:

      MariaDB [(none)]> SELECT * FROM slave_conversion_test.tab;
      +------------+--------+
      | id         | data   |
      +------------+--------+
      |          1 | str    |
      | 2147483647 | newstr |
      | 4294967295 | str    |
      +------------+--------+
      3 rows in set (0.00 sec)

      The row with 'id' value 4294967295 created an error on the slave:

      MariaDB [(none)]> SHOW SLAVE STATUS\G
      *************************** 1. row ***************************
                     Slave_IO_State: Waiting for master to send event
                        Master_Host: 192.168.1.65
                        Master_User: repl
                        Master_Port: 3306
                      Connect_Retry: 60
                    Master_Log_File: mysqld-bin.000004
                Read_Master_Log_Pos: 1088
                     Relay_Log_File: master-relay-bin.000005
                      Relay_Log_Pos: 599
              Relay_Master_Log_File: mysqld-bin.000004
                   Slave_IO_Running: Yes
                  Slave_SQL_Running: No
                    Replicate_Do_DB: 
                Replicate_Ignore_DB: 
                 Replicate_Do_Table: 
             Replicate_Ignore_Table: 
            Replicate_Wild_Do_Table: 
        Replicate_Wild_Ignore_Table: 
                         Last_Errno: 1032
                         Last_Error: Could not execute Update_rows_v1 event on table slave_conversion_test.tab; Can't find record in 'tab', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mysqld-bin.000004, end_log_pos 1061
                       Skip_Counter: 0
                Exec_Master_Log_Pos: 884
                    Relay_Log_Space: 1821
                    Until_Condition: None
                     Until_Log_File: 
                      Until_Log_Pos: 0
                 Master_SSL_Allowed: No
                 Master_SSL_CA_File: 
                 Master_SSL_CA_Path: 
                    Master_SSL_Cert: 
                  Master_SSL_Cipher: 
                     Master_SSL_Key: 
              Seconds_Behind_Master: NULL
      Master_SSL_Verify_Server_Cert: No
                      Last_IO_Errno: 0
                      Last_IO_Error: 
                     Last_SQL_Errno: 1032
                     Last_SQL_Error: Could not execute Update_rows_v1 event on table slave_conversion_test.tab; Can't find record in 'tab', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mysqld-bin.000004, end_log_pos 1061
        Replicate_Ignore_Server_Ids: 
                   Master_Server_Id: 3
                     Master_SSL_Crl: 
                 Master_SSL_Crlpath: 
                         Using_Gtid: No
                        Gtid_IO_Pos: 
      1 row in set (0.00 sec)

      The slave seems to want to interpret the id value in the Update_rows_v1 event as a negative integer, since the most significant bit is 1.

      The master in this case is MySQL 5.5, if that makes a difference.

        Attachments

          Activity

            People

            • Assignee:
              monty Michael Widenius
              Reporter:
              GeoffMontee Geoff Montee
            • Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: