MDEV-37397 Assertion `bitmap_is_set(&read_partitions, next->id)' failed in int partition_info::vers_set_hist_part(THD *)

after 633417308f (MDEV-37312) lookup_handler is locked with F_WRLCK,
because it may be used for deleting rows.

And lookup_handler is locked with F_WRLCK after prune_partitions(),
but the main handler is locked before, and might expects all
partitions to be in the read least, non-pruned.

Let's prepare the lookup handler before prune_partitions().
This commit is contained in:
Sergei Golubchik 2025-09-03 18:56:13 +02:00
parent ff12ec86a5
commit 5743435954
4 changed files with 17 additions and 3 deletions

View File

@ -31,4 +31,10 @@ set transaction isolation level read committed;
update t1 for portion of p from '1980-01-01' to '1980-01-02' set a = 1;
ERROR 23000: Duplicate entry 'foo' for key 'f'
drop table t1;
#
# MDEV-37397 Assertion `bitmap_is_set(&read_partitions, next->id)' failed in int partition_info::vers_set_hist_part(THD *)
#
create table t (f int,s date,e date,period for p (s,e),unique (f,p without overlaps)) with system versioning partition by system_time limit+1 (partition p history,partition pn current);
delete from t;
drop table t;
# End of 10.6 tests

View File

@ -41,4 +41,11 @@ set transaction isolation level read committed;
update t1 for portion of p from '1980-01-01' to '1980-01-02' set a = 1;
drop table t1;
--echo #
--echo # MDEV-37397 Assertion `bitmap_is_set(&read_partitions, next->id)' failed in int partition_info::vers_set_hist_part(THD *)
--echo #
create table t (f int,s date,e date,period for p (s,e),unique (f,p without overlaps)) with system versioning partition by system_time limit+1 (partition p history,partition pn current);
delete from t;
drop table t;
--echo # End of 10.6 tests

View File

@ -511,6 +511,9 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
}
}
if (table->versioned(VERS_TIMESTAMP) || (table_list->has_period()))
table->file->prepare_for_insert(1);
#ifdef WITH_PARTITION_STORAGE_ENGINE
if (prune_partitions(thd, table, conds))
{
@ -813,8 +816,6 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
&& !table->versioned()
&& table->file->has_transactions();
if (table->versioned(VERS_TIMESTAMP) || (table_list->has_period()))
table->file->prepare_for_insert(1);
DBUG_ASSERT(table->file->inited != handler::NONE);
THD_STAGE_INFO(thd, stage_updating);

View File

@ -559,6 +559,7 @@ int mysql_update(THD *thd,
// Don't count on usage of 'only index' when calculating which key to use
table->covering_keys.clear_all();
table->file->prepare_for_insert(1);
#ifdef WITH_PARTITION_STORAGE_ENGINE
if (prune_partitions(thd, table, conds))
@ -1021,7 +1022,6 @@ update_begin:
can_compare_record= records_are_comparable(table);
explain->tracker.on_scan_init();
table->file->prepare_for_insert(1);
DBUG_ASSERT(table->file->inited != handler::NONE);
THD_STAGE_INFO(thd, stage_updating);