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

Due to the failure of foreign key detection, Galera slave node killed himself.

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • 10.2.8, 10.2.10, 10.2.12, 10.3.1
    • 10.1.35, 10.2.15
    • Galera

    Description

      err.log

      [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
      2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
      2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
               at galera/src/trx_handle.cpp:apply():351
      

      Reproduce
      wsrep_slave_threads>1

      CREATE TABLE `p` (
        `id` int(11) NOT NULL,
        `a` varchar(33) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
        PRIMARY KEY (`id`)
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ;
       
      CREATE TABLE `f` (
        `id` int(11) NOT NULL,
        `f_id` int(11) DEFAULT NULL,
        KEY `f_id` (`f_id`),
        CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ;
       
      insert into p select 1,'aaa';
       
      insert into f select 1,1;
       
      #Repeatedly execute the following SQL until you generate thousands of data
      insert into f select a.id + b.a,a.f_id from f a join (select max(id) as a from f b) b on 1=1;
       
      select count(*) from f;
      +----------+
      | count(*) |
      +----------+
      |   131072 |
      +----------+
       
      #Slave node, no matter wsrep_slave_fk_checks is on or off.
      show variables like 'wsrep_slave_fk_checks';
      +-----------------------+-------+
      | Variable_name         | Value |
      +-----------------------+-------+
      | wsrep_slave_fk_checks | ON    |
      +-----------------------+-------+
       
      #Master (Write) node
      delete from f;delete from p;
       
      #Slave node down and got errors
      2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
      2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
      2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
               at galera/src/trx_handle.cpp:apply():351
      Retrying 2th time
      2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
      2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
      2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
               at galera/src/trx_handle.cpp:apply():351
      Retrying 3th time
      2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
      2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
      2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
               at galera/src/trx_handle.cpp:apply():351
      Retrying 4th time
      2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
      2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
      2018-03-16 14:33:39 140457990018816 [ERROR] WSREP: Failed to apply trx: source: 849e805c-1dd2-11e8-aa79-eb31f2b81368 version: 3 local: 0 state: APPLYING flags: 1 conn_id: 87 trx_id: 12277 seqnos (l: 33, g: 128, s: 127, d: 126, ts: 1358419270394303)
      2018-03-16 14:33:39 140457990018816 [ERROR] WSREP: Failed to apply trx 128 4 times
      2018-03-16 14:33:39 140457990018816 [ERROR] WSREP: Node consistency compromised, aborting...
       
      #Slave processlist
      #Write set 127 is "delete from f;"
      #Write set 128 is "delete from p;"
      #Slave concurrently apply the two sql
       !image-2018-03-21-10-45-36-084.png|thumbnail! 
      

      This error didn't reproduce on MariaDB 10.2.7 with wsrep_slave_threads>1

      Attachments

        Issue Links

          Activity

            920895156@qq.com Devin Yu created issue -
            920895156@qq.com Devin Yu made changes -
            Field Original Value New Value
            Description *err.log*
            {code:java}
            [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
                     at galera/src/trx_handle.cpp:apply():351
            {code}

            *Reproduce*
            {code:java}
            CREATE TABLE `p` (
              `id` int(11) NOT NULL,
              `a` varchar(33) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
              PRIMARY KEY (`id`)
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ;

            CREATE TABLE `f` (
              `id` int(11) NOT NULL,
              `f_id` int(11) DEFAULT NULL,
              KEY `f_id` (`f_id`),
              CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ;

            insert into p select 1,'aaa';

            insert into f select 1,1;

            #Repeatedly execute the following SQL until you generate thousands of data
            insert into f select a.id + b.a,a.f_id from f a join (select max(id) as a from f b) b on 1=1;

            select count(*) from f;
            +----------+
            | count(*) |
            +----------+
            | 131072 |
            +----------+

            #Slave node
            show variables like 'wsrep_slave_fk_checks';
            +-----------------------+-------+
            | Variable_name | Value |
            +-----------------------+-------+
            | wsrep_slave_fk_checks | ON |
            +-----------------------+-------+

            #Master (Write) node
            delete from f;delete from p;

            #Slave node down and got errors
            2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
                     at galera/src/trx_handle.cpp:apply():351
            Retrying 2th time
            2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
                     at galera/src/trx_handle.cpp:apply():351
            Retrying 3th time
            2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
                     at galera/src/trx_handle.cpp:apply():351
            Retrying 4th time
            2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [ERROR] WSREP: Failed to apply trx: source: 849e805c-1dd2-11e8-aa79-eb31f2b81368 version: 3 local: 0 state: APPLYING flags: 1 conn_id: 87 trx_id: 12277 seqnos (l: 33, g: 128, s: 127, d: 126, ts: 1358419270394303)
            2018-03-16 14:33:39 140457990018816 [ERROR] WSREP: Failed to apply trx 128 4 times
            2018-03-16 14:33:39 140457990018816 [ERROR] WSREP: Node consistency compromised, aborting...

            #Slave processlist
            #Write set 127 is "delete from f;"
            #Write set 128 is "delete from p;"
            #Slave concurrently apply the two sql
             !image-2018-03-21-10-45-36-084.png|thumbnail!
            {code}

            *This error didn't reproduce on MariaDB 10.2.7.*
            *err.log*
            {code:java}
            [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
                     at galera/src/trx_handle.cpp:apply():351
            {code}

            *Reproduce*
            {code:java}
            CREATE TABLE `p` (
              `id` int(11) NOT NULL,
              `a` varchar(33) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
              PRIMARY KEY (`id`)
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ;

            CREATE TABLE `f` (
              `id` int(11) NOT NULL,
              `f_id` int(11) DEFAULT NULL,
              KEY `f_id` (`f_id`),
              CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ;

            insert into p select 1,'aaa';

            insert into f select 1,1;

            #Repeatedly execute the following SQL until you generate thousands of data
            insert into f select a.id + b.a,a.f_id from f a join (select max(id) as a from f b) b on 1=1;

            select count(*) from f;
            +----------+
            | count(*) |
            +----------+
            | 131072 |
            +----------+

            #Slave node, no matter wsrep_slave_fk_checks is on or off.
            show variables like 'wsrep_slave_fk_checks';
            +-----------------------+-------+
            | Variable_name | Value |
            +-----------------------+-------+
            | wsrep_slave_fk_checks | ON |
            +-----------------------+-------+

            #Master (Write) node
            delete from f;delete from p;

            #Slave node down and got errors
            2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
                     at galera/src/trx_handle.cpp:apply():351
            Retrying 2th time
            2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
                     at galera/src/trx_handle.cpp:apply():351
            Retrying 3th time
            2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
                     at galera/src/trx_handle.cpp:apply():351
            Retrying 4th time
            2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [ERROR] WSREP: Failed to apply trx: source: 849e805c-1dd2-11e8-aa79-eb31f2b81368 version: 3 local: 0 state: APPLYING flags: 1 conn_id: 87 trx_id: 12277 seqnos (l: 33, g: 128, s: 127, d: 126, ts: 1358419270394303)
            2018-03-16 14:33:39 140457990018816 [ERROR] WSREP: Failed to apply trx 128 4 times
            2018-03-16 14:33:39 140457990018816 [ERROR] WSREP: Node consistency compromised, aborting...

            #Slave processlist
            #Write set 127 is "delete from f;"
            #Write set 128 is "delete from p;"
            #Slave concurrently apply the two sql
             !image-2018-03-21-10-45-36-084.png|thumbnail!
            {code}

            *This error didn't reproduce on MariaDB 10.2.7.*
            920895156@qq.com Devin Yu made changes -
            Description *err.log*
            {code:java}
            [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
                     at galera/src/trx_handle.cpp:apply():351
            {code}

            *Reproduce*
            {code:java}
            CREATE TABLE `p` (
              `id` int(11) NOT NULL,
              `a` varchar(33) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
              PRIMARY KEY (`id`)
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ;

            CREATE TABLE `f` (
              `id` int(11) NOT NULL,
              `f_id` int(11) DEFAULT NULL,
              KEY `f_id` (`f_id`),
              CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ;

            insert into p select 1,'aaa';

            insert into f select 1,1;

            #Repeatedly execute the following SQL until you generate thousands of data
            insert into f select a.id + b.a,a.f_id from f a join (select max(id) as a from f b) b on 1=1;

            select count(*) from f;
            +----------+
            | count(*) |
            +----------+
            | 131072 |
            +----------+

            #Slave node, no matter wsrep_slave_fk_checks is on or off.
            show variables like 'wsrep_slave_fk_checks';
            +-----------------------+-------+
            | Variable_name | Value |
            +-----------------------+-------+
            | wsrep_slave_fk_checks | ON |
            +-----------------------+-------+

            #Master (Write) node
            delete from f;delete from p;

            #Slave node down and got errors
            2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
                     at galera/src/trx_handle.cpp:apply():351
            Retrying 2th time
            2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
                     at galera/src/trx_handle.cpp:apply():351
            Retrying 3th time
            2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
                     at galera/src/trx_handle.cpp:apply():351
            Retrying 4th time
            2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [ERROR] WSREP: Failed to apply trx: source: 849e805c-1dd2-11e8-aa79-eb31f2b81368 version: 3 local: 0 state: APPLYING flags: 1 conn_id: 87 trx_id: 12277 seqnos (l: 33, g: 128, s: 127, d: 126, ts: 1358419270394303)
            2018-03-16 14:33:39 140457990018816 [ERROR] WSREP: Failed to apply trx 128 4 times
            2018-03-16 14:33:39 140457990018816 [ERROR] WSREP: Node consistency compromised, aborting...

            #Slave processlist
            #Write set 127 is "delete from f;"
            #Write set 128 is "delete from p;"
            #Slave concurrently apply the two sql
             !image-2018-03-21-10-45-36-084.png|thumbnail!
            {code}

            *This error didn't reproduce on MariaDB 10.2.7.*
            *err.log*
            {code:java}
            [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
                     at galera/src/trx_handle.cpp:apply():351
            {code}

            *Reproduce*
            wsrep_slave_threads>1
            {code:java}
            CREATE TABLE `p` (
              `id` int(11) NOT NULL,
              `a` varchar(33) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
              PRIMARY KEY (`id`)
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ;

            CREATE TABLE `f` (
              `id` int(11) NOT NULL,
              `f_id` int(11) DEFAULT NULL,
              KEY `f_id` (`f_id`),
              CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ;

            insert into p select 1,'aaa';

            insert into f select 1,1;

            #Repeatedly execute the following SQL until you generate thousands of data
            insert into f select a.id + b.a,a.f_id from f a join (select max(id) as a from f b) b on 1=1;

            select count(*) from f;
            +----------+
            | count(*) |
            +----------+
            | 131072 |
            +----------+

            #Slave node, no matter wsrep_slave_fk_checks is on or off.
            show variables like 'wsrep_slave_fk_checks';
            +-----------------------+-------+
            | Variable_name | Value |
            +-----------------------+-------+
            | wsrep_slave_fk_checks | ON |
            +-----------------------+-------+

            #Master (Write) node
            delete from f;delete from p;

            #Slave node down and got errors
            2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
                     at galera/src/trx_handle.cpp:apply():351
            Retrying 2th time
            2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
                     at galera/src/trx_handle.cpp:apply():351
            Retrying 3th time
            2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
                     at galera/src/trx_handle.cpp:apply():351
            Retrying 4th time
            2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [ERROR] WSREP: Failed to apply trx: source: 849e805c-1dd2-11e8-aa79-eb31f2b81368 version: 3 local: 0 state: APPLYING flags: 1 conn_id: 87 trx_id: 12277 seqnos (l: 33, g: 128, s: 127, d: 126, ts: 1358419270394303)
            2018-03-16 14:33:39 140457990018816 [ERROR] WSREP: Failed to apply trx 128 4 times
            2018-03-16 14:33:39 140457990018816 [ERROR] WSREP: Node consistency compromised, aborting...

            #Slave processlist
            #Write set 127 is "delete from f;"
            #Write set 128 is "delete from p;"
            #Slave concurrently apply the two sql
             !image-2018-03-21-10-45-36-084.png|thumbnail!
            {code}

            *This error didn't reproduce on MariaDB 10.2.7 with wsrep_slave_threads>1*
            920895156@qq.com Devin Yu made changes -
            Description *err.log*
            {code:java}
            [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
                     at galera/src/trx_handle.cpp:apply():351
            {code}

            *Reproduce*
            wsrep_slave_threads>1
            {code:java}
            CREATE TABLE `p` (
              `id` int(11) NOT NULL,
              `a` varchar(33) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
              PRIMARY KEY (`id`)
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ;

            CREATE TABLE `f` (
              `id` int(11) NOT NULL,
              `f_id` int(11) DEFAULT NULL,
              KEY `f_id` (`f_id`),
              CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ;

            insert into p select 1,'aaa';

            insert into f select 1,1;

            #Repeatedly execute the following SQL until you generate thousands of data
            insert into f select a.id + b.a,a.f_id from f a join (select max(id) as a from f b) b on 1=1;

            select count(*) from f;
            +----------+
            | count(*) |
            +----------+
            | 131072 |
            +----------+

            #Slave node, no matter wsrep_slave_fk_checks is on or off.
            show variables like 'wsrep_slave_fk_checks';
            +-----------------------+-------+
            | Variable_name | Value |
            +-----------------------+-------+
            | wsrep_slave_fk_checks | ON |
            +-----------------------+-------+

            #Master (Write) node
            delete from f;delete from p;

            #Slave node down and got errors
            2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
                     at galera/src/trx_handle.cpp:apply():351
            Retrying 2th time
            2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
                     at galera/src/trx_handle.cpp:apply():351
            Retrying 3th time
            2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
                     at galera/src/trx_handle.cpp:apply():351
            Retrying 4th time
            2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [ERROR] WSREP: Failed to apply trx: source: 849e805c-1dd2-11e8-aa79-eb31f2b81368 version: 3 local: 0 state: APPLYING flags: 1 conn_id: 87 trx_id: 12277 seqnos (l: 33, g: 128, s: 127, d: 126, ts: 1358419270394303)
            2018-03-16 14:33:39 140457990018816 [ERROR] WSREP: Failed to apply trx 128 4 times
            2018-03-16 14:33:39 140457990018816 [ERROR] WSREP: Node consistency compromised, aborting...

            #Slave processlist
            #Write set 127 is "delete from f;"
            #Write set 128 is "delete from p;"
            #Slave concurrently apply the two sql
             !image-2018-03-21-10-45-36-084.png|thumbnail!
            {code}

            *This error didn't reproduce on MariaDB 10.2.7 with wsrep_slave_threads>1*
            *err.log*
            {code:java}
            [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
                     at galera/src/trx_handle.cpp:apply():351
            {code}

            *Reproduce*
            *wsrep_slave_threads>1*
            {code:java}
            CREATE TABLE `p` (
              `id` int(11) NOT NULL,
              `a` varchar(33) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
              PRIMARY KEY (`id`)
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ;

            CREATE TABLE `f` (
              `id` int(11) NOT NULL,
              `f_id` int(11) DEFAULT NULL,
              KEY `f_id` (`f_id`),
              CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ;

            insert into p select 1,'aaa';

            insert into f select 1,1;

            #Repeatedly execute the following SQL until you generate thousands of data
            insert into f select a.id + b.a,a.f_id from f a join (select max(id) as a from f b) b on 1=1;

            select count(*) from f;
            +----------+
            | count(*) |
            +----------+
            | 131072 |
            +----------+

            #Slave node, no matter wsrep_slave_fk_checks is on or off.
            show variables like 'wsrep_slave_fk_checks';
            +-----------------------+-------+
            | Variable_name | Value |
            +-----------------------+-------+
            | wsrep_slave_fk_checks | ON |
            +-----------------------+-------+

            #Master (Write) node
            delete from f;delete from p;

            #Slave node down and got errors
            2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
                     at galera/src/trx_handle.cpp:apply():351
            Retrying 2th time
            2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
                     at galera/src/trx_handle.cpp:apply():351
            Retrying 3th time
            2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: Failed to apply app buffer: seqno: 128, status: 1
                     at galera/src/trx_handle.cpp:apply():351
            Retrying 4th time
            2018-03-16 14:33:39 140457990018816 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table aaa.p; Cannot delete or update a parent row: a foreign key constraint fails (`aaa`.`f`, CONSTRAINT `f_ibfk_1` FOREIGN KEY (`f_id`) REFERENCES `p` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 108, Internal MariaDB error code: 1451
            2018-03-16 14:33:39 140457990018816 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 128
            2018-03-16 14:33:39 140457990018816 [ERROR] WSREP: Failed to apply trx: source: 849e805c-1dd2-11e8-aa79-eb31f2b81368 version: 3 local: 0 state: APPLYING flags: 1 conn_id: 87 trx_id: 12277 seqnos (l: 33, g: 128, s: 127, d: 126, ts: 1358419270394303)
            2018-03-16 14:33:39 140457990018816 [ERROR] WSREP: Failed to apply trx 128 4 times
            2018-03-16 14:33:39 140457990018816 [ERROR] WSREP: Node consistency compromised, aborting...

            #Slave processlist
            #Write set 127 is "delete from f;"
            #Write set 128 is "delete from p;"
            #Slave concurrently apply the two sql
             !image-2018-03-21-10-45-36-084.png|thumbnail!
            {code}

            *This error didn't reproduce on MariaDB 10.2.7 with wsrep_slave_threads>1*
            elenst Elena Stepanova made changes -
            Fix Version/s 10.2 [ 14601 ]
            Assignee Sachin Setiya [ sachin.setiya.007 ]
            Priority Blocker [ 1 ] Critical [ 2 ]
            sachin.setiya.007 Sachin Setiya (Inactive) made changes -
            Attachment galera_mdev_15611.cnf [ 45420 ]
            Attachment galera_mdev_15611.test [ 45421 ]

            Thanks for the test case I am looking into it galera_mdev_15611.cnf galera_mdev_15611.test

            sachin.setiya.007 Sachin Setiya (Inactive) added a comment - Thanks for the test case I am looking into it galera_mdev_15611.cnf galera_mdev_15611.test

            Actually I am not sure if this is bug or not, If we try to try to increase the may_apply_attempts

            diff --git a/galera/src/replicator_smm.cpp b/galera/src/replicator_smm.cpp
            index 48026f5..a45ee16 100644
            --- a/galera/src/replicator_smm.cpp
            +++ b/galera/src/replicator_smm.cpp
            @@ -24,7 +24,7 @@ apply_trx_ws(void*                    recv_ctx,
                          const wsrep_trx_meta_t&  meta)
             {
                 using galera::TrxHandle;
            -    static const size_t max_apply_attempts(4);
            +    static const size_t max_apply_attempts(100);
                 size_t attempts(1);
             
                 do
            

            We can make the test case to pass.
            Hi seppo what you think ?

            sachin.setiya.007 Sachin Setiya (Inactive) added a comment - Actually I am not sure if this is bug or not, If we try to try to increase the may_apply_attempts diff --git a/galera/src/replicator_smm.cpp b/galera/src/replicator_smm.cpp index 48026f5..a45ee16 100644 --- a/galera/src/replicator_smm.cpp +++ b/galera/src/replicator_smm.cpp @@ - 24 , 7 + 24 , 7 @@ apply_trx_ws( void * recv_ctx, const wsrep_trx_meta_t& meta) { using galera::TrxHandle; - static const size_t max_apply_attempts( 4 ); + static const size_t max_apply_attempts( 100 ); size_t attempts( 1 );   do We can make the test case to pass. Hi seppo what you think ?

            Actually we don't need complicated insert
            Even normal insert fails

            --source include/galera_cluster.inc
            --source include/have_innodb.inc
             
            --connection node_1
            CREATE TABLE t1 (
              id int primary key
            );
             
            CREATE TABLE t2 (
              id int primary key ,
              f_id int DEFAULT NULL, FOREIGN KEY(f_id)  REFERENCES t1 (id)
            );
             
            insert into t1 select 1;
             
            --let $count=200
            while($count)
            {
              #Repeatedly execute the following SQL until you generate thousands of data
              --eval insert into t2 values ($count, 1);
              --dec $count
            }
             
            select count(*) from t1;
            delete from t2;
            delete from t1;
            
            

            If we remove primary key from t2 then it will make slave node (node 2) to crash , with primary key , node 2 is aborted , which is not the correct behaviour

            sachin.setiya.007 Sachin Setiya (Inactive) added a comment - Actually we don't need complicated insert Even normal insert fails --source include/galera_cluster.inc --source include/have_innodb.inc   --connection node_1 CREATE TABLE t1 ( id int primary key );   CREATE TABLE t2 ( id int primary key , f_id int DEFAULT NULL , FOREIGN KEY (f_id) REFERENCES t1 (id) );   insert into t1 select 1;   --let $count=200 while($ count ) { #Repeatedly execute the following SQL until you generate thousands of data --eval insert into t2 values ($count, 1); --dec $count }   select count (*) from t1; delete from t2; delete from t1; If we remove primary key from t2 then it will make slave node (node 2) to crash , with primary key , node 2 is aborted , which is not the correct behaviour

            Comment from seppo

            I did some FK experiments with MariaDB 10.2 (latest development HEAD), and it turns out that, for an child table delete, only child table key is pushed into write set
            this means that the reference to the parent table row is not present in the write set at all. And therefore parallel applying allows processing parent table delete in parallel with child table delete

            sachin.setiya.007 Sachin Setiya (Inactive) added a comment - Comment from seppo I did some FK experiments with MariaDB 10.2 (latest development HEAD), and it turns out that, for an child table delete, only child table key is pushed into write set this means that the reference to the parent table row is not present in the write set at all. And therefore parallel applying allows processing parent table delete in parallel with child table delete
            920895156@qq.com Devin Yu added a comment -

            Table t2 without PK, the purpose is to let "be removed from t2;" perform slowly, so slave can apply "delete from t2;" and "delete from t1;" concurrently .
            There is a PK in the table of my real environment where we encountered this bug.
            BTW, the two SQL can't be in the same transaction, because the granularity of concurrency is transaction
            Please redo this test in MariaDB 10.2.7, will never reproduce this bug no matter there is a PK in t2 or not.

            Thank you.

            920895156@qq.com Devin Yu added a comment - Table t2 without PK, the purpose is to let "be removed from t2;" perform slowly, so slave can apply "delete from t2;" and "delete from t1;" concurrently . There is a PK in the table of my real environment where we encountered this bug. BTW, the two SQL can't be in the same transaction, because the granularity of concurrency is transaction Please redo this test in MariaDB 10.2.7, will never reproduce this bug no matter there is a PK in t2 or not. Thank you.

            Hi 920895156@qq.com ,

            Thanks for reminding that it does not fail in 10.2.7 , I have run git bisect and 2f342c450755fe7b6c39ec69930d240047c8242d is first bad commit, I am trying to understand what is does

            sachin.setiya.007 Sachin Setiya (Inactive) added a comment - Hi 920895156@qq.com , Thanks for reminding that it does not fail in 10.2.7 , I have run git bisect and 2f342c450755fe7b6c39ec69930d240047c8242d is first bad commit, I am trying to understand what is does
            sachin.setiya.007 Sachin Setiya (Inactive) added a comment - Patch link http://lists.askmonty.org/pipermail/commits/2018-April/012274.html
            sachin.setiya.007 Sachin Setiya (Inactive) made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            sachin.setiya.007 Sachin Setiya (Inactive) made changes -
            Assignee Sachin Setiya [ sachin.setiya.007 ] Marko Mäkelä [ marko ]
            Status In Progress [ 3 ] In Review [ 10002 ]
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -
            marko Marko Mäkelä made changes -

            The submitted patch would seem to reintroduce MDEV-13498, because the Galera adjustments would be executed even when Galera is disabled (!wsrep_on_trx(trx)).

            The function wsrep_must_process_fk() was introduced in MDEV-13498/MDEV-13246 and subsequently changed in MDEV-13678.

            sachin.setiya.007, in which exact code revisions can the failure be repeated? Note that MDEV-14222 (MariaDB 10.2.13) changed some FOREIGN KEY processing by reverting a change that was made in MySQL 5.7.2 and reverted in 5.7.21.

            marko Marko Mäkelä added a comment - The submitted patch would seem to reintroduce MDEV-13498 , because the Galera adjustments would be executed even when Galera is disabled ( !wsrep_on_trx(trx) ). The function wsrep_must_process_fk() was introduced in MDEV-13498 / MDEV-13246 and subsequently changed in MDEV-13678 . sachin.setiya.007 , in which exact code revisions can the failure be repeated? Note that MDEV-14222 (MariaDB 10.2.13) changed some FOREIGN KEY processing by reverting a change that was made in MySQL 5.7.2 and reverted in 5.7.21.
            marko Marko Mäkelä made changes -

            I think that the predicate should be rewritten like this:

            inline bool wsrep_must_process_fk(const upd_node_t* node, const trx_t* trx)
            {
            	if (!wsrep_on_trx(trx)) {
            		return false;
            	}
            	return que_node_get_type(node->common.parent) != QUE_NODE_UPDATE
            		|| static_cast<upd_node_t*>(node->common.parent)->cascade_node
            		!= node;
            }
            

            That is, the condition on WSREP_ON is preserved, but the condition on node is negated.

            marko Marko Mäkelä added a comment - I think that the predicate should be rewritten like this: inline bool wsrep_must_process_fk( const upd_node_t* node, const trx_t* trx) { if (!wsrep_on_trx(trx)) { return false ; } return que_node_get_type(node->common.parent) != QUE_NODE_UPDATE || static_cast <upd_node_t*>(node->common.parent)->cascade_node != node; } That is, the condition on WSREP_ON is preserved, but the condition on node is negated.
            marko Marko Mäkelä made changes -
            Assignee Marko Mäkelä [ marko ] Sachin Setiya [ sachin.setiya.007 ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            marko Marko Mäkelä made changes -
            Affects Version/s 10.3.1 [ 22532 ]
            Affects Version/s 10.2.8 [ 22544 ]
            marko Marko Mäkelä made changes -
            Fix Version/s 10.3 [ 22126 ]

            Hi Marko!

            Thanks for the review,
            The issue was introduced in 2f342c4 to all version upto 10.2

            sachin.setiya.007 Sachin Setiya (Inactive) added a comment - Hi Marko! Thanks for the review, The issue was introduced in 2f342c4 to all version upto 10.2

            Hi Marko!

            I pushed it into bb-mdev-15611 branch.

            sachin.setiya.007 Sachin Setiya (Inactive) added a comment - Hi Marko! I pushed it into bb-mdev-15611 branch.
            sachin.setiya.007 Sachin Setiya (Inactive) made changes -
            Fix Version/s 10.2.15 [ 23006 ]
            Fix Version/s 10.2 [ 14601 ]
            Fix Version/s 10.3 [ 22126 ]
            Resolution Fixed [ 1 ]
            Status Stalled [ 10000 ] Closed [ 6 ]
            sachin.setiya.007 Sachin Setiya (Inactive) made changes -

            Is there a fix for MariaDB 10.1?

            tanj Guillaume Lefranc added a comment - Is there a fix for MariaDB 10.1?
            jplindst Jan Lindström (Inactive) made changes -
            Fix Version/s 10.1.35 [ 23116 ]
            marko Marko Mäkelä made changes -
            Assignee Sachin Setiya [ sachin.setiya.007 ] Jan Lindström [ jplindst ]
            serg Sergei Golubchik made changes -
            laocius TAO ZHOU added a comment -

            Is this already fixed. I am running 10.2.19 and still getting the same error. It didn't kill itself though.

            2019-01-09 13:51:46 50734833152 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table w2live_college.WebSiteLayout; Cannot delete or update a parent row: a foreign key constraint fails (`w2live_college`.`WebNodeType`, CONSTRAINT `WebNodeType_ibfk_1` FOREIGN KEY (`webSiteLayoutId`) REFERENCES `WebSiteLayout` (`id`)), Error_code: 1451; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 196, Internal MariaDB error code: 1451
            2019-01-09 13:51:46 50734833152 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152, 1398192281
            2019-01-09 13:51:46 50734833152 [Warning] WSREP: Failed to apply app buffer: seqno: 1398192281, status: 1
            	 at galera/src/trx_handle.cpp:apply():353
            Retrying 2th time
            

            laocius TAO ZHOU added a comment - Is this already fixed. I am running 10.2.19 and still getting the same error. It didn't kill itself though. 2019 - 01 - 09 13 : 51 : 46 50734833152 [ERROR] Slave SQL: Could not execute Delete_rows_v1 event on table w2live_college.WebSiteLayout; Cannot delete or update a parent row: a foreign key constraint fails (`w2live_college`.`WebNodeType`, CONSTRAINT `WebNodeType_ibfk_1` FOREIGN KEY (`webSiteLayoutId`) REFERENCES `WebSiteLayout` (`id`)), Error_code: 1451 ; handler error HA_ERR_ROW_IS_REFERENCED; the event's master log FIRST, end_log_pos 196 , Internal MariaDB error code: 1451 2019 - 01 - 09 13 : 51 : 46 50734833152 [Warning] WSREP: RBR event 3 Delete_rows_v1 apply warning: 152 , 1398192281 2019 - 01 - 09 13 : 51 : 46 50734833152 [Warning] WSREP: Failed to apply app buffer: seqno: 1398192281 , status: 1 at galera/src/trx_handle.cpp:apply(): 353 Retrying 2th time
            laocius TAO ZHOU added a comment -

            It's still crashing.

            laocius TAO ZHOU added a comment - It's still crashing.
            marko Marko Mäkelä made changes -
            prupert Pim Rupert made changes -
            prupert Pim Rupert made changes -
            prupert Pim Rupert made changes -
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 86114 ] MariaDB v4 [ 153988 ]
            mariadb-jira-automation Jira Automation (IT) made changes -
            Zendesk Related Tickets 134580 183212

            People

              jplindst Jan Lindström (Inactive)
              920895156@qq.com Devin Yu
              Votes:
              0 Vote for this issue
              Watchers:
              13 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.