Skip to content

Commit 343f695

Browse files
committed
MDEV-27469: Assertion failure in defragment due to tx_read_only
In commit c5fd9aa (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.
1 parent 16b87f9 commit 343f695

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

storage/innobase/dict/dict0defrag_bg.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
3-
Copyright (c) 2016, 2021, MariaDB Corporation.
3+
Copyright (c) 2016, 2022, MariaDB Corporation.
44
55
This program is free software; you can redistribute it and/or modify it under
66
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)
253253
trx_t *trx= trx_create();
254254
trx->mysql_thd= thd;
255255
trx_start_internal(trx);
256-
dberr_t ret= lock_table_for_trx(table_stats, trx, LOCK_X);
256+
dberr_t ret= trx->read_only
257+
? DB_READ_ONLY
258+
: lock_table_for_trx(table_stats, trx, LOCK_X);
257259
if (ret == DB_SUCCESS)
258260
ret= lock_table_for_trx(index_stats, trx, LOCK_X);
259261
row_mysql_lock_data_dictionary(trx);
@@ -388,7 +390,9 @@ dict_stats_save_defrag_stats(
388390
trx_t *trx= trx_create();
389391
trx->mysql_thd= thd;
390392
trx_start_internal(trx);
391-
dberr_t ret= lock_table_for_trx(table_stats, trx, LOCK_X);
393+
dberr_t ret= trx->read_only
394+
? DB_READ_ONLY
395+
: lock_table_for_trx(table_stats, trx, LOCK_X);
392396
if (ret == DB_SUCCESS)
393397
ret= lock_table_for_trx(index_stats, trx, LOCK_X);
394398

0 commit comments

Comments
 (0)