From 096b58a0bff7e5741d3fe6351c3f80c10e5e0cef Mon Sep 17 00:00:00 2001 From: Alexey Yurchenko Date: Tue, 10 Feb 2026 19:56:58 +0100 Subject: [PATCH] MDEV-38787 wsrep_slave_fk_checks=OFF results in inconsistency Since ATM wsrep does not replicate any cascaded changes (because they are not binlogged in the upstream code) we have to rely on foreign checks on replicas to reproduce the cascade. Thus setting wsrep_slave_fk_checks=OFF will result in inconsistency in any setup where there are cascading relations. Mark this option as deprecated and make it a NOOP. --- mysql-test/suite/sys_vars/r/sysvars_wsrep.result | 2 +- .../sys_vars/r/wsrep_slave_fk_checks_basic.result | 12 ++++++++++++ sql/sys_vars.cc | 5 +++-- sql/wsrep_high_priority_service.cc | 5 +---- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/mysql-test/suite/sys_vars/r/sysvars_wsrep.result b/mysql-test/suite/sys_vars/r/sysvars_wsrep.result index 6c584e190f13c..0d9b6b9268263 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_wsrep.result +++ b/mysql-test/suite/sys_vars/r/sysvars_wsrep.result @@ -578,7 +578,7 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE ON VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT Should slave thread do foreign key constraint checks +VARIABLE_COMMENT Should slave thread do foreign key constraint checks (deprecated, has no effect) NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL diff --git a/mysql-test/suite/sys_vars/r/wsrep_slave_fk_checks_basic.result b/mysql-test/suite/sys_vars/r/wsrep_slave_fk_checks_basic.result index 40b3270e22114..ad6b77c9df6c8 100644 --- a/mysql-test/suite/sys_vars/r/wsrep_slave_fk_checks_basic.result +++ b/mysql-test/suite/sys_vars/r/wsrep_slave_fk_checks_basic.result @@ -12,24 +12,34 @@ SELECT @@global.wsrep_slave_fk_checks; SELECT @@session.wsrep_slave_fk_checks; ERROR HY000: Variable 'wsrep_slave_FK_checks' is a GLOBAL variable SET @@global.wsrep_slave_fk_checks=OFF; +Warnings: +Warning 1287 '@@wsrep_slave_FK_checks' is deprecated and will be removed in a future release SELECT @@global.wsrep_slave_fk_checks; @@global.wsrep_slave_fk_checks 0 SET @@global.wsrep_slave_fk_checks=ON; +Warnings: +Warning 1287 '@@wsrep_slave_FK_checks' is deprecated and will be removed in a future release SELECT @@global.wsrep_slave_fk_checks; @@global.wsrep_slave_fk_checks 1 # valid values SET @@global.wsrep_slave_fk_checks='OFF'; +Warnings: +Warning 1287 '@@wsrep_slave_FK_checks' is deprecated and will be removed in a future release SELECT @@global.wsrep_slave_fk_checks; @@global.wsrep_slave_fk_checks 0 SET @@global.wsrep_slave_fk_checks=ON; +Warnings: +Warning 1287 '@@wsrep_slave_FK_checks' is deprecated and will be removed in a future release SELECT @@global.wsrep_slave_fk_checks; @@global.wsrep_slave_fk_checks 1 SET @@global.wsrep_slave_fk_checks=default; +Warnings: +Warning 1287 '@@wsrep_slave_FK_checks' is deprecated and will be removed in a future release SELECT @@global.wsrep_slave_fk_checks; @@global.wsrep_slave_fk_checks 1 @@ -42,4 +52,6 @@ ERROR 42000: Variable 'wsrep_slave_FK_checks' can't be set to the value of 'junk # restore the initial value SET @@global.wsrep_slave_fk_checks = @wsrep_slave_fk_checks_global_saved; +Warnings: +Warning 1287 '@@wsrep_slave_FK_checks' is deprecated and will be removed in a future release # End of test diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 5fe3eb4586b20..79cb29056cf50 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -6195,9 +6195,10 @@ static Sys_var_mybool Sys_wsrep_load_data_splitting( static Sys_var_mybool Sys_wsrep_slave_FK_checks( "wsrep_slave_FK_checks", "Should slave thread do " - "foreign key constraint checks", + "foreign key constraint checks (deprecated, has no effect)", GLOBAL_VAR(wsrep_slave_FK_checks), - CMD_LINE(OPT_ARG), DEFAULT(TRUE)); + CMD_LINE(OPT_ARG), DEFAULT(TRUE), NO_MUTEX_GUARD, NOT_IN_BINLOG, + ON_CHECK(0), ON_UPDATE(0), DEPRECATED("")); // since 10.6.26 static Sys_var_mybool Sys_wsrep_slave_UK_checks( "wsrep_slave_UK_checks", "Should slave thread do " diff --git a/sql/wsrep_high_priority_service.cc b/sql/wsrep_high_priority_service.cc index ce3459db08e0e..8aef448db26d7 100644 --- a/sql/wsrep_high_priority_service.cc +++ b/sql/wsrep_high_priority_service.cc @@ -114,10 +114,7 @@ static void wsrep_setup_uk_and_fk_checks(THD* thd) else thd->variables.option_bits&= ~OPTION_RELAXED_UNIQUE_CHECKS; - if (wsrep_slave_FK_checks == FALSE) - thd->variables.option_bits|= OPTION_NO_FOREIGN_KEY_CHECKS; - else - thd->variables.option_bits&= ~OPTION_NO_FOREIGN_KEY_CHECKS; + thd->variables.option_bits&= ~OPTION_NO_FOREIGN_KEY_CHECKS; } static int apply_events(THD* thd,