diff --git a/include/mysql/service_wsrep.h b/include/mysql/service_wsrep.h index cf94364c1cf82..3994ba8b59862 100644 --- a/include/mysql/service_wsrep.h +++ b/include/mysql/service_wsrep.h @@ -14,7 +14,7 @@ enum Wsrep_service_key_type #else /* Copyright (c) 2015, 2020, MariaDB Corporation Ab - 2018 Codership Oy + 2018, 2025, Codership Oy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -96,6 +96,7 @@ extern struct wsrep_service_st { void (*wsrep_thd_kill_UNLOCK_func)(const MYSQL_THD thd); void (*wsrep_thd_set_wsrep_PA_unsafe_func)(MYSQL_THD thd); uint32 (*wsrep_get_domain_id_func)(); + my_bool (*wsrep_applier_log_warnings)(const MYSQL_THD thd); } *wsrep_service; #define MYSQL_SERVICE_WSREP_INCLUDED @@ -146,6 +147,7 @@ extern struct wsrep_service_st { #define wsrep_report_bf_lock_wait(T,I) wsrep_service->wsrep_report_bf_lock_wait(T,I) #define wsrep_thd_set_PA_unsafe(T) wsrep_service->wsrep_thd_set_PA_unsafe_func(T) #define wsrep_get_domain_id(T) wsrep_service->wsrep_get_domain_id_func(T) +#define wsrep_applier_log_warnings(T) wsrep_service->wsrep_applier_log_warnings_func(T) #else #define MYSQL_SERVICE_WSREP_STATIC_INCLUDED @@ -256,5 +258,6 @@ extern "C" void wsrep_report_bf_lock_wait(const THD *thd, /* declare parallel applying unsafety for the THD */ extern "C" void wsrep_thd_set_PA_unsafe(MYSQL_THD thd); extern "C" uint32 wsrep_get_domain_id(); +extern "C" my_bool wsrep_applier_log_warnings(const MYSQL_THD thd); #endif #endif /* MYSQL_SERVICE_WSREP_INCLUDED */ diff --git a/mysql-test/suite/galera/r/MW-369.result b/mysql-test/suite/galera/r/MW-369.result index 4c487c570305f..cccc9260d756e 100644 --- a/mysql-test/suite/galera/r/MW-369.result +++ b/mysql-test/suite/galera/r/MW-369.result @@ -258,6 +258,7 @@ SET SESSION DEBUG_SYNC = 'now SIGNAL signal.wsrep_apply_cb'; SET GLOBAL DEBUG_DBUG = ""; SET DEBUG_SYNC = 'RESET'; connection node_1; +call mtr.add_suppression("WSREP: Foreign key check table:.*"); connection node_2; SELECT * FROM pg; f1 f2 diff --git a/mysql-test/suite/galera/r/galera_FK_duplicate_client_insert.result b/mysql-test/suite/galera/r/galera_FK_duplicate_client_insert.result index b40c57c5d9021..3993abfc3700d 100644 --- a/mysql-test/suite/galera/r/galera_FK_duplicate_client_insert.result +++ b/mysql-test/suite/galera/r/galera_FK_duplicate_client_insert.result @@ -380,3 +380,4 @@ truncate user_session; set debug_sync = reset; connection node_1; drop table user_session,user; +call mtr.add_suppression("WSREP: Foreign key check table:.*"); diff --git a/mysql-test/suite/galera/r/galera_var_wsrep_mode.result b/mysql-test/suite/galera/r/galera_var_wsrep_mode.result index b5b33fe8ae597..51bb5bedee750 100644 --- a/mysql-test/suite/galera/r/galera_var_wsrep_mode.result +++ b/mysql-test/suite/galera/r/galera_var_wsrep_mode.result @@ -20,8 +20,8 @@ SET GLOBAL wsrep_mode='A'; ERROR 42000: Variable 'wsrep_mode' can't be set to the value of 'A' SET GLOBAL wsrep_mode=NULL; ERROR 42000: Variable 'wsrep_mode' can't be set to the value of 'NULL' -SET GLOBAL wsrep_mode=128; -ERROR 42000: Variable 'wsrep_mode' can't be set to the value of '128' +SET GLOBAL wsrep_mode=65536; +ERROR 42000: Variable 'wsrep_mode' can't be set to the value of '65536' SET GLOBAL wsrep_mode=REQUIRED_PRIMARY_KEY,REPLICATE_MYISAM; 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 SET GLOBAL wsrep_mode=1; @@ -56,6 +56,10 @@ SET GLOBAL wsrep_mode=REPLICATE_ARIA; SELECT @@wsrep_mode; @@wsrep_mode REPLICATE_ARIA +SET GLOBAL wsrep_mode=APPLIER_DISABLE_FK_WARNINGS; +SELECT @@wsrep_mode; +@@wsrep_mode +APPLIER_DISABLE_FK_WARNINGS SET GLOBAL wsrep_mode=DISALLOW_LOCAL_GTID; SELECT @@wsrep_mode; @@wsrep_mode diff --git a/mysql-test/suite/galera/t/MW-369.test b/mysql-test/suite/galera/t/MW-369.test index 157993a3eb448..1bfead2b11642 100644 --- a/mysql-test/suite/galera/t/MW-369.test +++ b/mysql-test/suite/galera/t/MW-369.test @@ -333,6 +333,7 @@ INSERT INTO pg VALUES (2, 0); # Commit succeeds --connection node_1 --reap +call mtr.add_suppression("WSREP: Foreign key check table:.*"); --connection node_2 SELECT * FROM pg; diff --git a/mysql-test/suite/galera/t/galera_FK_duplicate_client_insert.combinations b/mysql-test/suite/galera/t/galera_FK_duplicate_client_insert.combinations new file mode 100644 index 0000000000000..af0656dd33537 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_FK_duplicate_client_insert.combinations @@ -0,0 +1,5 @@ +[no_warnigs] +wsrep-mode=APPLIER_DISABLE_FK_WARNINGS + +[warnings] +wsrep-mode=0 diff --git a/mysql-test/suite/galera/t/galera_FK_duplicate_client_insert.test b/mysql-test/suite/galera/t/galera_FK_duplicate_client_insert.test index 6dd1fee1d4e80..4ed5ec62b50d6 100644 --- a/mysql-test/suite/galera/t/galera_FK_duplicate_client_insert.test +++ b/mysql-test/suite/galera/t/galera_FK_duplicate_client_insert.test @@ -159,3 +159,5 @@ while($counter > 0) --connection node_1 drop table user_session,user; + +call mtr.add_suppression("WSREP: Foreign key check table:.*"); diff --git a/mysql-test/suite/galera/t/galera_var_wsrep_mode.test b/mysql-test/suite/galera/t/galera_var_wsrep_mode.test index fdb033b08741b..6ba680e334cc3 100644 --- a/mysql-test/suite/galera/t/galera_var_wsrep_mode.test +++ b/mysql-test/suite/galera/t/galera_var_wsrep_mode.test @@ -22,7 +22,7 @@ SET GLOBAL wsrep_mode='A'; --error ER_WRONG_VALUE_FOR_VAR SET GLOBAL wsrep_mode=NULL; --error ER_WRONG_VALUE_FOR_VAR -SET GLOBAL wsrep_mode=128; +SET GLOBAL wsrep_mode=65536; --error ER_PARSE_ERROR SET GLOBAL wsrep_mode=REQUIRED_PRIMARY_KEY,REPLICATE_MYISAM; # @@ -44,8 +44,11 @@ SET GLOBAL wsrep_mode=REPLICATE_MYISAM; SELECT @@wsrep_mode; SET GLOBAL wsrep_mode=REPLICATE_ARIA; SELECT @@wsrep_mode; +SET GLOBAL wsrep_mode=APPLIER_DISABLE_FK_WARNINGS; +SELECT @@wsrep_mode; SET GLOBAL wsrep_mode=DISALLOW_LOCAL_GTID; SELECT @@wsrep_mode; + SET GLOBAL wsrep_mode='STRICT_REPLICATION,BINLOG_ROW_FORMAT_ONLY'; SELECT @@wsrep_mode; SET GLOBAL wsrep_mode='STRICT_REPLICATION,BINLOG_ROW_FORMAT_ONLY,REQUIRED_PRIMARY_KEY,REPLICATE_MYISAM,REPLICATE_ARIA,DISALLOW_LOCAL_GTID'; diff --git a/mysql-test/suite/sys_vars/r/sysvars_wsrep.result b/mysql-test/suite/sys_vars/r/sysvars_wsrep.result index 6c584e190f13c..fb2bd9a45b6ad 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_wsrep.result +++ b/mysql-test/suite/sys_vars/r/sysvars_wsrep.result @@ -342,7 +342,7 @@ VARIABLE_COMMENT Set of WSREP features that are enabled. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST STRICT_REPLICATION,BINLOG_ROW_FORMAT_ONLY,REQUIRED_PRIMARY_KEY,REPLICATE_MYISAM,REPLICATE_ARIA,DISALLOW_LOCAL_GTID,BF_ABORT_MARIABACKUP +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 READ_ONLY NO COMMAND_LINE_ARGUMENT REQUIRED GLOBAL_VALUE_PATH NULL diff --git a/sql/service_wsrep.cc b/sql/service_wsrep.cc index 9d04849aadbeb..16aa40a305576 100644 --- a/sql/service_wsrep.cc +++ b/sql/service_wsrep.cc @@ -418,3 +418,13 @@ extern "C" my_bool wsrep_thd_is_local_transaction(const THD *thd) return (wsrep_thd_is_local(thd) && thd->wsrep_cs().transaction().active()); } + +extern "C" my_bool wsrep_applier_log_warnings(const THD *thd) +{ + /* Applier will log warning on fk errors if + (1) wsrep_mode != WSREP_MODE_APPLIER_DISABLE_WARNINGS AND + (2) thd executing is applier + */ + return (!wsrep_check_mode(WSREP_MODE_APPLIER_DISABLE_WARNINGS) && + thd->wsrep_cs().mode() == wsrep::client_state::m_high_priority); +} diff --git a/sql/sql_plugin_services.inl b/sql/sql_plugin_services.inl index 9acd34190e4de..a3335660463e9 100644 --- a/sql/sql_plugin_services.inl +++ b/sql/sql_plugin_services.inl @@ -185,7 +185,8 @@ static struct wsrep_service_st wsrep_handler = { wsrep_thd_kill_LOCK, wsrep_thd_kill_UNLOCK, wsrep_thd_set_PA_unsafe, - wsrep_get_domain_id + wsrep_get_domain_id, + wsrep_applier_log_warnings }; static struct thd_specifics_service_st thd_specifics_handler= diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 5fe3eb4586b20..2f620bdd7fe1f 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -6111,6 +6111,7 @@ static const char *wsrep_mode_names[]= "REPLICATE_ARIA", "DISALLOW_LOCAL_GTID", "BF_ABORT_MARIABACKUP", + "APPLIER_DISABLE_FK_WARNINGS", NullS }; static Sys_var_set Sys_wsrep_mode( diff --git a/sql/wsrep_dummy.cc b/sql/wsrep_dummy.cc index 8762dd9907e19..11b845140da61 100644 --- a/sql/wsrep_dummy.cc +++ b/sql/wsrep_dummy.cc @@ -169,3 +169,6 @@ void wsrep_thd_set_PA_unsafe(THD*) uint32 wsrep_get_domain_id() { return 0;} + +my_bool wsrep_applier_log_warnings(const THD*) +{ return 0;} diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index 389bedda30ad3..aa072f2b2d326 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -1,4 +1,4 @@ -/* Copyright 2008-2023 Codership Oy +/* Copyright 2008-2025 Codership Oy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -131,7 +131,8 @@ enum enum_wsrep_mode { WSREP_MODE_REPLICATE_MYISAM= (1ULL << 3), WSREP_MODE_REPLICATE_ARIA= (1ULL << 4), WSREP_MODE_DISALLOW_LOCAL_GTID= (1ULL << 5), - WSREP_MODE_BF_MARIABACKUP= (1ULL << 6) + WSREP_MODE_BF_MARIABACKUP= (1ULL << 6), + WSREP_MODE_APPLIER_DISABLE_WARNINGS= (1ULL << 7) }; // Streaming Replication diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 31cefab99cd2e..73858dad80cde 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -49,8 +49,9 @@ Created 4/20/1996 Heikki Tuuri #ifdef WITH_WSREP #include #include -#include "ha_prototypes.h" #endif /* WITH_WSREP */ +#include +#include /************************************************************************* IMPORTANT NOTE: Any operation that generates redo MUST check that there @@ -748,12 +749,12 @@ row_ins_foreign_report_err( const dtuple_t* entry) /*!< in: index entry in the parent table */ { - std::string fk_str; - if (srv_read_only_mode) { return; } + std::string fk_str; + std::string fk_table_str; FILE* ef = dict_foreign_err_file; trx_t* trx = thr_get_trx(thr); @@ -762,7 +763,8 @@ row_ins_foreign_report_err( row_ins_foreign_trx_print(trx); fputs("Foreign key constraint fails for table ", ef); - ut_print_name(ef, trx, foreign->foreign_table_name); + fk_table_str= ut_get_name(trx, foreign->foreign_table_name); + fputs(fk_table_str.c_str(), ef); fputs(":\n", ef); fk_str = dict_print_info_on_foreign_key_in_create_format(trx, foreign, TRUE); @@ -776,7 +778,7 @@ row_ins_foreign_report_err( dtuple_print(ef, entry); } fputs("\nBut in child table ", ef); - ut_print_name(ef, trx, foreign->foreign_table_name); + fputs(fk_table_str.c_str(), ef); fprintf(ef, ", in index %s", foreign->foreign_index->name()); if (rec) { fputs(", there is a record:\n", ef); @@ -786,6 +788,23 @@ row_ins_foreign_report_err( } putc('\n', ef); +#ifdef WITH_WSREP + /* Warning message for applier FK failure */ + if (trx->is_wsrep() && + wsrep_applier_log_warnings(trx->mysql_thd)) { + WSREP_WARN("Foreign key constraint fails for table %s:\n %s\n " + "%s in parent table, in index %s\nBut in child table " + "%s in index %s %s\n", + fk_table_str.c_str(), + fk_str.c_str(), + errstr, + foreign->referenced_index->name(), + fk_table_str.c_str(), + foreign->foreign_index->name(), + (rec ? ", there is a record." : ", the record is not available")); + } +#endif + mysql_mutex_unlock(&dict_foreign_err_mutex); } @@ -805,12 +824,13 @@ row_ins_foreign_report_add_err( const dtuple_t* entry) /*!< in: index entry to insert in the child table */ { - std::string fk_str; - if (srv_read_only_mode) { return; } + std::string fk_str; + std::string fk_table_str; + std::string fk_ref_table_str; FILE* ef = dict_foreign_err_file; row_ins_set_detailed(trx, foreign); @@ -818,7 +838,8 @@ row_ins_foreign_report_add_err( row_ins_foreign_trx_print(trx); fputs("Foreign key constraint fails for table ", ef); - ut_print_name(ef, trx, foreign->foreign_table_name); + fk_table_str= ut_get_name(trx, foreign->foreign_table_name); + fputs(fk_table_str.c_str(), ef); fputs(":\n", ef); fk_str = dict_print_info_on_foreign_key_in_create_format(trx, foreign, TRUE); @@ -836,7 +857,8 @@ row_ins_foreign_report_add_err( dtuple_print(ef, entry); } fputs("\nBut in parent table ", ef); - ut_print_name(ef, trx, foreign->referenced_table_name); + fk_ref_table_str= ut_get_name(trx, foreign->referenced_table_name); + fputs(fk_ref_table_str.c_str(), ef); fprintf(ef, ", in index %s,\n" "the closest match we can find is record:\n", foreign->referenced_index->name()); @@ -852,6 +874,23 @@ row_ins_foreign_report_add_err( } putc('\n', ef); +#ifdef WITH_WSREP + /* Warning message for applier FK failure */ + if (trx->is_wsrep() && + wsrep_applier_log_warnings(trx->mysql_thd)) { + WSREP_WARN("Foreign key constraint fails for table %s:\%s" + " in parent table, in index %s" + "\nBut in parent table %s, in index %s,\n" + "the closest match we can find is record: %s\n", + fk_table_str.c_str(), + fk_str.c_str(), + fk_ref_table_str.c_str(), + foreign->referenced_index->name(), + (rec && page_rec_is_supremum(rec) ? " SUPREMUM" + : (rec) ? " REC" : "NULL")); + } +#endif + mysql_mutex_unlock(&dict_foreign_err_mutex); } @@ -978,6 +1017,31 @@ dberr_t wsrep_append_foreign_key(trx_t *trx, upd_node_t* upd_node, bool pa_disable, Wsrep_service_key_type key_type); + +/** Produce warning on foreign key action that failed on applier + +@param warn_msg FK warning message +@param table Table with FK constraint +@param index FK constraint index +@param err error status +*/ +void wsrep_fk_warn(const std::string warn_msg, + const trx_t* trx, + const dict_table_t *table, + const dict_index_t *index, + const dberr_t err) +{ + std::string fk_warn= "Foreign key check table: %s index: %s failed for "; + fk_warn+= warn_msg; + fk_warn+=" err: %s"; + + std::string fk_name= ut_get_name(trx, table->name.m_name); + WSREP_WARN(fk_warn.c_str(), + fk_name.c_str(), + index->name, + ut_strerr(err)); + +} #endif /* WITH_WSREP */ /*********************************************************************//** @@ -1145,6 +1209,14 @@ row_ins_foreign_check_on_constraint( PAGE_CUR_LE, BTR_SEARCH_LEAF, cascade->pcur, mtr); if (UNIV_UNLIKELY(err != DB_SUCCESS)) { +#ifdef WITH_WSREP + /* Warning message for applier FK failure */ + if (trx->is_wsrep() && + wsrep_applier_log_warnings(trx->mysql_thd)) { + wsrep_fk_warn("look clust rec", trx, table, + clust_index, err); + } +#endif goto nonstandard_exit_func; } @@ -1189,6 +1261,14 @@ row_ins_foreign_check_on_constraint( } if (err != DB_SUCCESS) { +#ifdef WITH_WSREP + /* Warning message for applier FK failure */ + if (trx->is_wsrep() && + wsrep_applier_log_warnings(trx->mysql_thd)) { + wsrep_fk_warn("lock table", trx, table, + clust_index, err); + } +#endif goto nonstandard_exit_func; } @@ -1255,6 +1335,15 @@ row_ins_foreign_check_on_constraint( node, foreign); if (err != DB_SUCCESS) { +#ifdef WITH_WSREP + /* Warning message for applier FK failure */ + if (trx->is_wsrep() && + wsrep_applier_log_warnings(trx->mysql_thd)) { + wsrep_fk_warn("set virtual NULL", trx, + table, clust_index, err); + } +#endif + goto nonstandard_exit_func; } } @@ -1279,6 +1368,14 @@ row_ins_foreign_check_on_constraint( node, foreign); if (err != DB_SUCCESS) { +#ifdef WITH_WSREP + /* Warning message for applier FK failure */ + if (trx->is_wsrep() && + wsrep_applier_log_warnings(trx->mysql_thd)) { + wsrep_fk_warn("virtual cascade", trx, + table, clust_index, err); + } +#endif goto nonstandard_exit_func; } } @@ -1340,6 +1437,13 @@ row_ins_foreign_check_on_constraint( false, NULL, true, WSREP_SERVICE_KEY_EXCLUSIVE); if (err != DB_SUCCESS) { + /* Warning message for applier FK failure */ + if (trx->is_wsrep() && + wsrep_applier_log_warnings(trx->mysql_thd)) { + wsrep_fk_warn("wsrep append key", trx, + table, clust_index, err); + } + goto nonstandard_exit_func; } } @@ -1553,6 +1657,9 @@ row_ins_check_foreign_constraint( dict_index_t *check_index; dberr_t err = DB_SUCCESS; + check_index = check_ref + ? foreign->referenced_index : foreign->foreign_index; + { dict_table_t*& fktable = check_ref ? foreign->referenced_table : foreign->foreign_table; @@ -1560,60 +1667,75 @@ row_ins_check_foreign_constraint( if (check_table) { err = lock_table(check_table, &fktable, LOCK_IS, thr); if (err != DB_SUCCESS) { +#ifdef WITH_WSREP + /* Warning message for applier FK failure */ + if (trx->is_wsrep() && + wsrep_applier_log_warnings(trx->mysql_thd)) { + wsrep_fk_warn("lock check table", trx, + check_table, check_index, err); + } +#endif goto do_possible_lock_wait; } } check_table = fktable; } - check_index = check_ref - ? foreign->referenced_index : foreign->foreign_index; - if (!check_table || !check_table->is_readable() || !check_index) { FILE* ef = dict_foreign_err_file; std::string fk_str; + std::ostringstream os; + std::string fk_table_str; row_ins_set_detailed(trx, foreign); row_ins_foreign_trx_print(trx); - fputs("Foreign key constraint fails for table ", ef); - ut_print_name(ef, trx, check_ref - ? foreign->foreign_table_name - : foreign->referenced_table_name); - fputs(":\n", ef); + os << "Foreign key constraint fails for table "; + fk_table_str= ut_get_name(trx, check_ref + ? foreign->foreign_table_name + : foreign->referenced_table_name); + os << fk_table_str << std::endl; fk_str = dict_print_info_on_foreign_key_in_create_format( trx, foreign, TRUE); - fputs(fk_str.c_str(), ef); + os << fk_str; if (check_ref) { if (foreign->foreign_index) { - fprintf(ef, "\nTrying to add to index %s" - " tuple:\n", - foreign->foreign_index->name()); + os << "\nTrying to add to index " << + foreign->foreign_index->name() << " tuple:\n"; } else { - fputs("\nTrying to add tuple:\n", ef); + os << "\nTrying to add tuple:\n"; } - dtuple_print(ef, entry); - fputs("\nBut the parent table ", ef); - ut_print_name(ef, trx, foreign->referenced_table_name); - fputs("\nor its .ibd file or the required index does" - " not currently exist!\n", ef); + dtuple_print(os, entry); + os << "\nBut the parent table "; + fk_table_str= ut_get_name(trx, foreign->referenced_table_name); + os << fk_table_str; + os << "\nor its .ibd file or the required index does" + " not currently exist!\n"; err = DB_NO_REFERENCED_ROW; } else { if (foreign->referenced_index) { - fprintf(ef, "\nTrying to modify index %s" - " tuple:\n", - foreign->referenced_index->name()); + os << "\nTrying to modify index " + << foreign->referenced_index->name() + <<" tuple:\n"; } else { - fputs("\nTrying to modify tuple:\n", ef); + os << "\nTrying to modify tuple:\n"; } - dtuple_print(ef, entry); - fputs("\nBut the referencing table ", ef); - ut_print_name(ef, trx, foreign->foreign_table_name); - fputs("\nor its .ibd file or the required index does" - " not currently exist!\n", ef); + dtuple_print(os, entry); + os << "\nBut the referencing table "; + fk_table_str= ut_get_name(trx, foreign->foreign_table_name); + os << fk_table_str; + os << "\nor its .ibd file or the required index does" + " not currently exist!\n"; err = DB_ROW_IS_REFERENCED; } - + fputs(os.str().c_str(), ef); +#ifdef WITH_WSREP + /* Warning message for applier FK failure */ + if (trx->is_wsrep() && + wsrep_applier_log_warnings(trx->mysql_thd)) { + WSREP_WARN("%s", os.str().c_str()); + } +#endif mysql_mutex_unlock(&dict_foreign_err_mutex); goto exit_func; } @@ -1661,8 +1783,19 @@ row_ins_check_foreign_constraint( case DB_SUCCESS: continue; default: + { +#ifdef WITH_WSREP + /* Warning message for applier FK failure */ + if (trx->is_wsrep() && + wsrep_applier_log_warnings(trx->mysql_thd)) { + wsrep_fk_warn("set shared rec lock", trx, + check_table, check_index, err); + } +#endif + goto end_scan; } + } } cmp = cmp_dtuple_rec(entry, rec, offsets); @@ -1686,7 +1819,18 @@ row_ins_check_foreign_constraint( case DB_SUCCESS: break; default: + { +#ifdef WITH_WSREP + /* Warning message for applier FK failure */ + if (trx->is_wsrep() && + wsrep_applier_log_warnings(trx->mysql_thd)) { + wsrep_fk_warn("delete flag", trx, + check_table, check_index, err); + } +#endif goto end_scan; + + } } } else { if (check_table->versioned()) { @@ -1719,8 +1863,18 @@ row_ins_check_foreign_constraint( case DB_SUCCESS: break; default: + { +#ifdef WITH_WSREP + /* Warning message for applier FK failure */ + if (trx->is_wsrep() && + wsrep_applier_log_warnings(trx->mysql_thd)) { + wsrep_fk_warn("lock row", trx, + check_table, check_index, err); + } +#endif goto end_scan; } + } if (check_ref) { err = DB_SUCCESS; @@ -1735,6 +1889,12 @@ row_ins_check_foreign_constraint( upd_node, false, WSREP_SERVICE_KEY_REFERENCE); + + if (err != DB_SUCCESS && + wsrep_applier_log_warnings(trx->mysql_thd)) { + wsrep_fk_warn("append key ref", trx, + check_table, check_index, err); + } } #endif /* WITH_WSREP */ goto end_scan; @@ -1834,6 +1994,14 @@ row_ins_check_foreign_constraint( if (err == DB_SUCCESS) { err = DB_LOCK_WAIT; } +#ifdef WITH_WSREP + /* Warning message for applier FK failure */ + if (err != DB_SUCCESS && trx->is_wsrep() && + wsrep_applier_log_warnings(trx->mysql_thd)) { + wsrep_fk_warn("after lock wait", trx, + check_table, check_index, err); + } +#endif } exit_func: