| Bug #105493 | No need to drop AHI and remove dict_table_t from cache for alter_part_normal | ||
|---|---|---|---|
| Submitted: | 8 Nov 2021 12:36 | Modified: | 8 Nov 2021 12:38 |
| Reporter: | Hope Lee (OCA) | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | MySQL Server: InnoDB storage engine | Severity: | S3 (Non-critical) |
| Version: | 8.0.27 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | contributions | ||
[8 Nov 2021 12:36]
Hope Lee
[Refactor] Don't drop AHI and remove cache for partitions not involved in DDL (*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.
Contribution: 0001-Refactor-Don-t-drop-AHI-and-remove-cache-for-partiti.patch (application/octet-stream, text), 1.60 KiB.
[8 Nov 2021 12:38]
MySQL Verification Team
Hello Lee, Thank you for the report and contributions. regards, Umesh

Description: During partition maintenance operations like ALTER TABLE ... ADD / DROP PARTITION, partitions not involved are represented by class `alter_part_normal`. The DDL drops AHI and removes table cache for these partitions, which is unnecessary. What's more, it causes the following queries on these partitions to lose the acceleration of AHI. How to repeat: Look at the pieces of codes in class `alter_part_normal`, around line 8598 in storage/innobase/handler/handler0alter.cc: /** Try to commit @param[in]» table» » Table definition before the ALTER @param[in,out]» altered_table» Table definition after the ALTER @param[in]» old_part» the stored old partition or nullptr if no corresponding one exists @param[in,out]» new_part» the stored new partition or nullptr if no corresponding one exists @return 0 or error number */ int try_commit(const TABLE *table, TABLE *altered_table, const dd::Partition *old_part, dd::Partition *new_part) override { ut_ad(m_old != nullptr); btr_drop_ahi_for_table(*m_old); dict_sys_mutex_enter(); dd_table_close(*m_old, nullptr, nullptr, true); dict_table_remove_from_cache(*m_old); *m_old = nullptr; dict_sys_mutex_exit(); return (0); } Actually, the data and index for these partitions should not be influenced by the DDL which doesn't do any changes to them. Suggested fix: Remove the overridden function, and make it inherit from the base class. Do nothing when committing for these partitions not involved in DDL.