41 #include "mysql/plugin.h"
46 #define BUF_READ_AHEAD_RANDOM_THRESHOLD(b) \
47 (5 + BUF_READ_AHEAD_AREA(b) / 8)
52 #define BUF_READ_AHEAD_PEND_LIMIT 2
59 buf_read_page_handle_error(
117 ib_int64_t tablespace_version,
126 ibool ignore_nonexistent_pages;
131 mode = mode & ~OS_AIO_SIMULATED_WAKE_LATER;
134 mode &= ~BUF_READ_IGNORE_NONEXISTENT_PAGES;
139 " InnoDB: Warning: trying to read"
140 " doublewrite buffer page %lu\n",
163 tablespace_version, offset);
170 if (buf_debug_prints) {
172 "Posting read request for page %lu, sync %s\n",
173 (ulong) offset, sync ?
"true" :
"false");
185 | ignore_nonexistent_pages,
186 sync, space, zip_size, offset, 0, zip_size,
192 | ignore_nonexistent_pages,
193 sync, space, 0, offset, 0, UNIV_PAGE_SIZE,
201 if (*err != DB_SUCCESS) {
203 buf_read_page_handle_error(bpage);
248 ib_int64_t tablespace_version;
249 ulint recent_blocks = 0;
255 const ulint buf_read_ahead_random_area
258 if (!srv_random_read_ahead) {
284 low = (offset / buf_read_ahead_random_area)
285 * buf_read_ahead_random_area;
286 high = (offset / buf_read_ahead_random_area + 1)
287 * buf_read_ahead_random_area;
305 for (i = low; i < high; i++) {
307 buf_page_hash_get(buf_pool, space, i);
339 for (i = low; i < high; i++) {
344 count += buf_read_page_low(
346 ibuf_mode | OS_AIO_SIMULATED_WAKE_LATER,
347 space, zip_size, FALSE,
348 tablespace_version, i);
352 " InnoDB: Warning: in random"
353 " readahead trying to access\n"
354 "InnoDB: tablespace %lu page %lu,\n"
355 "InnoDB: but the tablespace does not"
356 " exist or is just being dropped.\n",
357 (ulong) space, (ulong) i);
369 if (buf_debug_prints && (count > 0)) {
371 "Random read-ahead space %lu offset %lu pages %lu\n",
372 (ulong) space, (ulong) offset,
400 ib_int64_t tablespace_version;
411 tablespace_version, offset);
416 " InnoDB: Error: trying to access"
417 " tablespace %lu page no. %lu,\n"
418 "InnoDB: but the tablespace does not exist"
419 " or is just being dropped.\n",
420 (ulong) space, (ulong) offset);
443 ib_int64_t tablespace_version;
449 if (zip_size == ULINT_UNDEFINED) {
456 | OS_AIO_SIMULATED_WAKE_LATER
457 | BUF_READ_IGNORE_NONEXISTENT_PAGES,
458 space, zip_size, FALSE,
459 tablespace_version, offset);
506 ib_int64_t tablespace_version;
520 const ulint buf_read_ahead_linear_area
525 if (!srv_read_ahead_threshold) {
534 low = (offset / buf_read_ahead_linear_area)
535 * buf_read_ahead_linear_area;
536 high = (offset / buf_read_ahead_linear_area + 1)
537 * buf_read_ahead_linear_area;
539 if ((offset != low) && (offset != high - 1)) {
589 threshold =
ut_min((64 - srv_read_ahead_threshold),
594 for (i = low; i < high; i++) {
595 bpage = buf_page_hash_get(buf_pool, space, i);
601 }
else if (pred_bpage) {
614 if (res != 0 && res != asc_or_desc) {
619 if (fail_count > threshold) {
633 bpage = buf_page_hash_get(buf_pool, space, offset);
664 if ((offset == low) && (succ_offset == offset + 1)) {
667 new_offset = pred_offset;
669 }
else if ((offset == high - 1) && (pred_offset == offset - 1)) {
672 new_offset = succ_offset;
679 low = (new_offset / buf_read_ahead_linear_area)
680 * buf_read_ahead_linear_area;
681 high = (new_offset / buf_read_ahead_linear_area + 1)
682 * buf_read_ahead_linear_area;
684 if ((new_offset != low) && (new_offset != high - 1)) {
698 ibuf_mode = inside_ibuf
710 for (i = low; i < high; i++) {
715 count += buf_read_page_low(
718 space, zip_size, FALSE, tablespace_version, i);
722 " InnoDB: Warning: in"
723 " linear readahead trying to access\n"
724 "InnoDB: tablespace %lu page %lu,\n"
725 "InnoDB: but the tablespace does not"
726 " exist or is just being dropped.\n",
727 (ulong) space, (ulong) i);
739 if (buf_debug_prints && (count > 0)) {
741 "LINEAR read-ahead space %lu offset %lu pages %lu\n",
742 (ulong) space, (ulong) offset, (ulong) count);
767 const ulint* space_ids,
768 const ib_int64_t* space_versions,
775 const ulint* page_nos,
784 #ifdef UNIV_IBUF_DEBUG
785 ut_a(n_stored < UNIV_PAGE_SIZE);
788 for (i = 0; i < n_stored; i++) {
800 if (UNIV_UNLIKELY(zip_size == ULINT_UNDEFINED)) {
802 goto tablespace_deleted;
805 buf_read_page_low(&err, sync && (i + 1 == n_stored),
807 zip_size, TRUE, space_versions[i],
824 if (buf_debug_prints) {
826 "Ibuf merge read-ahead space %lu pages %lu\n",
827 (ulong) space_ids[0], (ulong) n_stored);
846 const ulint* page_nos,
853 ib_int64_t tablespace_version;
860 if (UNIV_UNLIKELY(zip_size == ULINT_UNDEFINED)) {
869 for (i = 0; i < n_stored; i++) {
885 "InnoDB: Error: InnoDB has waited for"
886 " 10 seconds for pending\n"
887 "InnoDB: reads to the buffer pool to"
889 "InnoDB: Number of pending reads %lu,"
890 " pending pread calls %lu\n",
900 if ((i + 1 == n_stored) && sync) {
902 zip_size, TRUE, tablespace_version,
906 | OS_AIO_SIMULATED_WAKE_LATER,
907 space, zip_size, TRUE,
908 tablespace_version, page_nos[i]);
915 if (buf_debug_prints) {
917 "Recovery applies read-ahead pages %lu\n",