mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-33533: Crash at execution of DELETE when trying to use rowid filter
(Based on original patch by Oleksandr Byelkin) Multi-table DELETE can execute via "buffered" mode: at phase #1 it collects rowids of rows to be deleted, then at phase #2 in multi_delete::do_deletes() it calls handler->rnd_pos() to read rows to be deleted and deletes them. The problem occurred when phase #1 used Rowid Filter on the table that phase #2 would be deleting from. In InnoDB, h->rnd_init(scan=false) and h->rnd_pos() is an index scan over PK under the hood. So, at phase #2 ha_innobase::rnd_init() would try to use the Rowid Filter and hit an assertion inside ha_innobase::rnd_init(). Note that multi-table UPDATE works similarly but was not affected, because patch for MDEV-7487 added code to disable rowid filter for phase #2 in multi_update::do_updates(). This patch changes the approach: - It makes InnoDB not use Rowid Filter in rnd_pos() scans: it is disabled in ha_innobase::rnd_init() and enabled back in ha_innobase::rnd_end(). - multi_update::do_updates() no longer disables Rowid Filter for phase#2 as it is no longer necessary.
This commit is contained in:
committed by
Sergei Golubchik
parent
f0a5412037
commit
fe41171c96
@ -143,3 +143,111 @@ connection default;
|
||||
disconnect con2;
|
||||
drop table t1,t2;
|
||||
# End of 10.4 tests
|
||||
#
|
||||
# MDEV-33533: multi-delete using rowid filter
|
||||
#
|
||||
set @save_default_storage_engine=@@default_storage_engine;
|
||||
set default_storage_engine=InnoDB;
|
||||
CREATE DATABASE dbt3_s001;
|
||||
use dbt3_s001;
|
||||
create index i_n_name on nation(n_name);
|
||||
analyze table
|
||||
nation, lineitem, customer, orders, part, supplier, partsupp, region
|
||||
persistent for all;
|
||||
Table Op Msg_type Msg_text
|
||||
dbt3_s001.nation analyze status Engine-independent statistics collected
|
||||
dbt3_s001.nation analyze status OK
|
||||
dbt3_s001.lineitem analyze status Engine-independent statistics collected
|
||||
dbt3_s001.lineitem analyze status OK
|
||||
dbt3_s001.customer analyze status Engine-independent statistics collected
|
||||
dbt3_s001.customer analyze status OK
|
||||
dbt3_s001.orders analyze status Engine-independent statistics collected
|
||||
dbt3_s001.orders analyze status OK
|
||||
dbt3_s001.part analyze status Engine-independent statistics collected
|
||||
dbt3_s001.part analyze status OK
|
||||
dbt3_s001.supplier analyze status Engine-independent statistics collected
|
||||
dbt3_s001.supplier analyze status OK
|
||||
dbt3_s001.partsupp analyze status Engine-independent statistics collected
|
||||
dbt3_s001.partsupp analyze status OK
|
||||
dbt3_s001.region analyze status Engine-independent statistics collected
|
||||
dbt3_s001.region analyze status OK
|
||||
explain
|
||||
update orders, customer, nation set orders.o_comment = "+++" where o_orderDATE between '1992-01-01' and '1992-06-30' and
|
||||
o_custkey = c_custkey and c_nationkey = n_nationkey and n_name='PERU';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using where; Using index
|
||||
1 SIMPLE customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6 Using index
|
||||
1 SIMPLE orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (8%) Using where; Using rowid filter
|
||||
explain format=json
|
||||
update orders, customer, nation set orders.o_comment = "+++" where o_orderDATE between '1992-01-01' and '1992-06-30' and
|
||||
o_custkey = c_custkey and c_nationkey = n_nationkey and n_name='PERU';
|
||||
EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"select_id": 1,
|
||||
"cost": "COST_REPLACED",
|
||||
"nested_loop": [
|
||||
{
|
||||
"table": {
|
||||
"table_name": "nation",
|
||||
"access_type": "ref",
|
||||
"possible_keys": ["PRIMARY", "i_n_name"],
|
||||
"key": "i_n_name",
|
||||
"key_length": "26",
|
||||
"used_key_parts": ["n_name"],
|
||||
"ref": ["const"],
|
||||
"loops": 1,
|
||||
"rows": 1,
|
||||
"cost": "COST_REPLACED",
|
||||
"filtered": 100,
|
||||
"attached_condition": "nation.n_name = 'PERU'",
|
||||
"using_index": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"table": {
|
||||
"table_name": "customer",
|
||||
"access_type": "ref",
|
||||
"possible_keys": ["PRIMARY", "i_c_nationkey"],
|
||||
"key": "i_c_nationkey",
|
||||
"key_length": "5",
|
||||
"used_key_parts": ["c_nationkey"],
|
||||
"ref": ["dbt3_s001.nation.n_nationkey"],
|
||||
"loops": 1,
|
||||
"rows": 6,
|
||||
"cost": "COST_REPLACED",
|
||||
"filtered": 100,
|
||||
"using_index": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"table": {
|
||||
"table_name": "orders",
|
||||
"access_type": "ref",
|
||||
"possible_keys": ["i_o_orderdate", "i_o_custkey"],
|
||||
"key": "i_o_custkey",
|
||||
"key_length": "5",
|
||||
"used_key_parts": ["o_custkey"],
|
||||
"ref": ["dbt3_s001.customer.c_custkey"],
|
||||
"rowid_filter": {
|
||||
"range": {
|
||||
"key": "i_o_orderdate",
|
||||
"used_key_parts": ["o_orderDATE"]
|
||||
},
|
||||
"rows": 119,
|
||||
"selectivity_pct": 7.933333333
|
||||
},
|
||||
"loops": 6,
|
||||
"rows": 15,
|
||||
"cost": "COST_REPLACED",
|
||||
"filtered": 7.933333397,
|
||||
"attached_condition": "orders.o_orderDATE between '1992-01-01' and '1992-06-30'"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
update orders, customer, nation set orders.o_comment = "+++" where o_orderDATE between '1992-01-01' and '1992-06-30' and
|
||||
o_custkey = c_custkey and c_nationkey = n_nationkey and n_name='PERU';
|
||||
DROP DATABASE dbt3_s001;
|
||||
set default_storage_engine=@save_default_storage_engine;
|
||||
|
Reference in New Issue
Block a user