[MDEV-33009] Server hangs for a long time with innodb_undo_log_truncate=ON Created: 2023-12-13 Updated: 2024-01-10 Resolved: 2023-12-19 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Affects Version/s: | 10.5, 10.6, 10.11, 11.0, 11.1, 11.2, 11.3 |
| Fix Version/s: | 10.5.24, 10.6.17, 10.11.7, 11.0.5, 11.1.4, 11.2.3, 11.3.2 |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Marko Mäkelä | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | hang, performance | ||
| Environment: |
Ubuntu 18.04 on AMD64 |
||
| Attachments: |
|
||||||||||||||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||||||||||||||
| Description |
|
After implementing
There is some indication that buf_flush_list_batch() may be making some progress (writing out some pages), but it would be extremely slow. |
| Comments |
| Comment by Axel Schwenke [ 2023-12-13 ] | ||
|
The fix works for Enterprise 10.6, but not for 10.5. Attached: mariadb-ES-10.5-MDEV-33009.zip | ||
| Comment by Axel Schwenke [ 2023-12-13 ] | ||
| Comment by Marko Mäkelä [ 2023-12-13 ] | ||
|
For 10.5 we apparently need a more intrusive version of trx_purge_truncate_history() that will acquire and release buf_pool.mutex on every block that it finds in the to-be-truncated tablespace. The successfully tested fix for 10.6 will only acquire and release buf_pool.mutex when a page latch had to be waited for. | ||
| Comment by Axel Schwenke [ 2023-12-13 ] | ||
|
10.6- | ||
| Comment by Axel Schwenke [ 2023-12-13 ] | ||
|
10.5-enterprise- | ||
| Comment by Matthias Leich [ 2023-12-13 ] | ||
|
| ||
| Comment by Marko Mäkelä [ 2023-12-14 ] | ||
|
On 10.5-enterprise, axel reproduced other hangs that involve buffer pool page access during undo tablespace truncation. Yesterday I checked one case where the undo tablespace truncation is in progress and both buf_pool.mutex and buf_pool.flush_list_mutex (which these patches affect) are vacant. There was a deadlock on page latches, and trx_rsegf_get() was one of the blocked functions. This reminds me of The stack trace samples in mariadb-ES-10.5-MDEV-33009-fb800bd29ab.zip At the point of the wait for the page latch, Thread 52 should only hold a rollback segment mutex and wait for the undo page 3 in tablespace 2. I do not think that any other thread should be holding that rollback segment header page latch. It could be that we are facing a bug in the original InnoDB rw-lock implementation, which was fixed in I am afraid that the fix of those page latch related hangs would be to apply | ||
| Comment by Marko Mäkelä [ 2023-12-14 ] | ||
|
axel, after some digging, I found MDEV-26733 that has been filed for the page latch related hang on 10.5. | ||
| Comment by Marko Mäkelä [ 2023-12-14 ] | ||
|
Short of acquiring also buf_pool.mutex around the buf_pool.flush_list traversal loop of the 10.5 trx_purge_truncate_history(), there does not seem to be any way to avoid those hangs on Ubuntu 18.04. (And the MDEV-26733 page latch leaks would come on top of that.) I would like to know if these hangs are repeatable in any other environment. I would not want to acquire and release the already busy buf_pool.mutex for no apparent reason, only to ‘please’ the Linux kernel or GNU libc version that is running in one performance testing environment. Ubuntu 18.04 reached its end-of-life already in April 2023, and this system is not even running the latest kernel. | ||
| Comment by Axel Schwenke [ 2023-12-15 ] | ||
|
The 10.6 fix for this issue (branch 10.6- | ||
| Comment by Marko Mäkelä [ 2023-12-15 ] | ||
|
The extreme waits are reproducible also on Ubuntu 20.04, on both 10.5 and 10.6. | ||
| Comment by Marko Mäkelä [ 2023-12-15 ] | ||
|
I got another idea: We’d better release and reacquire buf_pool.flush_list_mutex when trx_purge_truncate_history() needs to rescan the buf_pool.flush_list. If this is not sufficient to prevent the performance drops, then we’d also have to ‘dummily’ acquire and release the buf_pool.mutex. | ||
| Comment by Axel Schwenke [ 2023-12-15 ] | ||
|
Both 10.5 (branch 10.5- I don't think we can leave the server in this state. It may be better to have a slow server than to have corruption though. IMHO we need a big fat warning in the KB besides innodb_undo_log_truncate=ON. | ||
| Comment by Axel Schwenke [ 2023-12-15 ] | ||
|
results for 10.6: mariadb-10.6-MDEV-33009-76b99fccb44.zip | ||
| Comment by Marko Mäkelä [ 2023-12-15 ] | ||
|
I pushed the 10.5 version. Yes, it is somewhat slower than before the fix of The 10.6 version needs more work. I will add the trick of ‘unnecessarily’ acquiring buf_pool.mutex in order to ensure progress of the buf_flush_page_cleaner() thread. | ||
| Comment by Mason Sharp [ 2023-12-15 ] | ||
|
marko is the performance dip only when innodb_undo_log_truncate=ON? | ||
| Comment by Axel Schwenke [ 2023-12-18 ] | ||
|
Here is a summary plot of the performance/behavior of various 10.5 and 10.6 commits for community server. 4 commits are shown:
Attachment: 24x5_high_threads.pdf the tests with data set size 12x5 (12 thd) and data set size 24x5 (24 thd) did not make the undo logs grow and thus caused no truncate operation. It seems the pink line gives the best (but not good) result. | ||
| Comment by Marko Mäkelä [ 2023-12-18 ] | ||
|
Yes, this bug occurs during a scan of dirty pages that is enabled by setting innodb_undo_log_truncate=ON. | ||
| Comment by Axel Schwenke [ 2023-12-19 ] | ||
|
commit 9682add5cdf "solves" the problem with performance, but effectively prevents undo log truncates during the benchmark. This can be clearly seen in the history list length here: When we stop sysbench for 20 seconds every 6 minutes, the purge thread and with it the undo log trucate can run: When we include 9682add5cdf we should add a KB comment that innodb_undo_log_truncate=ON will only have an effect when there are times when the server is not under stress. | ||
| Comment by Marko Mäkelä [ 2023-12-19 ] | ||
|
axel, the commit that you mentioned only modifies some code that would be run after the InnoDB: Truncating message has been written to the server error log, to truncate an undo log tablespace. By design, the purge of history during a heavy workload is hard to predict. You might see some undo log truncation events during a workload if you let the workload run for a significantly longer time. In the bottom graph of 24x5_high_threads.pdf Based on these results, I think that the setting innodb_undo_log_truncate=ON may only be useful when the concurrent write workload is light or moderate. | ||
| Comment by Marko Mäkelä [ 2023-12-22 ] | ||
|
I filed |