[MDEV-9931] InnoDB reads first page of every .ibd file at startup Created: 2016-04-15 Updated: 2020-12-08 Resolved: 2016-09-27 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB, Storage Engine - XtraDB |
| Affects Version/s: | 10.1.13 |
| Fix Version/s: | 10.1.18 |
| Type: | Bug | Priority: | Major |
| Reporter: | Geoff Montee (Inactive) | Assignee: | Jan Lindström (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | innodb | ||
| Attachments: |
|
||||||||||||||||||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||
| Sprint: | 10.1.15, 10.1.18 | ||||||||||||||||||||||||||||||||||||
| Description |
|
A user noticed that InnoDB in MariaDB 10.1 reads the first page of every .ibd file at startup, even if the server is not going through crash recovery. I understand that this would be normal behavior when the server is performing crash recovery, as explained here: https://dev.mysql.com/doc/refman/5.7/en/innodb-recovery-tablespace-discovery.html However, it seems unusual that this also happens during a normal startup. Example strace output:
The full strace output is attached as strace.out. The content of the error log confirms that crash recovery is not taking place:
|
| Comments |
| Comment by Elena Stepanova [ 2016-04-15 ] |
|
I expect that it will turn out to be an intentional change (it's for jplindst to confirm), but does it cause any real problems? |
| Comment by Geoff Montee (Inactive) [ 2016-04-15 ] |
|
It caused problems for one particular user who had over 40,000 InnoDB tables. Reading the first page of each .ibd file could take several minutes to complete at times, and this caused the user's startup time to exceed MariaDB's default systemd startup timeout. |
| Comment by Jan Lindström (Inactive) [ 2016-04-21 ] |
|
This is expected behavior because encryption information (if present) is on the first page of each .ibd file, thus when table is first accessed this information is read. Currently, this is done on system startup. Has customer all 40,000 tables on the same database ? I will research if reading the first page can be delayed to point when database is changed. |
| Comment by Daniel Black [ 2016-04-21 ] |
|
In the meantime see https://mariadb.com/kb/en/mariadb/systemd/ for increasing the TimeoutStartSec as you may have done already. |
| Comment by Elena Stepanova [ 2016-04-21 ] |
I would be very careful about it, it will make things much worse for instances where, indeed, most tables are accumulated in a few databases. Of course, there are also restarts due to crashes and other force majeur, when the DBA cannot make sure that the startup is initiated in advance, but then a recovery would happen, and as it was said before, the reading would happen anyway. Maybe a compromise worth considering (I don't know whether it's actually doable, and whether there are pitfalls in it) would be to start without the read, but immediately after that start reading first pages in the background. If the database change happens before first pages for all tables in the database have been read, then alas, the user will have to wait, but chances for that will be much less this way. Also, it can be made controllable via an option, somewhat like buffer pool pre-loading and such. |
| Comment by Joseph Marcelletti [ 2016-04-21 ] |
|
Hello, I am the customer in question. #1 - No this is not 1 DB, it is 400 DB with varying table counts.. most under 400 tables. This is semi typical in the shared hosting market. #2 - If encryption is causing this problem, perhaps an option to completely disable the encryption engine would resolve the issue? Instead of delaying reads to after start, what about a disabled-encrypted = 1 in the my.cnf to remove this? #3 - Obvious here, but your daemon searches for .isl files on start (innodb symlinks?) - Why wouldn't we have another extention to reference/mark a table as encrypted? That way a simple stat of the file determines if you need to read, and a my.cnf config would be not required. Probably a bit too late to be changing the game. I realize this situation wasn't tested in development, probably because the team assumes this is not common... but I assure you in the web hosting space it is very common.. luckily, those people usually stick to the OS prebuilt mysql/mariadb, which is still on 5.5 so they are not experiencing the issues. IMO #2 solves the problem and is safe.. I understand you can't default it to off at this point, but perhaps having it in |
| Comment by Elena Stepanova [ 2016-06-10 ] |
|
More complaints from real-life world: |
| Comment by Jan Lindström (Inactive) [ 2016-09-22 ] |
|
commit 2bedc3978b90bf5abe1029df393c63ced1849bed Analysis: By design InnoDB was reading first page of every .ibd file Fix: Do not read first page of every .ibd file at startup. Instead TODO: Add support for SYS_TABLEOPTIONS where all table options |