[MDEV-23720] Change innodb_log_optimize_ddl=OFF by default Created: 2020-09-11  Updated: 2021-02-05  Resolved: 2020-10-25

Status: Closed
Project: MariaDB Server
Component/s: Backup, Storage Engine - InnoDB
Fix Version/s: 10.2.35, 10.3.26, 10.4.16

Type: Task Priority: Blocker
Reporter: Marko Mäkelä Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: deprecated_feature, not-10.5, performance

Issue Links:
Blocks
is blocked by MDEV-23399 10.5 performance regression with IO-b... Closed
Relates
relates to MDEV-23232 mysqld: storage/innobase/buf/buf0flu.... Closed
relates to MDEV-16809 Allow full redo logging for ALTER TABLE Closed
relates to MDEV-19747 Deprecate and ignore innodb_log_optim... Closed
relates to MDEV-20755 InnoDB: Database page corruption on d... Closed
relates to MDEV-21347 innodb_log_optimize_ddl=OFF is not cr... Closed

 Description   

MariaDB 10.2.2 inherited from MySQL 5.7 a perceived optimization of ALTER TABLE, which skips the writing of redo log records. In MDEV-16809 we introduced a parameter that allows the redo log to be written, so that Mariabackup would not be impacted, but we kept the MySQL 5.7 behaviour enabled by default (innodb_log_optimize_ddl=ON).

As noted in MDEV-19747, omitting the redo log writes can actually reduce performance, because we will have to wait for the data pages to be written out. When the redo log file is configured to be large enough, it actually can be much faster to write the redo log and avoid the extra page flushing. With 1 million rows, 4k page size and the data on RAM disk, I got the following numbers on 10.2 224c950462a22e09f4e2e37d19218c9129bccba6:

ON OFF statement
64.4s 28.4s ALTER TABLE t1 ADD INDEX…
40.6s 44.8s ALTER TABLE t1 FORCE

Since the time the original benchmarks for MDEV-19747 were run, the fix of the correctness bug MDEV-21347 probably increased the amount of log that is written for ALTER TABLE. Either this or the presence of the MLOG_MEMSET record in 10.4 could explain why MDEV-19747 shows that the rebuilding ALTER TABLE was not slower with the redo logging enabled. The benchmarks in MDEV-19747 were the ‘proof’ that it is safe to deprecate and ignore the parameter in 10.5 (and to always write redo log).

My primary motivation for changing the parameter is not performance but correctness, and the avoidance of bugs like MDEV-20755. In my opinion, a small decrease in ALTER TABLE performance should be a good trade-off. The suggested change of the default value can be overridden without a server restart by executing the following:

SET GLOBAL innodb_log_optimize_ddl=ON;



 Comments   
Comment by Marko Mäkelä [ 2020-09-17 ]

On popular demand, I repeated the exercise with 4 million rows and on NVMe storage instead of RAM disk, this time on 10.2 224c950462a22e09f4e2e37d19218c9129bccba6. The size of the table is multiple gigabytes already before creating the indexes, and 13GiB after creating the indexes.

ON OFF statement
98s 98s INSERT INTO t1 (a) SELECT seq FROM seq_1_to_4000000
1,240s 131s ALTER TABLE t1 ADD INDEX…
1,028s 234s ALTER TABLE t1 FORCE
0s 61s FLUSH TABLES t1 FOR EXPORT
2,366s 524s total

In this case (on real storage instead of RAM disk), we are seeing a significant performance improvement in both cases when disabling the harmful setting. The FLUSH TABLES FOR EXPORT step is not strictly necessary. It is only there to make the comparison a little more fair.

The invocation was slightly different, to keep the data in the buffer pool:

time MTR_TESTCASE_TIMEOUT=60 ./mtr --mysqld=--innodb-{page-size=4k,buffer-pool-size=32g,log-file-size=2g,log-optimize-ddl=1} innodb.benchmark
time MTR_TESTCASE_TIMEOUT=60 ./mtr --mysqld=--innodb-{page-size=4k,buffer-pool-size=32g,log-file-size=2g,log-optimize-ddl=0} innodb.benchmark

Comment by Ralf Gebhardt [ 2020-09-17 ]

Changing the default in GA releases requires more benchmarking to avoid regressions. Benchmarks need to be done after fixing MDEV-23399.

Comment by Elena Stepanova [ 2020-09-23 ]

Simultaneously with disabling innodb_log_optimize_ddl in 10.2+, I suggest to "backport" its deprecation from 10.5 to 10.2 – make it deprecated in 10.2+ as well. It provides some logic and context for disabling it in post-GA releases, and more importantly it will warn users who set it on explicitly in their configuration.

Comment by Marko Mäkelä [ 2020-10-25 ]

The parameter innodb_log_optimize_ddl will be OFF by default and documented as deprecated in information_schema.system_variables.

I did not add a deprecation warning if the parameter is set on startup or by SET GLOBAL.

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