Skip to content

Commit 15b691b

Browse files
committed
After-merge fix f84e28c
In a rebase of the merge, two preceding commits were accidentally reverted: commit 112b239 (MDEV-26308) commit ac2857a (MDEV-25717) Thanks to Daniele Sciascia for noticing this.
1 parent 8958f05 commit 15b691b

12 files changed

+96
-46
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ connection node_1;
77
connection node_2;
88
Killing server ...
99
connection node_1;
10+
SET SESSION lock_wait_timeout= 3;
1011
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
11-
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
12+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
1213
connection node_2;
1314
connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2;
1415
disconnect node_2;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ call mtr.add_suppression("WSREP: TO isolation failed for: ");
2222
--source include/kill_galera.inc
2323

2424
--connection node_1
25-
--error ER_LOCK_DEADLOCK
25+
SET SESSION lock_wait_timeout= 3;
26+
--error ER_LOCK_WAIT_TIMEOUT
2627
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
2728

2829
# Reset the master and restart the slave so that post-test checks can run

sql/handler.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
2-
Copyright (c) 2009, 2020, MariaDB Corporation.
2+
Copyright (c) 2009, 2021, MariaDB Corporation.
33
44
This program is free software; you can redistribute it and/or modify
55
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)
19461946
if (thd->is_error())
19471947
{
19481948
WSREP_DEBUG("ha_rollback_trans(%lld, %s) rolled back: %s: %s; is_real %d",
1949-
thd->thread_id, all?"TRUE":"FALSE", WSREP_QUERY(thd),
1949+
thd->thread_id, all?"TRUE":"FALSE", wsrep_thd_query(thd),
19501950
thd->get_stmt_da()->message(), is_real_trans);
19511951
}
19521952
(void) wsrep_after_rollback(thd, all);

sql/sql_insert.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Copyright (c) 2000, 2016, Oracle and/or its affiliates.
3-
Copyright (c) 2010, 2019, MariaDB Corporation
3+
Copyright (c) 2010, 2021, MariaDB Corporation
44
55
This program is free software; you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -4782,7 +4782,7 @@ bool select_create::send_eof()
47824782
{
47834783
WSREP_DEBUG("select_create commit failed, thd: %llu err: %s %s",
47844784
thd->thread_id,
4785-
wsrep_thd_transaction_state_str(thd), WSREP_QUERY(thd));
4785+
wsrep_thd_transaction_state_str(thd), wsrep_thd_query(thd));
47864786
mysql_mutex_unlock(&thd->LOCK_thd_data);
47874787
abort_result_set();
47884788
DBUG_RETURN(true);

sql/sql_parse.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7845,7 +7845,7 @@ static bool wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
78457845
DBUG_ASSERT(!debug_sync_set_action(thd, STRING_WITH_LEN(act)));
78467846
});
78477847
WSREP_DEBUG("wsrep retrying AC query: %lu %s",
7848-
thd->wsrep_retry_counter, WSREP_QUERY(thd));
7848+
thd->wsrep_retry_counter, wsrep_thd_query(thd));
78497849
wsrep_prepare_for_autocommit_retry(thd, rawbuf, length, parser_state);
78507850
if (thd->lex->explain)
78517851
delete_explain_query(thd->lex);
@@ -7859,7 +7859,7 @@ static bool wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
78597859
is_autocommit,
78607860
thd->wsrep_retry_counter,
78617861
thd->variables.wsrep_retry_autocommit,
7862-
WSREP_QUERY(thd));
7862+
wsrep_thd_query(thd));
78637863
my_error(ER_LOCK_DEADLOCK, MYF(0));
78647864
thd->reset_kill_query();
78657865
thd->wsrep_retry_counter= 0; // reset

sql/wsrep_client_service.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2018 Codership Oy <info@codership.com>
1+
/* Copyright 2018-2021 Codership Oy <info@codership.com>
22
33
This program is free software; you can redistribute it and/or modify
44
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()
109109
"affected rows: %llu, "
110110
"changed tables: %d, "
111111
"sql_log_bin: %d",
112-
WSREP_QUERY(m_thd),
112+
wsrep_thd_query(m_thd),
113113
m_thd->get_stmt_da()->affected_rows(),
114114
stmt_has_updated_trans_table(m_thd),
115115
m_thd->variables.sql_log_bin);
116116
}
117117
else
118118
{
119-
WSREP_DEBUG("empty rbr buffer, query: %s", WSREP_QUERY(m_thd));
119+
WSREP_DEBUG("empty rbr buffer, query: %s", wsrep_thd_query(m_thd));
120120
}
121121
}
122122
DBUG_RETURN(0);

sql/wsrep_high_priority_service.cc

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2018 Codership Oy <info@codership.com>
1+
/* Copyright 2018-2021 Codership Oy <info@codership.com>
22
33
This program is free software; you can redistribute it and/or modify
44
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,
379379
WSREP_DEBUG("Wsrep_high_priority_service::apply_toi: %lld",
380380
client_state.toi_meta().seqno().get());
381381

382+
DBUG_EXECUTE_IF("sync.wsrep_apply_toi",
383+
{
384+
const char act[]=
385+
"now "
386+
"SIGNAL sync.wsrep_apply_toi_reached "
387+
"WAIT_FOR signal.wsrep_apply_toi";
388+
DBUG_ASSERT(!debug_sync_set_action(thd,
389+
STRING_WITH_LEN(act)));
390+
};);
391+
382392
int ret= wsrep_apply_events(thd, m_rli, data.data(), data.size());
383393
if (ret != 0 || thd->wsrep_has_ignored_error)
384394
{
@@ -427,6 +437,15 @@ int Wsrep_high_priority_service::log_dummy_write_set(const wsrep::ws_handle& ws_
427437
DBUG_PRINT("info",
428438
("Wsrep_high_priority_service::log_dummy_write_set: seqno=%lld",
429439
ws_meta.seqno().get()));
440+
DBUG_EXECUTE_IF("sync.wsrep_log_dummy_write_set",
441+
{
442+
const char act[]=
443+
"now "
444+
"SIGNAL sync.wsrep_log_dummy_write_set_reached ";
445+
DBUG_ASSERT(!debug_sync_set_action(m_thd,
446+
STRING_WITH_LEN(act)));
447+
};);
448+
430449
if (ws_meta.ordered())
431450
{
432451
wsrep::client_state& cs(m_thd->wsrep_cs());
@@ -658,7 +677,7 @@ Wsrep_replayer_service::~Wsrep_replayer_service()
658677
DBUG_ASSERT(0);
659678
WSREP_ERROR("trx_replay failed for: %d, schema: %s, query: %s",
660679
m_replay_status,
661-
orig_thd->db.str, WSREP_QUERY(orig_thd));
680+
orig_thd->db.str, wsrep_thd_query(orig_thd));
662681
unireg_abort(1);
663682
}
664683
}

sql/wsrep_mysqld.cc

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2008-2015 Codership Oy <http://www.codership.com>
1+
/* Copyright 2008-2021 Codership Oy <http://www.codership.com>
22
33
This program is free software; you can redistribute it and/or modify
44
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,
20082008
{
20092009
DBUG_ASSERT(thd->variables.wsrep_OSU_method == WSREP_OSU_TOI);
20102010

2011-
WSREP_DEBUG("TOI Begin for %s", WSREP_QUERY(thd));
2011+
WSREP_DEBUG("TOI Begin for %s", wsrep_thd_query(thd));
20122012
if (wsrep_can_run_in_toi(thd, db, table, table_list) == false)
20132013
{
2014-
WSREP_DEBUG("No TOI for %s", WSREP_QUERY(thd));
2014+
WSREP_DEBUG("No TOI for %s", wsrep_thd_query(thd));
20152015
return 1;
20162016
}
20172017

@@ -2039,7 +2039,7 @@ static int wsrep_TOI_begin(THD *thd, const char *db, const char *table,
20392039
/* non replicated DDL, affecting temporary tables only */
20402040
WSREP_DEBUG("TO isolation skipped, sql: %s."
20412041
"Only temporary tables affected.",
2042-
WSREP_QUERY(thd));
2042+
wsrep_thd_query(thd));
20432043
if (buf) my_free(buf);
20442044
return -1;
20452045
}
@@ -2054,7 +2054,7 @@ static int wsrep_TOI_begin(THD *thd, const char *db, const char *table,
20542054
{
20552055
DBUG_ASSERT(cs.current_error());
20562056
WSREP_DEBUG("to_execute_start() failed for %llu: %s, seqno: %lld",
2057-
thd->thread_id, WSREP_QUERY(thd),
2057+
thd->thread_id, wsrep_thd_query(thd),
20582058
(long long)wsrep_thd_trx_seqno(thd));
20592059

20602060
/* 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,
20652065
"Maximum size exceeded.",
20662066
ret,
20672067
(thd->db.str ? thd->db.str : "(null)"),
2068-
WSREP_QUERY(thd));
2068+
wsrep_thd_query(thd));
20692069
my_error(ER_ERROR_DURING_COMMIT, MYF(0), WSREP_SIZE_EXCEEDED);
20702070
break;
2071+
case wsrep::e_deadlock_error:
2072+
WSREP_WARN("TO isolation failed for: %d, schema: %s, sql: %s. "
2073+
"Deadlock error.",
2074+
ret,
2075+
(thd->db.str ? thd->db.str : "(null)"),
2076+
wsrep_thd_query(thd));
2077+
my_error(ER_LOCK_DEADLOCK, MYF(0));
2078+
break;
2079+
case wsrep::e_timeout_error:
2080+
WSREP_WARN("TO isolation failed for: %d, schema: %s, sql: %s. "
2081+
"Operation timed out.",
2082+
ret,
2083+
(thd->db.str ? thd->db.str : "(null)"),
2084+
wsrep_thd_query(thd));
2085+
my_error(ER_LOCK_WAIT_TIMEOUT, MYF(0));
2086+
break;
20712087
default:
20722088
WSREP_WARN("TO isolation failed for: %d, schema: %s, sql: %s. "
2073-
"Check wsrep connection state and retry the query.",
2089+
"Check your wsrep connection state and retry the query.",
20742090
ret,
20752091
(thd->db.str ? thd->db.str : "(null)"),
2076-
WSREP_QUERY(thd));
2092+
wsrep_thd_query(thd));
2093+
20772094
if (!thd->is_error())
20782095
{
20792096
my_error(ER_LOCK_DEADLOCK, MYF(0), "WSREP replication failed. Check "
@@ -2106,19 +2123,19 @@ static void wsrep_TOI_end(THD *thd) {
21062123
if (!ret)
21072124
{
21082125
WSREP_DEBUG("TO END: %lld: %s",
2109-
client_state.toi_meta().seqno().get(), WSREP_QUERY(thd));
2126+
client_state.toi_meta().seqno().get(), wsrep_thd_query(thd));
21102127
}
21112128
else
21122129
{
21132130
WSREP_WARN("TO isolation end failed for: %d, sql: %s",
2114-
ret, WSREP_QUERY(thd));
2131+
ret, wsrep_thd_query(thd));
21152132
}
21162133
}
21172134

21182135
static int wsrep_RSU_begin(THD *thd, const char *db_, const char *table_)
21192136
{
21202137
WSREP_DEBUG("RSU BEGIN: %lld, : %s", wsrep_thd_trx_seqno(thd),
2121-
WSREP_QUERY(thd));
2138+
wsrep_thd_query(thd));
21222139
if (thd->wsrep_cs().begin_rsu(5000))
21232140
{
21242141
WSREP_WARN("RSU begin failed");
@@ -2133,7 +2150,7 @@ static int wsrep_RSU_begin(THD *thd, const char *db_, const char *table_)
21332150
static void wsrep_RSU_end(THD *thd)
21342151
{
21352152
WSREP_DEBUG("RSU END: %lld : %s", wsrep_thd_trx_seqno(thd),
2136-
WSREP_QUERY(thd));
2153+
wsrep_thd_query(thd));
21372154
if (thd->wsrep_cs().end_rsu())
21382155
{
21392156
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_,
21752192
if (wsrep_debug && thd->mdl_context.has_locks())
21762193
{
21772194
WSREP_DEBUG("thread holds MDL locks at TI begin: %s %llu",
2178-
WSREP_QUERY(thd), thd->thread_id);
2195+
wsrep_thd_query(thd), thd->thread_id);
21792196
}
21802197

21812198
/*
@@ -2191,13 +2208,6 @@ int wsrep_to_isolation_begin(THD *thd, const char *db_, const char *table_,
21912208
thd->variables.auto_increment_increment= 1;
21922209
}
21932210

2194-
/*
2195-
TOI operations will ignore provided lock_wait_timeout and restore it
2196-
after operation is done.
2197-
*/
2198-
thd->variables.saved_lock_wait_timeout= thd->variables.lock_wait_timeout;
2199-
thd->variables.lock_wait_timeout= LONG_TIMEOUT;
2200-
22012211
if (thd->variables.wsrep_on && wsrep_thd_is_local(thd))
22022212
{
22032213
switch (thd->variables.wsrep_OSU_method) {
@@ -2213,8 +2223,19 @@ int wsrep_to_isolation_begin(THD *thd, const char *db_, const char *table_,
22132223
ret= -1;
22142224
break;
22152225
}
2226+
22162227
switch (ret) {
2217-
case 0: /* wsrep_TOI_begin sould set toi mode */ break;
2228+
case 0: /* wsrep_TOI_begin sould set toi mode */
2229+
if (thd->variables.wsrep_OSU_method == WSREP_OSU_TOI)
2230+
{
2231+
/*
2232+
TOI operations ignore the provided lock_wait_timeout once replicated,
2233+
and restore it after operation is done.
2234+
*/
2235+
thd->variables.saved_lock_wait_timeout= thd->variables.lock_wait_timeout;
2236+
thd->variables.lock_wait_timeout= LONG_TIMEOUT;
2237+
}
2238+
break;
22182239
case 1:
22192240
/* TOI replication skipped, treat as success */
22202241
ret= 0;
@@ -2233,10 +2254,9 @@ void wsrep_to_isolation_end(THD *thd)
22332254
DBUG_ASSERT(wsrep_thd_is_local_toi(thd) ||
22342255
wsrep_thd_is_in_rsu(thd));
22352256

2236-
thd->variables.lock_wait_timeout= thd->variables.saved_lock_wait_timeout;
2237-
22382257
if (wsrep_thd_is_local_toi(thd))
22392258
{
2259+
thd->variables.lock_wait_timeout= thd->variables.saved_lock_wait_timeout;
22402260
DBUG_ASSERT(thd->variables.wsrep_OSU_method == WSREP_OSU_TOI);
22412261
wsrep_TOI_end(thd);
22422262
}

sql/wsrep_mysqld.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2008-2017 Codership Oy <http://www.codership.com>
1+
/* Copyright 2008-2021 Codership Oy <http://www.codership.com>
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -289,8 +289,6 @@ static inline bool wsrep_cluster_address_exists()
289289
return wsrep_cluster_address && wsrep_cluster_address[0];
290290
}
291291

292-
#define WSREP_QUERY(thd) (thd->query())
293-
294292
extern my_bool wsrep_ready_get();
295293
extern void wsrep_ready_wait();
296294

sql/wsrep_thd.cc

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,20 @@ int wsrep_abort_thd(THD *bf_thd_ptr, THD *victim_thd_ptr, my_bool signal)
340340
DBUG_RETURN(1);
341341
}
342342

343-
bool wsrep_bf_abort(const THD* bf_thd, THD* victim_thd)
343+
bool wsrep_bf_abort(THD* bf_thd, THD* victim_thd)
344344
{
345345
WSREP_LOG_THD(bf_thd, "BF aborter before");
346346
WSREP_LOG_THD(victim_thd, "victim before");
347-
wsrep::seqno bf_seqno(bf_thd->wsrep_trx().ws_meta().seqno());
347+
348+
DBUG_EXECUTE_IF("sync.wsrep_bf_abort",
349+
{
350+
const char act[]=
351+
"now "
352+
"SIGNAL sync.wsrep_bf_abort_reached "
353+
"WAIT_FOR signal.wsrep_bf_abort";
354+
DBUG_ASSERT(!debug_sync_set_action(bf_thd,
355+
STRING_WITH_LEN(act)));
356+
};);
348357

349358
if (WSREP(victim_thd) && !victim_thd->wsrep_trx().active())
350359
{
@@ -362,6 +371,8 @@ bool wsrep_bf_abort(const THD* bf_thd, THD* victim_thd)
362371
}
363372

364373
bool ret;
374+
wsrep::seqno bf_seqno(bf_thd->wsrep_trx().ws_meta().seqno());
375+
365376
if (wsrep_thd_is_toi(bf_thd))
366377
{
367378
ret= victim_thd->wsrep_cs().total_order_bf_abort(bf_seqno);

0 commit comments

Comments
 (0)