Skip to content

Commit f21a875

Browse files
committed
MDEV-28415 ALTER TABLE on a large table hangs InnoDB
buf_flush_page(): Never wait for a page latch, even in checkpoint flushing (flush_type == BUF_FLUSH_LIST), to prevent a hang of the page cleaner threads when a large number of pages is latched. In mysql/mysql-server@9542f30 it was claimed that such a hang only affects CREATE FULLTEXT INDEX. Their fix was to retain buffer-fix but release exclusive latch on non-leaf pages, and subsequently write to those pages while they are not associated with the mini-transaction, which would trip a debug assertion in the MariaDB version of mtr_t::memo_modify_page() and cause potential corruption when using the default MariaDB setting innodb_log_optimize_ddl=OFF. This change essentially backports a small part of commit 7cffb5f (MDEV-23399) from MariaDB Server 10.5.7.
1 parent 3999013 commit f21a875

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

storage/innobase/buf/buf0flu.cc

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
4-
Copyright (c) 2013, 2020, MariaDB Corporation.
4+
Copyright (c) 2013, 2022, MariaDB Corporation.
55
Copyright (c) 2013, 2014, Fusion-io
66
77
This program is free software; you can redistribute it and/or modify it under
@@ -1160,15 +1160,10 @@ buf_flush_page(
11601160
/* For table residing in temporary tablespace sync is done
11611161
using IO_FIX and so before scheduling for flush ensure that
11621162
page is not fixed. */
1163-
flush = FALSE;
1163+
return FALSE;
11641164
} else {
11651165
rw_lock = &reinterpret_cast<buf_block_t*>(bpage)->lock;
1166-
if (flush_type != BUF_FLUSH_LIST) {
1167-
flush = rw_lock_sx_lock_nowait(rw_lock, BUF_IO_WRITE);
1168-
} else {
1169-
/* Will SX lock later */
1170-
flush = TRUE;
1171-
}
1166+
flush = rw_lock_sx_lock_nowait(rw_lock, BUF_IO_WRITE);
11721167
}
11731168

11741169
if (flush) {
@@ -1190,22 +1185,6 @@ buf_flush_page(
11901185

11911186
buf_pool_mutex_exit(buf_pool);
11921187

1193-
if (flush_type == BUF_FLUSH_LIST
1194-
&& is_uncompressed
1195-
&& !rw_lock_sx_lock_nowait(rw_lock, BUF_IO_WRITE)) {
1196-
1197-
if (!fsp_is_system_temporary(bpage->id.space())) {
1198-
/* avoiding deadlock possibility involves
1199-
doublewrite buffer, should flush it, because
1200-
it might hold the another block->lock. */
1201-
buf_dblwr_flush_buffered_writes();
1202-
} else {
1203-
buf_dblwr_sync_datafiles();
1204-
}
1205-
1206-
rw_lock_sx_lock_gen(rw_lock, BUF_IO_WRITE);
1207-
}
1208-
12091188
/* If there is an observer that want to know if the asynchronous
12101189
flushing was sent then notify it.
12111190
Note: we set flush observer to a page with x-latch, so we can

0 commit comments

Comments
 (0)