From 4ee9e0664250ec1d6d2c0ea4ac6652c8b114fec0 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Mon, 23 Aug 2021 16:47:25 +0600 Subject: [PATCH 1/9] fix clang build --- storage/maria/ma_rt_test.c | 3 --- storage/myisam/rt_test.c | 3 --- 2 files changed, 6 deletions(-) diff --git a/storage/maria/ma_rt_test.c b/storage/maria/ma_rt_test.c index 5af941b78c8..f7e38af3dce 100644 --- a/storage/maria/ma_rt_test.c +++ b/storage/maria/ma_rt_test.c @@ -133,7 +133,6 @@ static int run_test(const char *filename) int key_length=8; int null_fields=0; int nrecords=sizeof(rt_data)/(sizeof(double)*4);/* 40 */ - int rec_length=0; int uniques=0; int i, max_i; int error; @@ -153,7 +152,6 @@ static int run_test(const char *filename) recinfo[0].type=FIELD_NORMAL; recinfo[0].length=1; /* For NULL bits */ - rec_length=1; /* Define 2*ndims columns for coordinates*/ @@ -161,7 +159,6 @@ static int run_test(const char *filename) { recinfo[i].type=FIELD_NORMAL; recinfo[i].length=key_length; - rec_length+=key_length; } /* Define a key with 2*ndims segments */ diff --git a/storage/myisam/rt_test.c b/storage/myisam/rt_test.c index 78deb80064a..07310039fd0 100644 --- a/storage/myisam/rt_test.c +++ b/storage/myisam/rt_test.c @@ -103,7 +103,6 @@ static int run_test(const char *filename) int key_length=8; int null_fields=0; int nrecords=sizeof(rt_data)/(sizeof(double)*4);/* 3000;*/ - int rec_length=0; int uniques=0; int i, max_i; int error; @@ -123,14 +122,12 @@ static int run_test(const char *filename) recinfo[0].type=FIELD_NORMAL; recinfo[0].length=1; /* For NULL bits */ - rec_length=1; /* Define 2*ndims columns for coordinates*/ for (i=1; i<=2*ndims ;i++){ recinfo[i].type=FIELD_NORMAL; recinfo[i].length=key_length; - rec_length+=key_length; } /* Define a key with 2*ndims segments */ From 1f1d5606e08c928e3da98bfeb13a7cccc307105d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 23 Aug 2021 15:14:54 +0300 Subject: [PATCH 2/9] Disable 2 commonly failing innodb_gis tests --- mysql-test/suite/innodb_gis/disabled.def | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql-test/suite/innodb_gis/disabled.def b/mysql-test/suite/innodb_gis/disabled.def index 8cae44a3607..bf500c1cb93 100644 --- a/mysql-test/suite/innodb_gis/disabled.def +++ b/mysql-test/suite/innodb_gis/disabled.def @@ -10,3 +10,5 @@ # ############################################################################## +rtree_concurrent_srch : MDEV-15284 COUNT(*) mismatch +rtree_recovery : MDEV-15284 COUNT(*) mismatch From c0a84fb9b0367b4cbd0a8e36d7cb219eb5f919e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 23 Aug 2021 17:00:01 +0300 Subject: [PATCH 3/9] MDEV-26465 Race condition in trx_purge_rseg_get_next_history_log() trx_purge_rseg_get_next_history_log(): Fix a race condition that was introduced in commit e46f76c9749d7758765ba274a212cfc2dcf3eeb8 (MDEV-15912). The buffer pool page contents must not be accessed while not holding a page latch. The page latch was released by mtr_t::commit(). This race resulted in an ASAN heap-use-after-poison during a stress test. --- storage/innobase/trx/trx0purge.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index 59d60d204d8..c8f471f1f7a 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -1155,15 +1155,16 @@ static void trx_purge_rseg_get_next_history_log( trx_no = mach_read_from_8(log_hdr + TRX_UNDO_TRX_NO); ut_ad(mach_read_from_2(log_hdr + TRX_UNDO_NEEDS_PURGE) <= 1); + const byte needs_purge = log_hdr[TRX_UNDO_NEEDS_PURGE + 1]; - mtr_commit(&mtr); + mtr.commit(); mutex_enter(&purge_sys.rseg->mutex); purge_sys.rseg->last_page_no = static_cast( prev_log_addr.page); purge_sys.rseg->set_last_commit(prev_log_addr.boffset, trx_no); - purge_sys.rseg->needs_purge = log_hdr[TRX_UNDO_NEEDS_PURGE + 1] != 0; + purge_sys.rseg->needs_purge = needs_purge != 0; /* Purge can also produce events, however these are already ordered in the rollback segment and any user generated event will be greater From 497b69493620eaa4cb1f2240a10be85e08a59793 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Tue, 24 Aug 2021 23:05:21 +0300 Subject: [PATCH 4/9] Fixed compile errors when compiling with HAVE_valgrind --- sql/field.cc | 2 +- storage/innobase/include/srv0mon.h | 2 +- storage/innobase/page/page0cur.cc | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sql/field.cc b/sql/field.cc index eaa829cd361..cba6df52b62 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -7692,7 +7692,7 @@ my_decimal *Field_varstring::val_decimal(my_decimal *decimal_value) #ifdef HAVE_valgrind void Field_varstring::mark_unused_memory_as_defined() { - uint used_length= get_length(); + uint used_length __attribute__((unused)) = get_length(); MEM_MAKE_DEFINED(get_data() + used_length, field_length - used_length); } #endif diff --git a/storage/innobase/include/srv0mon.h b/storage/innobase/include/srv0mon.h index eaf47789486..3721840f022 100644 --- a/storage/innobase/include/srv0mon.h +++ b/storage/innobase/include/srv0mon.h @@ -656,7 +656,7 @@ Use MONITOR_DEC if appropriate mutex protection exists. #ifdef HAVE_valgrind # define MONITOR_CHECK_DEFINED(value) do { \ - mon_type_t m = value; \ + mon_type_t m __attribute__((unused))= value; \ MEM_CHECK_DEFINED(&m, sizeof m); \ } while (0) #else /* HAVE_valgrind */ diff --git a/storage/innobase/page/page0cur.cc b/storage/innobase/page/page0cur.cc index e4007fca83b..a90195a1b67 100644 --- a/storage/innobase/page/page0cur.cc +++ b/storage/innobase/page/page0cur.cc @@ -1299,9 +1299,9 @@ page_cur_insert_rec_low( #ifdef HAVE_valgrind { - const void* rec_start + const void* rec_start __attribute__((unused)) = rec - rec_offs_extra_size(offsets); - ulint extra_size + ulint extra_size __attribute__((unused)) = rec_offs_extra_size(offsets) - (rec_offs_comp(offsets) ? REC_N_NEW_EXTRA_BYTES @@ -1530,9 +1530,9 @@ page_cur_insert_rec_zip( #ifdef HAVE_valgrind { - const void* rec_start + const void* rec_start __attribute__((unused)) = rec - rec_offs_extra_size(offsets); - ulint extra_size + ulint extra_size __attribute__((unused)) = rec_offs_extra_size(offsets) - (rec_offs_comp(offsets) ? REC_N_NEW_EXTRA_BYTES From ece30d47ca939944cdbb5bd2c12193c3c750fd01 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 8 Jul 2021 21:47:38 +1000 Subject: [PATCH 5/9] MDEV-26109: s390x detected as 32bit in mtr tests Currently @@version_compile_machine is used by mtr to determine if the compiled executable is 32 or 64 bits. We extend that logic by ensuring that if the DEFAUT_MACHINE name doesn't have "64" in its string, "-64bits" is appended to ensure these test pass. --- cmake/package_name.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmake/package_name.cmake b/cmake/package_name.cmake index 8acf52f1bb3..b93641109c3 100644 --- a/cmake/package_name.cmake +++ b/cmake/package_name.cmake @@ -110,7 +110,11 @@ IF(NOT VERSION) SET(DEFAULT_MACHINE "x86") ENDIF() ENDIF() - + + IF(NOT DEFAULT_MACHINE MATCHES "64" AND 64BIT) + SET(DEFAULT_MACHINE "${DEFAULT_MACHINE}-64bit") + ENDIF() + IF(NOT PLATFORM) SET(PLATFORM ${DEFAULT_PLATFORM}) ENDIF() From 8958f05e63f2cc059025c821b5cac8e54d8b6c91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 25 Aug 2021 09:12:27 +0300 Subject: [PATCH 6/9] Fix clang -Wunused-but-set-variable --- storage/maria/test_ma_backup.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/storage/maria/test_ma_backup.c b/storage/maria/test_ma_backup.c index 2a9a6704ecb..241763ecd32 100644 --- a/storage/maria/test_ma_backup.c +++ b/storage/maria/test_ma_backup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 MariaDB corporation +/* Copyright (C) 2018, 2021, MariaDB corporation. 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 @@ -178,7 +178,6 @@ static int create_test_table(const char *table_name, int type_of_table) int key_field=FIELD_SKIP_PRESPACE,extra_field=FIELD_SKIP_ENDSPACE; int key_type=HA_KEYTYPE_NUM; int create_flag=0; - uint offset_to_key; uint pack_seg=0, pack_keys= 0; uint key_length; uchar record[MAX_REC_LENGTH]; @@ -303,10 +302,6 @@ static int create_test_table(const char *table_name, int type_of_table) else uniques=0; - offset_to_key= MY_TEST(null_fields); - if (key_field == FIELD_BLOB || key_field == FIELD_VARCHAR) - offset_to_key+= 2; - if (!silent) printf("- Creating Aria file\n"); create_info.max_rows= 0; From bd3eb528512dfbb99a57033ff3bf7e09069c0d4e Mon Sep 17 00:00:00 2001 From: Marek Kulik Date: Wed, 25 Aug 2021 17:41:43 +1000 Subject: [PATCH 7/9] MDEV-26474: Fix mysql_setpermission hostname logic Changes: - Don't include port in connection parameters with 'localhost' hostname More info: The hostname, if not specified or specified as '' or 'localhost', will default to a MySQL server running on the local machine using the default for the UNIX socket. To connect to a MySQL server on the local machine via TCP, you must specify the loopback IP address (127.0.0.1) as the host. To comply with what the perl module expects, we omit the port for a host=localhost connection. Reported issue: https://bugzilla.redhat.com/show_bug.cgi?id=1976224 --- scripts/mysql_setpermission.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/mysql_setpermission.sh b/scripts/mysql_setpermission.sh index 29311b9c101..6f0ad72c1d9 100644 --- a/scripts/mysql_setpermission.sh +++ b/scripts/mysql_setpermission.sh @@ -105,11 +105,15 @@ else { if ($opt_socket and -S $opt_socket) { - $dsn .= "${prefix}_socket=$opt_socket"; + $dsn .= "${prefix}_socket=$opt_socket"; } else { - $dsn .= "host=$sqlhost;port=$opt_port"; + $dsn .= "host=$sqlhost"; + if ($sqlhost ne "localhost") + { + $dsn .= ";port=$opt_port"; + } } # make the connection to MariaDB From 15b691b7bd69568f813367d244d3744a3a04ac22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 25 Aug 2021 17:35:44 +0300 Subject: [PATCH 8/9] After-merge fix f84e28c119b495da77e197f7cd18af4048fc3126 In a rebase of the merge, two preceding commits were accidentally reverted: commit 112b23969a30ba6441efa5e22a3017435febfa17 (MDEV-26308) commit ac2857a5fbf851d90171ac55f23385869ee6ba83 (MDEV-25717) Thanks to Daniele Sciascia for noticing this. --- .../suite/galera/r/galera_split_brain.result | 3 +- .../suite/galera/t/galera_split_brain.test | 3 +- sql/handler.cc | 4 +- sql/sql_insert.cc | 4 +- sql/sql_parse.cc | 4 +- sql/wsrep_client_service.cc | 6 +- sql/wsrep_high_priority_service.cc | 23 ++++++- sql/wsrep_mysqld.cc | 66 ++++++++++++------- sql/wsrep_mysqld.h | 4 +- sql/wsrep_thd.cc | 15 ++++- sql/wsrep_thd.h | 6 +- sql/wsrep_var.cc | 4 +- 12 files changed, 96 insertions(+), 46 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_split_brain.result b/mysql-test/suite/galera/r/galera_split_brain.result index bd8c3a5bc44..08f9060d2a9 100644 --- a/mysql-test/suite/galera/r/galera_split_brain.result +++ b/mysql-test/suite/galera/r/galera_split_brain.result @@ -7,8 +7,9 @@ connection node_1; connection node_2; Killing server ... connection node_1; +SET SESSION lock_wait_timeout= 3; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +ERROR HY000: Lock wait timeout exceeded; try restarting transaction connection node_2; connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; disconnect node_2; diff --git a/mysql-test/suite/galera/t/galera_split_brain.test b/mysql-test/suite/galera/t/galera_split_brain.test index 6a822b8f127..ccdfd3fd506 100644 --- a/mysql-test/suite/galera/t/galera_split_brain.test +++ b/mysql-test/suite/galera/t/galera_split_brain.test @@ -22,7 +22,8 @@ call mtr.add_suppression("WSREP: TO isolation failed for: "); --source include/kill_galera.inc --connection node_1 ---error ER_LOCK_DEADLOCK +SET SESSION lock_wait_timeout= 3; +--error ER_LOCK_WAIT_TIMEOUT CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; # Reset the master and restart the slave so that post-test checks can run diff --git a/sql/handler.cc b/sql/handler.cc index 6b8c39cb0c4..757fa95a9a3 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. - Copyright (c) 2009, 2020, MariaDB Corporation. + Copyright (c) 2009, 2021, MariaDB Corporation. 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 @@ -1946,7 +1946,7 @@ int ha_rollback_trans(THD *thd, bool all) if (thd->is_error()) { WSREP_DEBUG("ha_rollback_trans(%lld, %s) rolled back: %s: %s; is_real %d", - thd->thread_id, all?"TRUE":"FALSE", WSREP_QUERY(thd), + thd->thread_id, all?"TRUE":"FALSE", wsrep_thd_query(thd), thd->get_stmt_da()->message(), is_real_trans); } (void) wsrep_after_rollback(thd, all); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index e04062d66d5..cbd815eb8fd 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. - Copyright (c) 2010, 2019, MariaDB Corporation + Copyright (c) 2010, 2021, MariaDB Corporation 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 @@ -4782,7 +4782,7 @@ bool select_create::send_eof() { WSREP_DEBUG("select_create commit failed, thd: %llu err: %s %s", thd->thread_id, - wsrep_thd_transaction_state_str(thd), WSREP_QUERY(thd)); + wsrep_thd_transaction_state_str(thd), wsrep_thd_query(thd)); mysql_mutex_unlock(&thd->LOCK_thd_data); abort_result_set(); DBUG_RETURN(true); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 9e78a1a95e2..8999397fee7 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -7845,7 +7845,7 @@ static bool wsrep_mysql_parse(THD *thd, char *rawbuf, uint length, DBUG_ASSERT(!debug_sync_set_action(thd, STRING_WITH_LEN(act))); }); WSREP_DEBUG("wsrep retrying AC query: %lu %s", - thd->wsrep_retry_counter, WSREP_QUERY(thd)); + thd->wsrep_retry_counter, wsrep_thd_query(thd)); wsrep_prepare_for_autocommit_retry(thd, rawbuf, length, parser_state); if (thd->lex->explain) delete_explain_query(thd->lex); @@ -7859,7 +7859,7 @@ static bool wsrep_mysql_parse(THD *thd, char *rawbuf, uint length, is_autocommit, thd->wsrep_retry_counter, thd->variables.wsrep_retry_autocommit, - WSREP_QUERY(thd)); + wsrep_thd_query(thd)); my_error(ER_LOCK_DEADLOCK, MYF(0)); thd->reset_kill_query(); thd->wsrep_retry_counter= 0; // reset diff --git a/sql/wsrep_client_service.cc b/sql/wsrep_client_service.cc index 89621619a23..f045e5d271a 100644 --- a/sql/wsrep_client_service.cc +++ b/sql/wsrep_client_service.cc @@ -1,4 +1,4 @@ -/* Copyright 2018 Codership Oy +/* Copyright 2018-2021 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 @@ -109,14 +109,14 @@ int Wsrep_client_service::prepare_data_for_replication() "affected rows: %llu, " "changed tables: %d, " "sql_log_bin: %d", - WSREP_QUERY(m_thd), + wsrep_thd_query(m_thd), m_thd->get_stmt_da()->affected_rows(), stmt_has_updated_trans_table(m_thd), m_thd->variables.sql_log_bin); } else { - WSREP_DEBUG("empty rbr buffer, query: %s", WSREP_QUERY(m_thd)); + WSREP_DEBUG("empty rbr buffer, query: %s", wsrep_thd_query(m_thd)); } } DBUG_RETURN(0); diff --git a/sql/wsrep_high_priority_service.cc b/sql/wsrep_high_priority_service.cc index 0da71c3eda5..452242dfd23 100644 --- a/sql/wsrep_high_priority_service.cc +++ b/sql/wsrep_high_priority_service.cc @@ -1,4 +1,4 @@ -/* Copyright 2018 Codership Oy +/* Copyright 2018-2021 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 @@ -379,6 +379,16 @@ int Wsrep_high_priority_service::apply_toi(const wsrep::ws_meta& ws_meta, WSREP_DEBUG("Wsrep_high_priority_service::apply_toi: %lld", client_state.toi_meta().seqno().get()); + DBUG_EXECUTE_IF("sync.wsrep_apply_toi", + { + const char act[]= + "now " + "SIGNAL sync.wsrep_apply_toi_reached " + "WAIT_FOR signal.wsrep_apply_toi"; + DBUG_ASSERT(!debug_sync_set_action(thd, + STRING_WITH_LEN(act))); + };); + int ret= wsrep_apply_events(thd, m_rli, data.data(), data.size()); if (ret != 0 || thd->wsrep_has_ignored_error) { @@ -427,6 +437,15 @@ int Wsrep_high_priority_service::log_dummy_write_set(const wsrep::ws_handle& ws_ DBUG_PRINT("info", ("Wsrep_high_priority_service::log_dummy_write_set: seqno=%lld", ws_meta.seqno().get())); + DBUG_EXECUTE_IF("sync.wsrep_log_dummy_write_set", + { + const char act[]= + "now " + "SIGNAL sync.wsrep_log_dummy_write_set_reached "; + DBUG_ASSERT(!debug_sync_set_action(m_thd, + STRING_WITH_LEN(act))); + };); + if (ws_meta.ordered()) { wsrep::client_state& cs(m_thd->wsrep_cs()); @@ -658,7 +677,7 @@ Wsrep_replayer_service::~Wsrep_replayer_service() DBUG_ASSERT(0); WSREP_ERROR("trx_replay failed for: %d, schema: %s, query: %s", m_replay_status, - orig_thd->db.str, WSREP_QUERY(orig_thd)); + orig_thd->db.str, wsrep_thd_query(orig_thd)); unireg_abort(1); } } diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index cabf066abf4..bf1e4e32b49 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -1,4 +1,4 @@ -/* Copyright 2008-2015 Codership Oy +/* Copyright 2008-2021 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 @@ -2008,10 +2008,10 @@ static int wsrep_TOI_begin(THD *thd, const char *db, const char *table, { DBUG_ASSERT(thd->variables.wsrep_OSU_method == WSREP_OSU_TOI); - WSREP_DEBUG("TOI Begin for %s", WSREP_QUERY(thd)); + WSREP_DEBUG("TOI Begin for %s", wsrep_thd_query(thd)); if (wsrep_can_run_in_toi(thd, db, table, table_list) == false) { - WSREP_DEBUG("No TOI for %s", WSREP_QUERY(thd)); + WSREP_DEBUG("No TOI for %s", wsrep_thd_query(thd)); return 1; } @@ -2039,7 +2039,7 @@ static int wsrep_TOI_begin(THD *thd, const char *db, const char *table, /* non replicated DDL, affecting temporary tables only */ WSREP_DEBUG("TO isolation skipped, sql: %s." "Only temporary tables affected.", - WSREP_QUERY(thd)); + wsrep_thd_query(thd)); if (buf) my_free(buf); return -1; } @@ -2054,7 +2054,7 @@ static int wsrep_TOI_begin(THD *thd, const char *db, const char *table, { DBUG_ASSERT(cs.current_error()); WSREP_DEBUG("to_execute_start() failed for %llu: %s, seqno: %lld", - thd->thread_id, WSREP_QUERY(thd), + thd->thread_id, wsrep_thd_query(thd), (long long)wsrep_thd_trx_seqno(thd)); /* jump to error handler in mysql_execute_command() */ @@ -2065,15 +2065,32 @@ static int wsrep_TOI_begin(THD *thd, const char *db, const char *table, "Maximum size exceeded.", ret, (thd->db.str ? thd->db.str : "(null)"), - WSREP_QUERY(thd)); + wsrep_thd_query(thd)); my_error(ER_ERROR_DURING_COMMIT, MYF(0), WSREP_SIZE_EXCEEDED); break; + case wsrep::e_deadlock_error: + WSREP_WARN("TO isolation failed for: %d, schema: %s, sql: %s. " + "Deadlock error.", + ret, + (thd->db.str ? thd->db.str : "(null)"), + wsrep_thd_query(thd)); + my_error(ER_LOCK_DEADLOCK, MYF(0)); + break; + case wsrep::e_timeout_error: + WSREP_WARN("TO isolation failed for: %d, schema: %s, sql: %s. " + "Operation timed out.", + ret, + (thd->db.str ? thd->db.str : "(null)"), + wsrep_thd_query(thd)); + my_error(ER_LOCK_WAIT_TIMEOUT, MYF(0)); + break; default: WSREP_WARN("TO isolation failed for: %d, schema: %s, sql: %s. " - "Check wsrep connection state and retry the query.", + "Check your wsrep connection state and retry the query.", ret, (thd->db.str ? thd->db.str : "(null)"), - WSREP_QUERY(thd)); + wsrep_thd_query(thd)); + if (!thd->is_error()) { my_error(ER_LOCK_DEADLOCK, MYF(0), "WSREP replication failed. Check " @@ -2106,19 +2123,19 @@ static void wsrep_TOI_end(THD *thd) { if (!ret) { WSREP_DEBUG("TO END: %lld: %s", - client_state.toi_meta().seqno().get(), WSREP_QUERY(thd)); + client_state.toi_meta().seqno().get(), wsrep_thd_query(thd)); } else { WSREP_WARN("TO isolation end failed for: %d, sql: %s", - ret, WSREP_QUERY(thd)); + ret, wsrep_thd_query(thd)); } } static int wsrep_RSU_begin(THD *thd, const char *db_, const char *table_) { WSREP_DEBUG("RSU BEGIN: %lld, : %s", wsrep_thd_trx_seqno(thd), - WSREP_QUERY(thd)); + wsrep_thd_query(thd)); if (thd->wsrep_cs().begin_rsu(5000)) { WSREP_WARN("RSU begin failed"); @@ -2133,7 +2150,7 @@ static int wsrep_RSU_begin(THD *thd, const char *db_, const char *table_) static void wsrep_RSU_end(THD *thd) { WSREP_DEBUG("RSU END: %lld : %s", wsrep_thd_trx_seqno(thd), - WSREP_QUERY(thd)); + wsrep_thd_query(thd)); if (thd->wsrep_cs().end_rsu()) { WSREP_WARN("Failed to end RSU, server may need to be restarted"); @@ -2175,7 +2192,7 @@ int wsrep_to_isolation_begin(THD *thd, const char *db_, const char *table_, if (wsrep_debug && thd->mdl_context.has_locks()) { WSREP_DEBUG("thread holds MDL locks at TI begin: %s %llu", - WSREP_QUERY(thd), thd->thread_id); + wsrep_thd_query(thd), thd->thread_id); } /* @@ -2191,13 +2208,6 @@ int wsrep_to_isolation_begin(THD *thd, const char *db_, const char *table_, thd->variables.auto_increment_increment= 1; } - /* - TOI operations will ignore provided lock_wait_timeout and restore it - after operation is done. - */ - thd->variables.saved_lock_wait_timeout= thd->variables.lock_wait_timeout; - thd->variables.lock_wait_timeout= LONG_TIMEOUT; - if (thd->variables.wsrep_on && wsrep_thd_is_local(thd)) { switch (thd->variables.wsrep_OSU_method) { @@ -2213,8 +2223,19 @@ int wsrep_to_isolation_begin(THD *thd, const char *db_, const char *table_, ret= -1; break; } + switch (ret) { - case 0: /* wsrep_TOI_begin sould set toi mode */ break; + case 0: /* wsrep_TOI_begin sould set toi mode */ + if (thd->variables.wsrep_OSU_method == WSREP_OSU_TOI) + { + /* + TOI operations ignore the provided lock_wait_timeout once replicated, + and restore it after operation is done. + */ + thd->variables.saved_lock_wait_timeout= thd->variables.lock_wait_timeout; + thd->variables.lock_wait_timeout= LONG_TIMEOUT; + } + break; case 1: /* TOI replication skipped, treat as success */ ret= 0; @@ -2233,10 +2254,9 @@ void wsrep_to_isolation_end(THD *thd) DBUG_ASSERT(wsrep_thd_is_local_toi(thd) || wsrep_thd_is_in_rsu(thd)); - thd->variables.lock_wait_timeout= thd->variables.saved_lock_wait_timeout; - if (wsrep_thd_is_local_toi(thd)) { + thd->variables.lock_wait_timeout= thd->variables.saved_lock_wait_timeout; DBUG_ASSERT(thd->variables.wsrep_OSU_method == WSREP_OSU_TOI); wsrep_TOI_end(thd); } diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index 748d93c72aa..db3e9b09b51 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -1,4 +1,4 @@ -/* Copyright 2008-2017 Codership Oy +/* Copyright 2008-2021 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 @@ -289,8 +289,6 @@ static inline bool wsrep_cluster_address_exists() return wsrep_cluster_address && wsrep_cluster_address[0]; } -#define WSREP_QUERY(thd) (thd->query()) - extern my_bool wsrep_ready_get(); extern void wsrep_ready_wait(); diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc index d8f3d8959e0..2e02110d697 100644 --- a/sql/wsrep_thd.cc +++ b/sql/wsrep_thd.cc @@ -340,11 +340,20 @@ int wsrep_abort_thd(THD *bf_thd_ptr, THD *victim_thd_ptr, my_bool signal) DBUG_RETURN(1); } -bool wsrep_bf_abort(const THD* bf_thd, THD* victim_thd) +bool wsrep_bf_abort(THD* bf_thd, THD* victim_thd) { WSREP_LOG_THD(bf_thd, "BF aborter before"); WSREP_LOG_THD(victim_thd, "victim before"); - wsrep::seqno bf_seqno(bf_thd->wsrep_trx().ws_meta().seqno()); + + DBUG_EXECUTE_IF("sync.wsrep_bf_abort", + { + const char act[]= + "now " + "SIGNAL sync.wsrep_bf_abort_reached " + "WAIT_FOR signal.wsrep_bf_abort"; + DBUG_ASSERT(!debug_sync_set_action(bf_thd, + STRING_WITH_LEN(act))); + };); if (WSREP(victim_thd) && !victim_thd->wsrep_trx().active()) { @@ -362,6 +371,8 @@ bool wsrep_bf_abort(const THD* bf_thd, THD* victim_thd) } bool ret; + wsrep::seqno bf_seqno(bf_thd->wsrep_trx().ws_meta().seqno()); + if (wsrep_thd_is_toi(bf_thd)) { ret= victim_thd->wsrep_cs().total_order_bf_abort(bf_seqno); diff --git a/sql/wsrep_thd.h b/sql/wsrep_thd.h index d24d8e6358f..560dbbdab44 100644 --- a/sql/wsrep_thd.h +++ b/sql/wsrep_thd.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 Codership Oy +/* Copyright (C) 2013-2021 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 @@ -87,7 +87,7 @@ int wsrep_show_bf_aborts (THD *thd, SHOW_VAR *var, char *buff, bool wsrep_create_appliers(long threads, bool mutex_protected=false); void wsrep_create_rollbacker(); -bool wsrep_bf_abort(const THD*, THD*); +bool wsrep_bf_abort(THD* bf_thd, THD* victim_thd); int wsrep_abort_thd(THD *bf_thd_ptr, THD *victim_thd_ptr, my_bool signal); extern void wsrep_thd_set_PA_safe(void *thd_ptr, my_bool safe); @@ -292,7 +292,7 @@ static inline void wsrep_log_thd(const THD *thd, (thd->get_stmt_da()->is_error() ? thd->get_stmt_da()->message() : "") #ifdef WSREP_THD_LOG_QUERIES , thd->lex->sql_command, - WSREP_QUERY(thd) + wsrep_thd_query(thd) #endif /* WSREP_OBSERVER_LOG_QUERIES */ ); } diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc index e4cfd0d89c9..cd7b9bdf870 100644 --- a/sql/wsrep_var.cc +++ b/sql/wsrep_var.cc @@ -1,4 +1,4 @@ -/* Copyright 2008-2015 Codership Oy +/* Copyright 2008-2021 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 @@ -794,7 +794,7 @@ bool wsrep_desync_check (sys_var *self, THD* thd, set_var* var) ret= Wsrep_server_state::instance().provider().desync(); if (ret) { WSREP_WARN ("SET desync failed %d for schema: %s, query: %s", ret, - thd->db.str, WSREP_QUERY(thd)); + thd->db.str, wsrep_thd_query(thd)); my_error (ER_CANNOT_USER, MYF(0), "'desync'", thd->query()); return true; } From dc6bc85cd29586631d927036451d955c7013206c Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 24 Aug 2021 11:03:02 +0200 Subject: [PATCH 9/9] MDEV-26380 auth_pam_tool has incorrect permissions on CentOS 7 Buggy sepdebugcrcfix in CentOS 7 (rpm-4.11.3) does not restore SUID bit after editing the binary. This is fixed in rpm-4.12. Still let's not set SUID bit when installing auth_pam_tool and use rpm spec %attr directive instead. --- plugin/auth_pam/CMakeLists.txt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/plugin/auth_pam/CMakeLists.txt b/plugin/auth_pam/CMakeLists.txt index 8d11d174f90..5b2ca3c708a 100644 --- a/plugin/auth_pam/CMakeLists.txt +++ b/plugin/auth_pam/CMakeLists.txt @@ -38,11 +38,10 @@ IF(HAVE_PAM_APPL_H AND HAVE_GETGROUPLIST) IF (TARGET auth_pam) MYSQL_ADD_EXECUTABLE(auth_pam_tool auth_pam_tool.c DESTINATION ${INSTALL_PLUGINDIR}/auth_pam_tool_dir COMPONENT Server) TARGET_LINK_LIBRARIES(auth_pam_tool pam) - INSTALL(CODE "EXECUTE_PROCESS( - COMMAND chmod u=rwx,g=,o= auth_pam_tool_dir - COMMAND chmod u=rwxs,g=rx,o=rx auth_pam_tool_dir/auth_pam_tool - WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${INSTALL_PLUGINDIR}/)" - COMPONENT Server) + SET(CPACK_RPM_server_USER_FILELIST ${CPACK_RPM_server_USER_FILELIST} + "%attr(700, -, -) ${INSTALL_PLUGINDIRABS}/auth_pam_tool_dir" + "%attr(4755, -, -) ${INSTALL_PLUGINDIRABS}/auth_pam_tool_dir/auth_pam_tool") + SET(CPACK_RPM_server_USER_FILELIST ${CPACK_RPM_server_USER_FILELIST} PARENT_SCOPE) ENDIF() IF(TARGET auth_pam OR TARGET auth_pam_v1) ADD_SUBDIRECTORY(testing) @@ -52,7 +51,7 @@ IF(HAVE_PAM_APPL_H AND HAVE_GETGROUPLIST) IF(INSTALL_PAMDIR) INSTALL(TARGETS pam_user_map DESTINATION ${INSTALL_PAMDIR} COMPONENT Server) INSTALL(FILES mapper/user_map.conf DESTINATION ${INSTALL_PAMDATADIR} COMPONENT Server) - SET(CPACK_RPM_server_USER_FILELIST ${CPACK_RPM_server_USER_FILELIST} "%config(noreplace) ${INSTALL_PAMDATADIR}/*" PARENT_SCOPE) + SET(CPACK_RPM_server_USER_FILELIST ${CPACK_RPM_server_USER_FILELIST} "%config(noreplace) ${INSTALL_PAMDATADIRABS}/*" PARENT_SCOPE) ENDIF() ENDIF() ENDIF()