Skip to content

Commit 310dff5

Browse files
committed
MDEV-25783: Change buffer records are lost under heavy load
ibuf_read_merge_pages(): Disable some code that was added in MDEV-20394 in order to avoid a server hang if the change buffer is corrupted, presumably due to the race condition in recovery that was later fixed in MDEV-24449. The code will still be available in debug builds when the command line option --debug=d,ibuf_merge_corruption is specified. Due to MDEV-19514, the impact of this code is much worse starting with the 10.5 series. In older versions, the code was only enabled during a shutdown with innodb_fast_shutdown=0, but in 10.5 it was active during the normal operation of the server.
1 parent f456e71 commit 310dff5

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

storage/innobase/ibuf/ibuf0ibuf.cc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2296,9 +2296,11 @@ bool ibuf_delete_rec(const page_id_t page_id, btr_pcur_t* pcur,
22962296
static void ibuf_read_merge_pages(const uint32_t* space_ids,
22972297
const uint32_t* page_nos, ulint n_stored)
22982298
{
2299+
#ifndef DBUG_OFF
22992300
mem_heap_t* heap = mem_heap_create(512);
23002301
ulint dops[IBUF_OP_COUNT];
23012302
memset(dops, 0, sizeof(dops));
2303+
#endif
23022304

23032305
for (ulint i = 0; i < n_stored; i++) {
23042306
const ulint space_id = space_ids[i];
@@ -2331,6 +2333,28 @@ static void ibuf_read_merge_pages(const uint32_t* space_ids,
23312333
goto tablespace_deleted;
23322334
}
23332335
}
2336+
#ifndef DBUG_OFF
2337+
DBUG_EXECUTE_IF("ibuf_merge_corruption", goto work_around;);
2338+
continue;
2339+
2340+
/* The following code works around a hang when the
2341+
change buffer is corrupted, likely due to the race
2342+
condition in crash recovery that was fixed in
2343+
MDEV-24449. But, it also introduces corruption by
2344+
itself in the following scenario:
2345+
2346+
(1) We merged buffered changes in buf_page_get_gen()
2347+
(2) We committed the mini-transaction
2348+
(3) Redo log and the page with the merged changes is written
2349+
(4) A write completion callback thread evicts the page.
2350+
(5) Other threads buffer changes for that page.
2351+
(6) We will wrongly discard those newly buffered changes below.
2352+
2353+
This code will be available in debug builds, so that
2354+
users may try to fix a shutdown hang that occurs due
2355+
to a corrupted change buffer. */
2356+
2357+
work_around:
23342358
/* Prevent an infinite loop, by removing entries from
23352359
the change buffer also in the case the bitmap bits were
23362360
wrongly clear even though buffered changes exist. */
@@ -2377,10 +2401,13 @@ static void ibuf_read_merge_pages(const uint32_t* space_ids,
23772401
ibuf_mtr_commit(&mtr);
23782402
btr_pcur_close(&pcur);
23792403
mem_heap_empty(heap);
2404+
#endif
23802405
}
23812406

2407+
#ifndef DBUG_OFF
23822408
ibuf_add_ops(ibuf.n_discarded_ops, dops);
23832409
mem_heap_free(heap);
2410+
#endif
23842411
}
23852412

23862413
/*********************************************************************//**

0 commit comments

Comments
 (0)