@@ -525,7 +525,7 @@ buf_read_ahead_linear(const page_id_t page_id, ulint zip_size, bool ibuf)
525
525
526
526
/* We will check that almost all pages in the area have been accessed
527
527
in the desired order. */
528
- const bool descending= page_id = = low;
528
+ const bool descending= page_id ! = low;
529
529
530
530
if (!descending && page_id != high_1)
531
531
/* 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)
555
555
uint32_t {buf_pool.read_ahead_area });
556
556
page_id_t new_low= low, new_high_1= high_1;
557
557
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)
559
559
{
560
560
buf_pool_t ::hash_chain &chain= buf_pool.page_hash .cell_get (i.fold ());
561
561
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)
583
583
if (prev == FIL_NULL || next == FIL_NULL)
584
584
goto fail;
585
585
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
+ }
590
595
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
+ }
592
601
593
602
new_low= id - (id.page_no () % buf_read_ahead_area);
594
603
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)
620
629
/* If we got this far, read-ahead can be sensible: do it */
621
630
count= 0 ;
622
631
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)
624
633
{
625
634
if (ibuf_bitmap_page (new_low, zip_size))
626
635
continue ;
0 commit comments