Bug #113312 | Server stall during Alter/Drop table while clearing AHIs from the buffer pool | ||
---|---|---|---|
Submitted: | 1 Dec 2023 22:48 | Modified: | 8 Feb 2024 13:18 |
Reporter: | Mershad Irani | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: InnoDB storage engine | Severity: | S2 (Serious) |
Version: | 8.0.35, 8.1.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[1 Dec 2023 22:48]
Mershad Irani
[4 Dec 2023 13:37]
MySQL Verification Team
Hello Mershad Irani, Thank you for the report and feedback. I'm trying to reproduce with the provided details and would get back to you if anything further needed(surely, going to take a long time in the load step, in test step etc). This reminds me of my former colleague Jesper's Bug #91977 and mostly looks identical as you rightly mentioned. In any case, will try to reproduce. Thank you. Sincerely, Umesh
[5 Dec 2023 7:41]
MySQL Verification Team
Hello Mershad Irani, Thank you for the details steps. Verified as described. For now, not marking this as a duplicate of Bug #91977 as Bug #91977 was supposed to be fixed per [30 Oct 2020 15:30] Sunny Bains The fix has been pushed and should be in the next 8.x release. All truncate/drop tables will be instant. This underlying issues is the same as Bug#98869. regards, Umesh
[5 Dec 2023 8:00]
MySQL Verification Team
Test results - 8.0.35
Attachment: 113312_8.0.35.log (application/octet-stream, text), 20.79 KiB.
[5 Dec 2023 17:08]
Mershad Irani
Hi Uday, Thank you for the confirmation. Glad to know that the issue will be fixed in next release. Would it be possible for you to confirm if this will also fix the issue during the table dropping phase with "Alter tables ?" For example, Changing the data type of a column. I see a bug where, ALTER TABLE...ALGORITHM=INSTANT also stalls on AHI drop. https://bugs.mysql.com/bug.php?id=107308 Also, when you mention next 8.x release, would this be 8.0.36 or 8.0.37 ?
[5 Dec 2023 18:54]
Mershad Irani
Apologies for the typo in the addressed name in the previous comment. I was referring to "Umesh".
[6 Dec 2023 21:36]
Nuno P
I wonder if this is what I have been battling with, for the past weeks. I'm on 8.0.33, and I have a cronjob that updates the contents of a table from a CSV file. The cronjob runs a "LOAD DATA LOCAL INFILE" into a new table, then a set of "RENAME TABLE" to swap the tables, and then "DROP TABLE" to delete the renamed old table. The "DROP TABLE" is taking 3 seconds, and during that time, I get a number of logs saying that a number of concurrent "SELECT" queries took too long. Those "SELECT" tables are on another database (on the same MySQL server), and have absolutely nothing to do with this table. I've been trying a number of things, such as using "TRUNCATE/OPTIMIZE/DROP" instead (but looks like "TRUNCATE" is an alias to "DROP/CREATE" anyway), add "SLEEP(5)" in between the queries, etc... nothing improves. The table isn't even that big... just 350MB and 1 secondary index. Is this the same issue described here? I've recently migrated from MariaDB to MySQL, and I don't recall ever having this issue with MariaDB. Thank you very much.
[6 Dec 2023 21:47]
Jean-François Gagné
> I've recently migrated from MariaDB to MySQL, and I don't recall ever having this issue with MariaDB. The AHI (InnoDB adaptive hash index) is disabled in MariaDB 10.5+ [1] while it is enabled in MySQL 8.0 [2]. I would suggest disabling it in MySQL and seeing if this solves the problem. [1]: https://mariadb.com/kb/en/innodb-system-variables/#innodb_adaptive_hash_index [2]: https://dev.mysql.com/doc/refman/8.0/en/innodb-parameters.html#sysvar_innodb_adaptive_hash...
[7 Dec 2023 8:44]
Nuno P
Thank you very much. I've changed that variable to OFF (dynamically, without restarting), and will let you know what happens next time the cron runs.
[9 Dec 2023 19:03]
Nuno P
Looks like `innodb_adaptive_hash_index = OFF` resolved the issue for me !! Thank you very much!
[8 Feb 2024 13:18]
Mershad Irani
Hi Umesh, Hope you are doing well. Do we know which version of MySQL 8 will have this fixed ? Regards, Mershad
[2 May 2024 6:18]
MySQL Verification Team
Please note that in 8.4 we have AHI disabled by default, please see https://dev.mysql.com/doc/relnotes/mysql/8.4/en/news-8-4-0.html https://dev.mysql.com/doc/refman/8.4/en/innodb-parameters.html#sysvar_innodb_adaptive_hash...
[23 Oct 2024 11:29]
Satya Bodapati
Marcos Albe told me this bug still exists and I was surprised and I told him lazy eviction of dropped tablesapce pages is implemented, so it shouldn't exist. but alas, I see that btr_drop_ahi_for_table() exists! The problem is how AHI records are hashed. They don't use the space_id or a table_id when hashing records. AHI uses record field and prefixes to hash. So even if a page is lazily is evicted, it needs a table definition after its dropped. This is a design problem. It can be solved either with improved hashing or saving in-memory table definitions (dict_table_t/dict_index_ts) for deferred freeing. Now the questions, AHI is now OFF by default in 8.4 and I believe this feature might be soon neglected/deprecated/dying. Is it worth the effort? We can turn AHI off and live with these bugs!