Skip to content

Commit 97582f1

Browse files
sjaakolajanlindstrom
authored andcommitted
MDEV-27649 PS conflict handling causing node crash
Handling BF abort for prepared statement execution so that EXECUTE processing will continue until parameter setup is complete, before BF abort bails out the statement execution. THD class has new boolean member: wsrep_delayed_BF_abort, which is set if BF abort is observed in do_command() right after reading client's packet, and if the client has sent PS execute command. In such case, the deadlock error is not returned immediately back to client, but the PS execution will be started. However, the PS execution loop, will now check if wsrep_delayed_BF_abort is set, and stop the PS execution after the type information has been assigned for the PS. With this, the PS protocol type information, which is present in the first PS EXECUTE command, is not lost even if the first PS EXECUTE command was marked to abort. Reviewed-by: Jan Lindström <jan.lindstrom@mariadb.com>
1 parent 8e9e1c3 commit 97582f1

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

sql/sql_class.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,7 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
666666
wsrep_replicate_GTID(false),
667667
wsrep_ignore_table(false),
668668
wsrep_aborter(0),
669+
wsrep_delayed_BF_abort(false),
669670

670671
/* wsrep-lib */
671672
m_wsrep_next_trx_id(WSREP_UNDEFINED_TRX_ID),

sql/sql_class.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4897,6 +4897,10 @@ class THD: public THD_count, /* this must be first */
48974897
/* thread who has started kill for this THD protected by LOCK_thd_data*/
48984898
my_thread_id wsrep_aborter;
48994899

4900+
/* true if BF abort is observed in do_command() right after reading
4901+
client's packet, and if the client has sent PS execute command. */
4902+
bool wsrep_delayed_BF_abort;
4903+
49004904
/*
49014905
Transaction id:
49024906
* m_wsrep_next_trx_id is assigned on the first query after

sql/sql_parse.cc

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,13 @@ bool do_command(THD *thd)
13131313
DBUG_ASSERT(!thd->mdl_context.has_locks());
13141314
DBUG_ASSERT(!thd->get_stmt_da()->is_set());
13151315
/* We let COM_QUIT and COM_STMT_CLOSE to execute even if wsrep aborted. */
1316-
if (command != COM_STMT_CLOSE &&
1316+
if (command == COM_STMT_EXECUTE)
1317+
{
1318+
WSREP_DEBUG("PS BF aborted at do_command");
1319+
thd->wsrep_delayed_BF_abort= true;
1320+
}
1321+
if (command != COM_STMT_CLOSE &&
1322+
command != COM_STMT_EXECUTE &&
13171323
command != COM_QUIT)
13181324
{
13191325
my_error(ER_LOCK_DEADLOCK, MYF(0));
@@ -1385,6 +1391,17 @@ bool do_command(THD *thd)
13851391
/* there was a command to process, and before_command() has been called */
13861392
wsrep_after_command_after_result(thd);
13871393
}
1394+
1395+
if (thd->wsrep_delayed_BF_abort)
1396+
{
1397+
my_error(ER_LOCK_DEADLOCK, MYF(0));
1398+
WSREP_DEBUG("Deadlock error for PS query: %s", thd->query());
1399+
thd->reset_killed();
1400+
thd->mysys_var->abort = 0;
1401+
thd->wsrep_retry_counter = 0;
1402+
1403+
thd->wsrep_delayed_BF_abort= false;
1404+
}
13881405
#endif /* WITH_WSREP */
13891406
DBUG_RETURN(return_value);
13901407
}

sql/sql_prepare.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4461,7 +4461,13 @@ Prepared_statement::execute_loop(String *expanded_query,
44614461

44624462
if (set_parameters(expanded_query, packet, packet_end))
44634463
return TRUE;
4464-
4464+
#ifdef WITH_WSREP
4465+
if (thd->wsrep_delayed_BF_abort)
4466+
{
4467+
WSREP_DEBUG("delayed BF abort, quitting execute_loop, stmt: %d", id);
4468+
return TRUE;
4469+
}
4470+
#endif /* WITH_WSREP */
44654471
reexecute:
44664472
// Make sure that reprepare() did not create any new Items.
44674473
DBUG_ASSERT(thd->free_list == NULL);

0 commit comments

Comments
 (0)