Skip to content

Commit 5743435

Browse files
committed
MDEV-37397 Assertion `bitmap_is_set(&read_partitions, next->id)' failed in int partition_info::vers_set_hist_part(THD *)
after 6334173 (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().
1 parent ff12ec8 commit 5743435

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

mysql-test/suite/period/r/long_unique.result

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,10 @@ set transaction isolation level read committed;
3131
update t1 for portion of p from '1980-01-01' to '1980-01-02' set a = 1;
3232
ERROR 23000: Duplicate entry 'foo' for key 'f'
3333
drop table t1;
34+
#
35+
# MDEV-37397 Assertion `bitmap_is_set(&read_partitions, next->id)' failed in int partition_info::vers_set_hist_part(THD *)
36+
#
37+
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);
38+
delete from t;
39+
drop table t;
3440
# End of 10.6 tests

mysql-test/suite/period/t/long_unique.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,11 @@ set transaction isolation level read committed;
4141
update t1 for portion of p from '1980-01-01' to '1980-01-02' set a = 1;
4242
drop table t1;
4343

44+
--echo #
45+
--echo # MDEV-37397 Assertion `bitmap_is_set(&read_partitions, next->id)' failed in int partition_info::vers_set_hist_part(THD *)
46+
--echo #
47+
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);
48+
delete from t;
49+
drop table t;
50+
4451
--echo # End of 10.6 tests

sql/sql_delete.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,9 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
511511
}
512512
}
513513

514+
if (table->versioned(VERS_TIMESTAMP) || (table_list->has_period()))
515+
table->file->prepare_for_insert(1);
516+
514517
#ifdef WITH_PARTITION_STORAGE_ENGINE
515518
if (prune_partitions(thd, table, conds))
516519
{
@@ -813,8 +816,6 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
813816
&& !table->versioned()
814817
&& table->file->has_transactions();
815818

816-
if (table->versioned(VERS_TIMESTAMP) || (table_list->has_period()))
817-
table->file->prepare_for_insert(1);
818819
DBUG_ASSERT(table->file->inited != handler::NONE);
819820

820821
THD_STAGE_INFO(thd, stage_updating);

sql/sql_update.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,7 @@ int mysql_update(THD *thd,
559559

560560
// Don't count on usage of 'only index' when calculating which key to use
561561
table->covering_keys.clear_all();
562+
table->file->prepare_for_insert(1);
562563

563564
#ifdef WITH_PARTITION_STORAGE_ENGINE
564565
if (prune_partitions(thd, table, conds))
@@ -1021,7 +1022,6 @@ int mysql_update(THD *thd,
10211022
can_compare_record= records_are_comparable(table);
10221023
explain->tracker.on_scan_init();
10231024

1024-
table->file->prepare_for_insert(1);
10251025
DBUG_ASSERT(table->file->inited != handler::NONE);
10261026

10271027
THD_STAGE_INFO(thd, stage_updating);

0 commit comments

Comments
 (0)