[MDEV-28240] InnoDB Temporary Tablespace (ibtmp1) is continuously growing Created: 2022-04-04  Updated: 2022-12-14  Resolved: 2022-09-06

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.6.2, 10.7, 10.8
Fix Version/s: 10.6.10, 10.7.6, 10.8.5

Type: Bug Priority: Critical
Reporter: Oli Sennhauser Assignee: Thirunarayanan Balathandayuthapani
Resolution: Fixed Votes: 0
Labels: create, innodb, table, temporary

Attachments: File mdbmain_ibtemp1_202204041112.sql.gz    
Issue Links:
Duplicate
duplicates MDEV-26525 Replication stops because too big inn... Closed
duplicates MDEV-28183 Innodb-temp-data-file does not stop g... Closed
is duplicated by MDEV-29192 Mariadb10.6.8 runs out of disk space Closed
Problem/Incident
is caused by MDEV-25506 Atomic DDL: .frm file is removed and ... Closed
Relates
relates to MDEV-26782 InnoDB temporary tablespace: reclaimi... Closed

 Description   

If we have an Event Scheduler calling a Stored Procedure (once a second) creating an explicit temporary table (with engine InnoDB) the InnoDB temporary tablespace (ibtmp1) is continuously growing until the disk is full.

This does NOT happen with 10.5 (10.5.8 and 10.5.12 no problem) and started with 10.6 (10.6.5 it happens, 10.7.1 it happens) until 10.8. It happens on Windows and Linux (Ubuntu 18.04)

The growth rate is about 22.5 Mibyte per minute. And the temporary tablespace is growing in chuncks of 64 Mibyte.

rw-rw--- 1 mysql mysql 213909504 Apr 4 12:13 ibtmp1
rw-rw--- 1 mysql mysql 281018368 Apr 4 12:14 ibtmp1
rw-rw--- 1 mysql mysql 281018368 Apr 4 12:17 ibtmp1
rw-rw--- 1 mysql mysql 348127232 Apr 4 12:19 ibtmp1
rw-rw--- 1 mysql mysql 415236096 Apr 4 12:22 ibtmp1
rw-rw--- 1 mysql mysql 482344960 Apr 4 12:25 ibtmp1
rw-rw--- 1 mysql mysql 549453824 Apr 4 12:28 ibtmp1
rw-rw--- 1 mysql mysql 616562688 Apr 4 12:31 ibtmp1
rw-rw--- 1 mysql mysql 683671552 Apr 4 12:33 ibtmp1
rw-rw--- 1 mysql mysql 750780416 Apr 4 12:36 ibtmp1
rw-rw--- 1 mysql mysql 817889280 Apr 4 12:39 ibtmp1
rw-rw--- 1 mysql mysql 884998144 Apr 4 12:42 ibtmp1
rw-rw--- 1 mysql mysql 952107008 Apr 4 12:45 ibtmp1
rw-rw--- 1 mysql mysql 1019215872 Apr 4 12:48 ibtmp1
rw-rw--- 1 mysql mysql 1086324736 Apr 4 12:50 ibtmp1
rw-rw--- 1 mysql mysql 1153433600 Apr 4 12:53 ibtmp1
rw-rw--- 1 mysql mysql 1220542464 Apr 4 12:56 ibtmp1
rw-rw--- 1 mysql mysql 1287651328 Apr 4 12:59 ibtmp1
rw-rw--- 1 mysql mysql 1354760192 Apr 4 13:02 ibtmp1
rw-rw--- 1 mysql mysql 1421869056 Apr 4 13:04 ibtmp1
rw-rw--- 1 mysql mysql 1488977920 Apr 4 13:07 ibtmp1
rw-rw--- 1 mysql mysql 1556086784 Apr 4 13:10 ibtmp1
rw-rw--- 1 mysql mysql 1623195648 Apr 4 13:13 ibtmp1
rw-rw--- 1 mysql mysql 1690304512 Apr 4 13:16 ibtmp1
rw-rw--- 1 mysql mysql 1757413376 Apr 4 13:19 ibtmp1
rw-rw--- 1 mysql mysql 1824522240 Apr 4 13:21 ibtmp1
rw-rw--- 1 mysql mysql 1891631104 Apr 4 13:24 ibtmp1
rw-rw--- 1 mysql mysql 1958739968 Apr 4 13:27 ibtmp1
rw-rw--- 1 mysql mysql 2025848832 Apr 4 13:30 ibtmp1
rw-rw--- 1 mysql mysql 2092957696 Apr 4 13:33 ibtmp1
rw-rw--- 1 mysql mysql 2160066560 Apr 4 13:35 ibtmp1
rw-rw--- 1 mysql mysql 2227175424 Apr 4 13:38 ibtmp1
rw-rw--- 1 mysql mysql 2294284288 Apr 4 13:41 ibtmp1
rw-rw--- 1 mysql mysql 2361393152 Apr 4 13:44 ibtmp1
rw-rw--- 1 mysql mysql 2428502016 Apr 4 13:47 ibtmp1
rw-rw--- 1 mysql mysql 2495610880 Apr 4 13:50 ibtmp1
rw-rw--- 1 mysql mysql 2562719744 Apr 4 13:52 ibtmp1
rw-rw--- 1 mysql mysql 2629828608 Apr 4 13:55 ibtmp1 +64M
rw-rw--- 1 mysql mysql 2696937472 Apr 4 13:58 ibtmp1 +64M

A reproducible test case is attached. Do not forget to enable Event scheduler! The test case seems to be reproducible at will in about 1 minute... Low hanging fruit!

SET GLOBAL event_scheduler = ON;

Possible related: https://jira.mariadb.org/browse/MDEV-26782

Workaround: CREATE TEMPORARY TABLE ... ENGINE = Aria (SELECT * FROM ...)



 Comments   
Comment by Thirunarayanan Balathandayuthapani [ 2022-09-02 ]

Problem in 10.6 happens due to the following commit:

commit 1bd681c8b3c5213ce1f7976940a7dc38b48a0d39
Author: Marko Mäkelä <marko.makela@mariadb.com>
Date:   Wed Jun 9 17:02:55 2021 +0300
 
    MDEV-25506 (3 of 3): Do not delete .ibd files before commit

Problem should happen from 10.6.2. Temporary tables doesn't free any segment related to indexes.
Right now working on the fix

Comment by Thirunarayanan Balathandayuthapani [ 2022-09-02 ]

Patch is in bb-10.6-MDEV-28240

Comment by Marko Mäkelä [ 2022-09-05 ]

Thank you for locating and fixing the problem. The fix looks OK to me.

Comment by Alex [ 2022-10-28 ]

I can confirm that ibtmp1 is no longer permanently growing after updating to 10.6.10 over a month ago.

Just wondering why my initial bug-reports of this issue over a year ago (MDEV-26525) and over half a year ago (MDEV-28183) have been ignored.

Comment by Sergei Golubchik [ 2022-10-28 ]

It wasn't ignored as such, it was in the bugfixing queue. This MDEV-28240 was also in a bugfixing queue, but it had a higher priority, so it was fixed first.

Comment by Alex [ 2022-11-02 ]

Actually this issue is a duplicate of MDEV-28183 and MDEV-26525, even an exact duplicate of MDEV-28183.
So how is the priority choosen?

Generated at Thu Feb 08 09:59:10 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.