diff options
author | Sergei Petrunia <psergey@askmonty.org> | 2019-11-15 23:37:28 +0300 |
---|---|---|
committer | Sergei Petrunia <psergey@askmonty.org> | 2019-11-15 23:37:28 +0300 |
commit | 86167e908fe5de6f6e9f5076b4ea8041514d0820 (patch) | |
tree | 92815b55b229fb7ce4b55eb176e2ebc19e3b8985 /sql/ha_partition.cc | |
parent | 3d4a80153345209bad736235d4f66dcaa51a9d51 (diff) | |
download | mariadb-git-86167e908fe5de6f6e9f5076b4ea8041514d0820.tar.gz |
MDEV-20611: MRR scan over partitioned InnoDB table produces "Out of memory" error
Fix partitioning and DS-MRR to work together
- In ha_partition::index_end(): take into account that ha_innobase (and
other engines using DS-MRR) will have inited=RND when initialized for
DS-MRR scan.
- In ha_partition::multi_range_read_next(): if the MRR scan is using
HA_MRR_NO_ASSOCIATION mode, it is not guaranteed that the partition's
handler will store anything into *range_info.
- In DsMrr_impl::choose_mrr_impl(): ha_partition will inquire partitions
about how much memory their MRR implementation needs by passing
*buffer_size=0. DS-MRR code didn't know about this (actually it used
uint for buffer size calculation and would have an under-flow).
Returning *buffer_size=0 made ha_partition assume that partitions do
not need MRR memory and pass the same buffer to each of them.
Now, this is fixed. If DS-MRR gets *buffer_size=0, it will return
the amount of buffer space needed, but not more than about
@@mrr_buffer_size.
* Fix ha_{innobase,maria,myisam}::clone. If ha_partition uses MRR on its
partitions, and partition use DS-MRR, the code will call handler->clone
with TABLE (*NOT partition*) name as an argument.
DS-MRR has no way of knowing the partition name, so the solution was
to have the ::clone() function for the affected storage engine to ignore
the name argument and get it elsewhere.
Diffstat (limited to 'sql/ha_partition.cc')
-rw-r--r-- | sql/ha_partition.cc | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index ccda01de6b7..09664deb458 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -5478,6 +5478,13 @@ int ha_partition::index_end() if ((tmp= (*file)->ha_index_end())) error= tmp; } + else if ((*file)->inited == RND) + { + // Possible due to MRR + int tmp; + if ((tmp= (*file)->ha_rnd_end())) + error= tmp; + } } while (*(++file)); destroy_record_priority_queue(); DBUG_RETURN(error); @@ -6519,8 +6526,11 @@ int ha_partition::multi_range_read_next(range_id_t *range_info) else if (unlikely((error= handle_unordered_next(table->record[0], FALSE)))) DBUG_RETURN(error); - *range_info= - ((PARTITION_KEY_MULTI_RANGE *) m_range_info[m_last_part])->ptr; + if (!(m_mrr_mode & HA_MRR_NO_ASSOCIATION)) + { + *range_info= + ((PARTITION_KEY_MULTI_RANGE *) m_range_info[m_last_part])->ptr; + } } DBUG_RETURN(0); } |