Skip to content

Commit a2d3770

Browse files
committed
Only print "InnoDB: Transaction was aborted..." if log_warnings >= 4
This is a minor fixup for MDEV-24035 Failing assertion UT_LIST_GET_LEN(lock.trx_locks) == 0 causing disruption and replication failure
1 parent 130d6f9 commit a2d3770

File tree

3 files changed

+70
-2
lines changed

3 files changed

+70
-2
lines changed

include/mysql/service_log_warnings.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/* Copyright (c) 2013, 2018, MariaDB
2+
3+
This program is free software; you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License as published by
5+
the Free Software Foundation; version 2 of the License.
6+
7+
This program is distributed in the hope that it will be useful,
8+
but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
GNU General Public License for more details.
11+
12+
You should have received a copy of the GNU General Public License
13+
along with this program; if not, write to the Free Software
14+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
15+
16+
#ifndef MYSQL_SERVICE_LOG_WARNINGS
17+
#define MYSQL_SERVICE_LOG_WARNINGS
18+
19+
/**
20+
@file
21+
This service provides access to the log warning level for the
22+
current session.
23+
24+
thd_log_warnings(thd)
25+
@return thd->log_warnings
26+
*/
27+
28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
31+
32+
extern struct thd_log_warnings_service_st {
33+
void *(*thd_log_warnings)(MYSQL_THD);
34+
} *thd_log_warnings_service;
35+
36+
#ifdef MYSQL_DYNAMIC_PLUGIN
37+
# define thd_log_warnings(THD) thd_log_warnings_service->thd_log_warnings(THD)
38+
#else
39+
/**
40+
MDL_context accessor
41+
@param thd the current session
42+
@return pointer to thd->mdl_context
43+
*/
44+
int thd_log_warnings(MYSQL_THD thd);
45+
#endif
46+
47+
#ifdef __cplusplus
48+
}
49+
#endif
50+
51+
#endif
52+

sql/sql_class.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5805,6 +5805,20 @@ extern "C" void *thd_mdl_context(MYSQL_THD thd)
58055805
return &thd->mdl_context;
58065806
}
58075807

5808+
5809+
/**
5810+
log_warnings accessor
5811+
@param thd the current session
5812+
5813+
@return log warning level
5814+
*/
5815+
5816+
extern "C" int thd_log_warnings(const MYSQL_THD thd)
5817+
{
5818+
return thd->variables.log_warnings;
5819+
}
5820+
5821+
58085822
/**
58095823
Send check/repair message to the user
58105824

storage/innobase/handler/ha_innodb.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ this program; if not, write to the Free Software Foundation, Inc.,
4848
#include <mysql/service_thd_alloc.h>
4949
#include <mysql/service_thd_wait.h>
5050
#include <mysql/service_print_check_msg.h>
51+
#include <mysql/service_log_warnings.h>
5152
#include "sql_type_geom.h"
5253
#include "scope.h"
5354
#include "srv0srv.h"
@@ -2154,8 +2155,9 @@ static void innodb_transaction_abort(THD *thd, bool all, dberr_t err) noexcept
21542155
{
21552156
ut_ad(trx->state == TRX_STATE_NOT_STARTED);
21562157
trx->state= TRX_STATE_ABORTED;
2157-
sql_print_error("InnoDB: Transaction was aborted due to %s",
2158-
ut_strerr(err));
2158+
if (thd_log_warnings(thd) >= 4)
2159+
sql_print_error("InnoDB: Transaction was aborted due to %s",
2160+
ut_strerr(err));
21592161
}
21602162
thd_mark_transaction_to_rollback(thd, all);
21612163
}

0 commit comments

Comments
 (0)