Browse Source

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().
bb-10.6-mdev-36058-hf
Sergei Golubchik 1 month ago
parent
commit
5743435954
  1. 6
      mysql-test/suite/period/r/long_unique.result
  2. 7
      mysql-test/suite/period/t/long_unique.test
  3. 5
      sql/sql_delete.cc
  4. 2
      sql/sql_update.cc

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

@ -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

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

@ -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

5
sql/sql_delete.cc

@ -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);

2
sql/sql_update.cc

@ -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);

Loading…
Cancel
Save