Skip to content

Commit 717e3b3

Browse files
committed
Merge 10.6 into 10.9
2 parents 2763f73 + c271057 commit 717e3b3

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

storage/innobase/buf/buf0rea.cc

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ buf_read_ahead_linear(const page_id_t page_id, ulint zip_size, bool ibuf)
525525

526526
/* We will check that almost all pages in the area have been accessed
527527
in the desired order. */
528-
const bool descending= page_id == low;
528+
const bool descending= page_id != low;
529529

530530
if (!descending && page_id != high_1)
531531
/* This is not a border page of the area */
@@ -555,7 +555,7 @@ buf_read_ahead_linear(const page_id_t page_id, ulint zip_size, bool ibuf)
555555
uint32_t{buf_pool.read_ahead_area});
556556
page_id_t new_low= low, new_high_1= high_1;
557557
unsigned prev_accessed= 0;
558-
for (page_id_t i= low; i != high_1; ++i)
558+
for (page_id_t i= low; i <= high_1; ++i)
559559
{
560560
buf_pool_t::hash_chain &chain= buf_pool.page_hash.cell_get(i.fold());
561561
transactional_shared_lock_guard<page_hash_latch> g
@@ -583,12 +583,21 @@ buf_read_ahead_linear(const page_id_t page_id, ulint zip_size, bool ibuf)
583583
if (prev == FIL_NULL || next == FIL_NULL)
584584
goto fail;
585585
page_id_t id= page_id;
586-
if (descending && next - 1 == page_id.page_no())
587-
id.set_page_no(prev);
588-
else if (!descending && prev + 1 == page_id.page_no())
589-
id.set_page_no(next);
586+
if (descending)
587+
{
588+
if (id == high_1)
589+
++id;
590+
else if (next - 1 != page_id.page_no())
591+
goto fail;
592+
else
593+
id.set_page_no(prev);
594+
}
590595
else
591-
goto fail; /* Successor or predecessor not in the right order */
596+
{
597+
if (prev + 1 != page_id.page_no())
598+
goto fail;
599+
id.set_page_no(next);
600+
}
592601

593602
new_low= id - (id.page_no() % buf_read_ahead_area);
594603
new_high_1= new_low + (buf_read_ahead_area - 1);
@@ -620,7 +629,7 @@ buf_read_ahead_linear(const page_id_t page_id, ulint zip_size, bool ibuf)
620629
/* If we got this far, read-ahead can be sensible: do it */
621630
count= 0;
622631
for (ulint ibuf_mode= ibuf ? BUF_READ_IBUF_PAGES_ONLY : BUF_READ_ANY_PAGE;
623-
new_low != new_high_1; ++new_low)
632+
new_low <= new_high_1; ++new_low)
624633
{
625634
if (ibuf_bitmap_page(new_low, zip_size))
626635
continue;

0 commit comments

Comments
 (0)