Skip to content

Commit

Permalink
Improved MTR test "galera.galera_retry_applying" by
Browse files Browse the repository at this point in the history
moving failure inject from InnoDB code to MySQL code.
  • Loading branch information
plampio committed Jan 7, 2025
1 parent 90af31f commit a5d90f8
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 21 deletions.
6 changes: 3 additions & 3 deletions mysql-test/suite/galera/r/galera_retry_applying.result
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ INSERT INTO t3 (f1, f2) VALUES (3, 'c'), (4, 'd'), (5, 'e');
COMMIT;
connection node_2;
SET GLOBAL wsrep_applier_retry_count = 2;
SET GLOBAL debug_dbug = "d,innodb_insert_fail_once:o,/dev/null";
SET GLOBAL debug_dbug = "d,apply_event_fail_once:o,/dev/null";
CALL mtr.add_suppression("Event .* Write_rows.* apply failed");
connection node_1;
START TRANSACTION;
Expand Down Expand Up @@ -46,12 +46,12 @@ connection node_1;
SET wsrep_sync_wait=0;
CREATE TABLE t2 (f1 INTEGER PRIMARY KEY DEFAULT 0, f2 char(12));
connection node_2;
CALL mtr.add_suppression("Event .* Write_rows.* apply failed");
CALL mtr.add_suppression("Event .* Update_rows.* apply failed");
CALL mtr.add_suppression("Inconsistency detected");
CALL mtr.add_suppression("Failed to apply write set:.*");
SET GLOBAL wsrep_applier_retry_count = 2;
SET GLOBAL debug_dbug = '';
SET GLOBAL debug_dbug = "d,innodb_insert_fail_always:o,/dev/null";
SET GLOBAL debug_dbug = "d,apply_event_fail_always:o,/dev/null";
connection node_1;
START TRANSACTION;
INSERT INTO t2 (f1, f2) VALUES (1, 'a'), (2, 'b');
Expand Down
6 changes: 3 additions & 3 deletions mysql-test/suite/galera/t/galera_retry_applying.test
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ COMMIT;
--source include/wait_condition.inc

SET GLOBAL wsrep_applier_retry_count = 2;
SET GLOBAL debug_dbug = "d,innodb_insert_fail_once:o,/dev/null";
SET GLOBAL debug_dbug = "d,apply_event_fail_once:o,/dev/null";
CALL mtr.add_suppression("Event .* Write_rows.* apply failed");

--connection node_1
Expand Down Expand Up @@ -86,13 +86,13 @@ SET wsrep_sync_wait=0;
CREATE TABLE t2 (f1 INTEGER PRIMARY KEY DEFAULT 0, f2 char(12));

--connection node_2
CALL mtr.add_suppression("Event .* Write_rows.* apply failed");
CALL mtr.add_suppression("Event .* Update_rows.* apply failed");
CALL mtr.add_suppression("Inconsistency detected");
CALL mtr.add_suppression("Failed to apply write set:.*");

SET GLOBAL wsrep_applier_retry_count = 2;
SET GLOBAL debug_dbug = '';
SET GLOBAL debug_dbug = "d,innodb_insert_fail_always:o,/dev/null";
SET GLOBAL debug_dbug = "d,apply_event_fail_always:o,/dev/null";

--connection node_1
START TRANSACTION;
Expand Down
36 changes: 35 additions & 1 deletion sql/log_event_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4925,7 +4925,41 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi)
/* remove trigger's tables */
goto err;
}

#ifdef WITH_WSREP
DBUG_EXECUTE_IF("apply_event_fail_once", {
if (WSREP(thd)) {
TABLE_LIST *table_list_ptr= rgi->tables_to_lock;
for (uint i=0 ; table_list_ptr && (i < rgi->tables_to_lock_count);
table_list_ptr= table_list_ptr->next_global, i++) {
RPL_TABLE_LIST *ptr= static_cast<RPL_TABLE_LIST*>(table_list_ptr);
WSREP_INFO("DEBUG: %s: executing row event: %s.%s", __FUNCTION__,
ptr->table->s->db.str, ptr->table->s->table_name.str);
if (0 == strcmp("test", ptr->table->s->db.str)) {
error= HA_ERR_LOCK_WAIT_TIMEOUT;
thd->is_slave_error= 1;
DBUG_SET("-d,apply_event_fail_once");
goto err;
}
}
}
};);
DBUG_EXECUTE_IF("apply_event_fail_always", {
if (WSREP(thd)) {
TABLE_LIST *table_list_ptr= rgi->tables_to_lock;
for (uint i=0 ; table_list_ptr && (i < rgi->tables_to_lock_count);
table_list_ptr= table_list_ptr->next_global, i++) {
RPL_TABLE_LIST *ptr= static_cast<RPL_TABLE_LIST*>(table_list_ptr);
WSREP_INFO("DEBUG: %s: executing row event: %s.%s", __FUNCTION__,
ptr->table->s->db.str, ptr->table->s->table_name.str);
if (0 == strcmp("test", ptr->table->s->db.str)) {
error= HA_ERR_LOCK_WAIT_TIMEOUT;
thd->is_slave_error= 1;
goto err;
}
}
}
};);
#endif /* WITH_WSREP */
/*
When the open and locking succeeded, we check all tables to
ensure that they still have the correct type.
Expand Down
14 changes: 0 additions & 14 deletions storage/innobase/row/row0ins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3813,20 +3813,6 @@ row_ins_step(
do_insert:
/* DO THE CHECKS OF THE CONSISTENCY CONSTRAINTS HERE */

DBUG_EXECUTE_IF("innodb_insert_fail_once",
{
if (0 == strncmp("test/",
node->table->name.m_name, 5)) {
err = DB_LOCK_WAIT_TIMEOUT;
DBUG_SET("-d,innodb_insert_fail_once");
goto error_handling;}});
DBUG_EXECUTE_IF("innodb_insert_fail_always",
{
if (0 == strncmp("test/",
node->table->name.m_name, 5)) {
err = DB_LOCK_WAIT_TIMEOUT;
goto error_handling;}});

err = row_ins(node, thr);

error_handling:
Expand Down

0 comments on commit a5d90f8

Please sign in to comment.