Merge branch '10.6' into 10.11

This commit is contained in:
Yuchen Pei 2025-12-19 14:18:11 +11:00
commit 15fa5351cd
No known key found for this signature in database
GPG key ID: 3DD1B35105743563
12 changed files with 114 additions and 52 deletions

View file

@ -1147,6 +1147,7 @@ dummy_empty:
goto dummy_empty;
#endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */
} else if (dict_index_is_online_ddl(index) || !index->is_committed()
|| !index->is_btree()
|| !index->table->space) {
goto dummy_empty;
} else {

View file

@ -3012,8 +3012,9 @@ page_zip_decompress_low(
/* Check that the bytes that we skip are identical. */
#if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
ut_a(!memcmp(FIL_PAGE_TYPE + page,
FIL_PAGE_TYPE + page_zip->data,
PAGE_HEADER - FIL_PAGE_TYPE));
FIL_PAGE_TYPE + page_zip->data, 2));
ut_a(!memcmp(FIL_PAGE_SPACE_ID + page,
FIL_PAGE_SPACE_ID + page_zip->data, 4));
ut_a(!memcmp(PAGE_HEADER + PAGE_LEVEL + page,
PAGE_HEADER + PAGE_LEVEL + page_zip->data,
PAGE_DATA - (PAGE_HEADER + PAGE_LEVEL)));
@ -3027,7 +3028,8 @@ page_zip_decompress_low(
#if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
/* Check that the page headers match after copying. */
ut_a(!memcmp(page, page_zip->data, PAGE_DATA));
ut_a(!memcmp(page_zip->data + FIL_PAGE_DATA,
page + FIL_PAGE_DATA, PAGE_DATA - FIL_PAGE_DATA));
#endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */
}

View file

@ -3036,17 +3036,23 @@ int ha_maria::start_stmt(THD *thd, thr_lock_type lock_type)
Reset THD_TRN and all file->trn related to the transaction
This is needed as some calls, like extra() or external_lock() may access
it before next transaction is started
Note that trn for the table is already freed and may be reused by another
thread.
*/
static void reset_thd_trn(THD *thd, MARIA_HA *first_table)
{
MARIA_HA *next;
TRN *trn __attribute__((unused)) = first_table ? first_table->trn : 0;
DBUG_ENTER("reset_thd_trn");
thd_set_ha_data(thd, maria_hton, 0);
MARIA_HA *next;
for (MARIA_HA *table= first_table; table ; table= next)
{
DBUG_ASSERT(table->trn == trn);
next= table->trn_next;
_ma_reset_trn_for_table(table);
table->trn_prev= 0;
table->trn_next= 0;
table->trn= 0;
/*
If table has changed by this statement, invalidate it from the query
@ -3129,13 +3135,15 @@ int ha_maria::implicit_commit(THD *thd, bool new_trn)
statement assuming they have a trn (see ha_maria::start_stmt()).
*/
trn= trnman_new_trn(& thd->transaction->wt);
thd_set_ha_data(thd, maria_hton, trn);
if (unlikely(trn == NULL))
{
reset_thd_trn(thd, used_tables);
reset_thd_trn(thd, used_tables); // Calls thd_set_ha_data()
error= HA_ERR_OUT_OF_MEM;
goto end;
}
else
thd_set_ha_data(thd, maria_hton, trn);
/*
Move all locked tables to the new transaction
We must do it here as otherwise file->thd and file->state may be
@ -3150,6 +3158,14 @@ int ha_maria::implicit_commit(THD *thd, bool new_trn)
trn_next= handler->trn_next;
DBUG_ASSERT(handler->s->base.born_transactional);
/*
We reset the link to the old trn to avoid the asserts
in _ma_set_trn_for_table()
*/
handler->trn_next= 0;
handler->trn_prev= 0;
handler->trn= 0;
/* If handler uses versioning */
if (handler->s->lock_key_trees)
{
@ -3583,7 +3599,6 @@ static int maria_commit(handlerton *hton __attribute__ ((unused)),
if (ma_commit(trn))
res= HA_ERR_COMMIT_ERROR;
reset_thd_trn(thd, used_instances);
thd_set_ha_data(thd, maria_hton, 0);
DBUG_RETURN(res);
}

View file

@ -31,6 +31,10 @@ static inline void _ma_set_trn_for_table(MARIA_HA *tbl, TRN *newtrn)
/* check that we are not calling this twice in a row */
DBUG_ASSERT(newtrn->used_instances != (void*) tbl);
DBUG_ASSERT(newtrn != &dummy_transaction_object);
DBUG_ASSERT(tbl->trn == 0);
DBUG_ASSERT(tbl->trn_next == 0);
DBUG_ASSERT(tbl->trn_prev == 0);
tbl->trn= newtrn;
/* Link into used list */
@ -63,17 +67,25 @@ static inline void _ma_set_tmp_trn_for_table(MARIA_HA *tbl, TRN *newtrn)
static inline void _ma_reset_trn_for_table(MARIA_HA *tbl)
{
TRN *trn __attribute__((unused))= tbl->trn;
DBUG_PRINT("info",("table: %p trn: %p -> NULL", tbl, tbl->trn));
/* The following is only false if tbl->trn == &dummy_transaction_object */
if (tbl->trn_prev)
{
if (tbl->trn_next)
{
DBUG_ASSERT(tbl->trn_next->trn == trn);
tbl->trn_next->trn_prev= tbl->trn_prev;
}
*tbl->trn_prev= tbl->trn_next;
tbl->trn_prev= 0;
tbl->trn_next= 0;
}
else
{
DBUG_ASSERT(tbl->trn_next == 0);
}
tbl->trn= 0;
}

View file

@ -0,0 +1,18 @@
include/master-slave.inc
[connection master]
connection slave;
INSTALL SONAME 'ha_spider';
connection master;
CREATE TABLE t (a INT) ENGINE=InnoDB;
XA START 'x';
INSERT INTO t VALUES (1),(2);
XA END 'x';
XA PREPARE 'x';
XA COMMIT 'x';
connection slave;
connection master;
DROP TABLE t;
connection slave;
Warnings:
Warning 1620 Plugin is busy and will be uninstalled on shutdown
include/rpl_end.inc

View file

@ -0,0 +1 @@
!include ../../../../../../mysql-test/suite/rpl/rpl_1slave_base.cnf

View file

@ -0,0 +1,24 @@
--source include/have_innodb.inc
--source include/master-slave.inc
--connection slave
INSTALL SONAME 'ha_spider';
# set spider_internal_xa=1; # no use
--connection master
CREATE TABLE t (a INT) ENGINE=InnoDB;
XA START 'x';
INSERT INTO t VALUES (1),(2);
XA END 'x';
XA PREPARE 'x';
XA COMMIT 'x';
--sync_slave_with_master
--connection master
DROP TABLE t;
--connection slave
--disable_query_log
--source ../../include/clean_up_spider.inc
--source include/rpl_end.inc

View file

@ -2343,8 +2343,6 @@ int spider_internal_xa_commit_by_xid(
table_xa->file->print_error(error_num, MYF(0));
goto error;
}
my_message(ER_SPIDER_XA_NOT_EXISTS_NUM, ER_SPIDER_XA_NOT_EXISTS_STR,
MYF(0));
error_num = ER_SPIDER_XA_NOT_EXISTS_NUM;
goto error;
}