Commit 343f695c authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-27469: Assertion failure in defragment due to tx_read_only

In commit c5fd9aa5 (MDEV-25919)
we prevented the function dict_stats_save_index_stat()
from being called in read-only mode in dict_stats_save(),
but not elsewhere.

dict_stats_save_defrag_summary(), dict_stats_save_defrag_stats():
If the transaction is in read-only mode, return DB_READ_ONLY
and do not attempt to lock or modify anything.
parent 16b87f98
/*****************************************************************************
Copyright (c) 2016, 2021, MariaDB Corporation.
Copyright (c) 2016, 2022, 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 the Free Software
......@@ -253,7 +253,9 @@ dberr_t dict_stats_save_defrag_summary(dict_index_t *index, THD *thd)
trx_t *trx= trx_create();
trx->mysql_thd= thd;
trx_start_internal(trx);
dberr_t ret= lock_table_for_trx(table_stats, trx, LOCK_X);
dberr_t ret= trx->read_only
? DB_READ_ONLY
: lock_table_for_trx(table_stats, trx, LOCK_X);
if (ret == DB_SUCCESS)
ret= lock_table_for_trx(index_stats, trx, LOCK_X);
row_mysql_lock_data_dictionary(trx);
......@@ -388,7 +390,9 @@ dict_stats_save_defrag_stats(
trx_t *trx= trx_create();
trx->mysql_thd= thd;
trx_start_internal(trx);
dberr_t ret= lock_table_for_trx(table_stats, trx, LOCK_X);
dberr_t ret= trx->read_only
? DB_READ_ONLY
: lock_table_for_trx(table_stats, trx, LOCK_X);
if (ret == DB_SUCCESS)
ret= lock_table_for_trx(index_stats, trx, LOCK_X);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment