Skip to content

Commit a8c9167

Browse files
sjaakolajanlindstrom
authored andcommitted
MDEV-36923 : Add warning messages for applier FK failures
Added warning messages for applier FK failures. Warnings are printed by default and can be disabled using set global wsrep_mode=APPLIER_DISABLE_FK_WARNINGS; Ported to MariaDB [email protected]
1 parent e706324 commit a8c9167

15 files changed

+249
-45
lines changed

include/mysql/service_wsrep.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ enum Wsrep_service_key_type
1414
#else
1515

1616
/* Copyright (c) 2015, 2020, MariaDB Corporation Ab
17-
2018 Codership Oy <[email protected]>
17+
2018, 2025, Codership Oy <[email protected]>
1818
1919
This program is free software; you can redistribute it and/or modify
2020
it under the terms of the GNU General Public License as published by
@@ -96,6 +96,7 @@ extern struct wsrep_service_st {
9696
void (*wsrep_thd_kill_UNLOCK_func)(const MYSQL_THD thd);
9797
void (*wsrep_thd_set_wsrep_PA_unsafe_func)(MYSQL_THD thd);
9898
uint32 (*wsrep_get_domain_id_func)();
99+
my_bool (*wsrep_applier_log_warnings)(const MYSQL_THD thd);
99100
} *wsrep_service;
100101

101102
#define MYSQL_SERVICE_WSREP_INCLUDED
@@ -146,6 +147,7 @@ extern struct wsrep_service_st {
146147
#define wsrep_report_bf_lock_wait(T,I) wsrep_service->wsrep_report_bf_lock_wait(T,I)
147148
#define wsrep_thd_set_PA_unsafe(T) wsrep_service->wsrep_thd_set_PA_unsafe_func(T)
148149
#define wsrep_get_domain_id(T) wsrep_service->wsrep_get_domain_id_func(T)
150+
#define wsrep_applier_log_warnings(T) wsrep_service->wsrep_applier_log_warnings_func(T)
149151
#else
150152

151153
#define MYSQL_SERVICE_WSREP_STATIC_INCLUDED
@@ -256,5 +258,6 @@ extern "C" void wsrep_report_bf_lock_wait(const THD *thd,
256258
/* declare parallel applying unsafety for the THD */
257259
extern "C" void wsrep_thd_set_PA_unsafe(MYSQL_THD thd);
258260
extern "C" uint32 wsrep_get_domain_id();
261+
extern "C" my_bool wsrep_applier_log_warnings(const MYSQL_THD thd);
259262
#endif
260263
#endif /* MYSQL_SERVICE_WSREP_INCLUDED */

mysql-test/suite/galera/r/MW-369.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ SET SESSION DEBUG_SYNC = 'now SIGNAL signal.wsrep_apply_cb';
258258
SET GLOBAL DEBUG_DBUG = "";
259259
SET DEBUG_SYNC = 'RESET';
260260
connection node_1;
261+
call mtr.add_suppression("WSREP: Foreign key check table:.*");
261262
connection node_2;
262263
SELECT * FROM pg;
263264
f1 f2

mysql-test/suite/galera/r/galera_FK_duplicate_client_insert.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,3 +380,4 @@ truncate user_session;
380380
set debug_sync = reset;
381381
connection node_1;
382382
drop table user_session,user;
383+
call mtr.add_suppression("WSREP: Foreign key check table:.*");

mysql-test/suite/galera/r/galera_var_wsrep_mode.result

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ SET GLOBAL wsrep_mode='A';
2020
ERROR 42000: Variable 'wsrep_mode' can't be set to the value of 'A'
2121
SET GLOBAL wsrep_mode=NULL;
2222
ERROR 42000: Variable 'wsrep_mode' can't be set to the value of 'NULL'
23-
SET GLOBAL wsrep_mode=128;
24-
ERROR 42000: Variable 'wsrep_mode' can't be set to the value of '128'
23+
SET GLOBAL wsrep_mode=65536;
24+
ERROR 42000: Variable 'wsrep_mode' can't be set to the value of '65536'
2525
SET GLOBAL wsrep_mode=REQUIRED_PRIMARY_KEY,REPLICATE_MYISAM;
2626
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
2727
SET GLOBAL wsrep_mode=1;
@@ -56,6 +56,10 @@ SET GLOBAL wsrep_mode=REPLICATE_ARIA;
5656
SELECT @@wsrep_mode;
5757
@@wsrep_mode
5858
REPLICATE_ARIA
59+
SET GLOBAL wsrep_mode=APPLIER_DISABLE_FK_WARNINGS;
60+
SELECT @@wsrep_mode;
61+
@@wsrep_mode
62+
APPLIER_DISABLE_FK_WARNINGS
5963
SET GLOBAL wsrep_mode=DISALLOW_LOCAL_GTID;
6064
SELECT @@wsrep_mode;
6165
@@wsrep_mode

mysql-test/suite/galera/t/MW-369.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ INSERT INTO pg VALUES (2, 0);
333333
# Commit succeeds
334334
--connection node_1
335335
--reap
336+
call mtr.add_suppression("WSREP: Foreign key check table:.*");
336337

337338
--connection node_2
338339
SELECT * FROM pg;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[no_warnigs]
2+
wsrep-mode=APPLIER_DISABLE_FK_WARNINGS
3+
4+
[warnings]
5+
wsrep-mode=0

mysql-test/suite/galera/t/galera_FK_duplicate_client_insert.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,5 @@ while($counter > 0)
159159
--connection node_1
160160

161161
drop table user_session,user;
162+
163+
call mtr.add_suppression("WSREP: Foreign key check table:.*");

mysql-test/suite/galera/t/galera_var_wsrep_mode.test

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ SET GLOBAL wsrep_mode='A';
2222
--error ER_WRONG_VALUE_FOR_VAR
2323
SET GLOBAL wsrep_mode=NULL;
2424
--error ER_WRONG_VALUE_FOR_VAR
25-
SET GLOBAL wsrep_mode=128;
25+
SET GLOBAL wsrep_mode=65536;
2626
--error ER_PARSE_ERROR
2727
SET GLOBAL wsrep_mode=REQUIRED_PRIMARY_KEY,REPLICATE_MYISAM;
2828
#
@@ -44,8 +44,11 @@ SET GLOBAL wsrep_mode=REPLICATE_MYISAM;
4444
SELECT @@wsrep_mode;
4545
SET GLOBAL wsrep_mode=REPLICATE_ARIA;
4646
SELECT @@wsrep_mode;
47+
SET GLOBAL wsrep_mode=APPLIER_DISABLE_FK_WARNINGS;
48+
SELECT @@wsrep_mode;
4749
SET GLOBAL wsrep_mode=DISALLOW_LOCAL_GTID;
4850
SELECT @@wsrep_mode;
51+
4952
SET GLOBAL wsrep_mode='STRICT_REPLICATION,BINLOG_ROW_FORMAT_ONLY';
5053
SELECT @@wsrep_mode;
5154
SET GLOBAL wsrep_mode='STRICT_REPLICATION,BINLOG_ROW_FORMAT_ONLY,REQUIRED_PRIMARY_KEY,REPLICATE_MYISAM,REPLICATE_ARIA,DISALLOW_LOCAL_GTID';

mysql-test/suite/sys_vars/r/sysvars_wsrep.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ VARIABLE_COMMENT Set of WSREP features that are enabled.
342342
NUMERIC_MIN_VALUE NULL
343343
NUMERIC_MAX_VALUE NULL
344344
NUMERIC_BLOCK_SIZE NULL
345-
ENUM_VALUE_LIST STRICT_REPLICATION,BINLOG_ROW_FORMAT_ONLY,REQUIRED_PRIMARY_KEY,REPLICATE_MYISAM,REPLICATE_ARIA,DISALLOW_LOCAL_GTID,BF_ABORT_MARIABACKUP
345+
ENUM_VALUE_LIST STRICT_REPLICATION,BINLOG_ROW_FORMAT_ONLY,REQUIRED_PRIMARY_KEY,REPLICATE_MYISAM,REPLICATE_ARIA,DISALLOW_LOCAL_GTID,BF_ABORT_MARIABACKUP,APPLIER_DISABLE_FK_WARNINGS
346346
READ_ONLY NO
347347
COMMAND_LINE_ARGUMENT REQUIRED
348348
GLOBAL_VALUE_PATH NULL

sql/service_wsrep.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,3 +418,13 @@ extern "C" my_bool wsrep_thd_is_local_transaction(const THD *thd)
418418
return (wsrep_thd_is_local(thd) &&
419419
thd->wsrep_cs().transaction().active());
420420
}
421+
422+
extern "C" my_bool wsrep_applier_log_warnings(const THD *thd)
423+
{
424+
/* Applier will log warning on fk errors if
425+
(1) wsrep_mode != WSREP_MODE_APPLIER_DISABLE_WARNINGS AND
426+
(2) thd executing is applier
427+
*/
428+
return (!wsrep_check_mode(WSREP_MODE_APPLIER_DISABLE_WARNINGS) &&
429+
thd->wsrep_cs().mode() == wsrep::client_state::m_high_priority);
430+
}

0 commit comments

Comments
 (0)