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
This commit is contained in:
Monty 2025-01-02 15:15:22 +02:00
parent 130d6f9c4b
commit a2d37705ca
3 changed files with 70 additions and 2 deletions

View file

@ -0,0 +1,52 @@
/* Copyright (c) 2013, 2018, MariaDB
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
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
#ifndef MYSQL_SERVICE_LOG_WARNINGS
#define MYSQL_SERVICE_LOG_WARNINGS
/**
@file
This service provides access to the log warning level for the
current session.
thd_log_warnings(thd)
@return thd->log_warnings
*/
#ifdef __cplusplus
extern "C" {
#endif
extern struct thd_log_warnings_service_st {
void *(*thd_log_warnings)(MYSQL_THD);
} *thd_log_warnings_service;
#ifdef MYSQL_DYNAMIC_PLUGIN
# define thd_log_warnings(THD) thd_log_warnings_service->thd_log_warnings(THD)
#else
/**
MDL_context accessor
@param thd the current session
@return pointer to thd->mdl_context
*/
int thd_log_warnings(MYSQL_THD thd);
#endif
#ifdef __cplusplus
}
#endif
#endif

View file

@ -5805,6 +5805,20 @@ extern "C" void *thd_mdl_context(MYSQL_THD thd)
return &thd->mdl_context; return &thd->mdl_context;
} }
/**
log_warnings accessor
@param thd the current session
@return log warning level
*/
extern "C" int thd_log_warnings(const MYSQL_THD thd)
{
return thd->variables.log_warnings;
}
/** /**
Send check/repair message to the user Send check/repair message to the user

View file

@ -48,6 +48,7 @@ this program; if not, write to the Free Software Foundation, Inc.,
#include <mysql/service_thd_alloc.h> #include <mysql/service_thd_alloc.h>
#include <mysql/service_thd_wait.h> #include <mysql/service_thd_wait.h>
#include <mysql/service_print_check_msg.h> #include <mysql/service_print_check_msg.h>
#include <mysql/service_log_warnings.h>
#include "sql_type_geom.h" #include "sql_type_geom.h"
#include "scope.h" #include "scope.h"
#include "srv0srv.h" #include "srv0srv.h"
@ -2154,8 +2155,9 @@ static void innodb_transaction_abort(THD *thd, bool all, dberr_t err) noexcept
{ {
ut_ad(trx->state == TRX_STATE_NOT_STARTED); ut_ad(trx->state == TRX_STATE_NOT_STARTED);
trx->state= TRX_STATE_ABORTED; trx->state= TRX_STATE_ABORTED;
sql_print_error("InnoDB: Transaction was aborted due to %s", if (thd_log_warnings(thd) >= 4)
ut_strerr(err)); sql_print_error("InnoDB: Transaction was aborted due to %s",
ut_strerr(err));
} }
thd_mark_transaction_to_rollback(thd, all); thd_mark_transaction_to_rollback(thd, all);
} }