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

S3 Engine: delayed slave may stop with an error




      (I am not sure if this property is a bug or a fundamental limitation. If it is a limitation, it's not documented, and we need to define this limitation)

      The issue:
      Consider a case where table T is first created in Aria (or any other regular engine), and then it is re-created in S3. Operations on T in Aria are binlogged. The slave will try to apply them. If the slave is delayed, it will see the table in S3, and try to apply changes to the S3 table.

      It is tempting to define the limitation as "For any dbname.tablename, you should decide beforehand what storage engine you're going to use, and only use that engine". The problem is that for S3 you can't do that - the only way to fill the S3 table is to create an Aria table (or other local table?) and then do "ALTER TABLE t ENGINE=S3". That is, it's unavoidable that t is a local table first, and then it's an S3 table.

      A testcase:


      !include ../rpl/my.cnf
      !include ./my.cnf
      !include ./slave.cnf


      --source include/have_s3.inc
      --source include/master-slave.inc
      drop table if exists t1;
      connection slave;
      show variables like 's3_slave%';
      stop slave;
      connection master;
      create table t1 (a int, b int) engine=aria;
      insert into t1 values (1,1),(2,2),(3,3);
      alter table t1 engine=s3;
      connection slave;
      show tables;
      start slave;
      connection master;
      connection slave;
      select * from t1;
      --source include/rpl_end.inc

      This will fail with:

      mysqltest: At line 27: sync_slave_with_master failed: 'select master_pos_wait('master-bin.000001', 1056, 300, '')' returned NULL indicating slave SQL thread failure


      Last_Error      Could not execute Write_rows_v1 event on table test.t1; 
      Table 't1' is read only, Error_code: 1036; handler error 
      HA_ERR_TABLE_READONLY; the event's master log 
      master-bin.000001, end_log_pos 850

      **** SHOW BINLOG EVENTS on default ****
      binlog_name = 'master-bin.000001'
      SHOW BINLOG EVENTS IN 'master-bin.000001';
      Log_name        Pos     Event_type      Server_id       End_log_pos     Info
      master-bin.000001       4       Format_desc     1       256     Server ver: 10.5.9-MariaDB-debug-log, Binlog ver: 4
      master-bin.000001       256     Gtid_list       1       285     []
      master-bin.000001       285     Binlog_checkpoint       1       329     master-bin.000001
      master-bin.000001       329     Gtid    1       371     GTID 0-1-1
      master-bin.000001       371     Query   1       489     use `test`; DROP TABLE IF EXISTS `t1` /* generated by server */
      master-bin.000001       489     Gtid    1       531     GTID 0-1-2
      master-bin.000001       531     Query   1       640     use `test`; create table t1 (a int, b int) engine=aria
      master-bin.000001       640     Gtid    1       682     BEGIN GTID 0-1-3
      master-bin.000001       682     Annotate_rows   1       744     insert into t1 values (1,1),(2,2),(3,3)
      master-bin.000001       744     Table_map       1       790     table_id: 32 (test.t1)
      master-bin.000001       790     Write_rows_v1   1       850     table_id: 32 flags: STMT_END_F
      master-bin.000001       850     Query   1       923     COMMIT
      master-bin.000001       923     Gtid    1       965     GTID 0-1-4
      master-bin.000001       965     Query   1       1056    use `test`; alter table t1 engine=s3




            monty Michael Widenius
            psergey Sergei Petrunia
            0 Vote for this issue
            3 Start watching this issue