11
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
13
You should have received a copy of the GNU General Public License along with
14
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
St, Fifth Floor, Boston, MA 02110-1301 USA
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15
Place, Suite 330, Boston, MA 02111-1307 USA
17
17
*****************************************************************************/
160
167
/********************************************************************//**
168
Applies a random read-ahead in buf_pool if there are at least a threshold
169
value of accessed pages from the random read-ahead area. Does not read any
170
page, not even the one at the position (space, offset), if the read-ahead
171
mechanism is not activated. NOTE 1: the calling thread may own latches on
172
pages: to avoid deadlocks this function must be written such that it cannot
173
end up waiting for these latches! NOTE 2: the calling thread must want
174
access to the page given: this rule is set to prevent unintended read-aheads
175
performed by ibuf routines, a situation which could result in a deadlock if
176
the OS does not support asynchronous i/o.
177
@return number of page read requests issued; NOTE that if we read ibuf
178
pages, it may happen that the page at the given page number does not
179
get read even if we return a positive value! */
182
buf_read_ahead_random(
183
/*==================*/
184
ulint space, /*!< in: space id */
185
ulint zip_size,/*!< in: compressed page size in bytes, or 0 */
186
ulint offset) /*!< in: page number of a page which the current thread
192
/* We have currently disabled random readahead */
197
/********************************************************************//**
161
198
High-level function which reads a page asynchronously from a file to the
162
199
buffer buf_pool if it is not already there. Sets the io_fix flag and sets
163
200
an exclusive lock on the buffer frame. The flag is cleared and the x-lock
164
released by the i/o-handler thread.
165
@return TRUE if page has been read in, FALSE in case of failure */
201
released by the i/o-handler thread. Does a random read-ahead if it seems
203
@return number of page read requests issued: this can be greater than
204
1 if read-ahead occurred */
170
209
ulint space, /*!< in: space id */
171
210
ulint zip_size,/*!< in: compressed page size in bytes, or 0 */
172
211
ulint offset) /*!< in: page number */
174
buf_pool_t* buf_pool = buf_pool_get(space, offset);
175
213
ib_int64_t tablespace_version;
179
218
tablespace_version = fil_space_get_version(space);
220
count = buf_read_ahead_random(space, zip_size, offset);
181
222
/* We do the i/o in the synchronous aio mode to save thread
182
223
switches: hence TRUE */
184
count = buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
186
tablespace_version, offset);
187
srv_buf_pool_reads += count;
225
count2 = buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
227
tablespace_version, offset);
228
srv_buf_pool_reads+= count2;
188
229
if (err == DB_TABLESPACE_DELETED) {
189
230
ut_print_timestamp(stderr);
317
357
/* How many out of order accessed pages can we ignore
318
358
when working out the access pattern for linear readahead */
319
359
threshold = ut_min((64 - srv_read_ahead_threshold),
320
BUF_READ_AHEAD_AREA(buf_pool));
360
BUF_READ_AHEAD_AREA);
324
364
for (i = low; i < high; i++) {
325
bpage = buf_page_hash_get(buf_pool, space, i);
365
bpage = buf_page_hash_get(space, i);
327
if (bpage == NULL || !buf_page_is_accessed(bpage)) {
367
if ((bpage == NULL) || !buf_page_is_accessed(bpage)) {
328
368
/* Not accessed */
331
371
} else if (pred_bpage) {
332
/* Note that buf_page_is_accessed() returns
333
the time of the first access. If some blocks
334
of the extent existed in the buffer pool at
335
the time of a linear access pattern, the first
336
access times may be nonmonotonic, even though
337
the latest access times were linear. The
338
threshold (srv_read_ahead_factor) should help
339
a little against this. */
340
int res = ut_ulint_cmp(
341
buf_page_is_accessed(bpage),
342
buf_page_is_accessed(pred_bpage));
372
int res = (ut_ulint_cmp(
373
buf_page_get_LRU_position(bpage),
374
buf_page_get_LRU_position(pred_bpage)));
343
375
/* Accesses not in the right order */
344
376
if (res != 0 && res != asc_or_desc) {
520
552
#ifdef UNIV_IBUF_DEBUG
521
553
ut_a(n_stored < UNIV_PAGE_SIZE);
555
while (buf_pool->n_pend_reads
556
> buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) {
557
os_thread_sleep(500000);
524
560
for (i = 0; i < n_stored; i++) {
526
buf_pool_t* buf_pool;
527
ulint zip_size = fil_space_get_zip_size(space_ids[i]);
529
buf_pool = buf_pool_get(space_ids[i], space_versions[i]);
531
while (buf_pool->n_pend_reads
532
> buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) {
533
os_thread_sleep(500000);
561
ulint zip_size = fil_space_get_zip_size(space_ids[i]);
536
564
if (UNIV_UNLIKELY(zip_size == ULINT_UNDEFINED)) {
606
634
tablespace_version = fil_space_get_version(space);
608
636
for (i = 0; i < n_stored; i++) {
609
buf_pool_t* buf_pool;
613
640
os_aio_print_debug = FALSE;
614
buf_pool = buf_pool_get(space, page_nos[i]);
615
642
while (buf_pool->n_pend_reads >= recv_n_pool_free_frames / 2) {
617
644
os_aio_simulated_wake_handler_threads();
618
os_thread_sleep(10000);
645
os_thread_sleep(500000);
624
651
"InnoDB: Error: InnoDB has waited for"
625
" 10 seconds for pending\n"
652
" 50 seconds for pending\n"
626
653
"InnoDB: reads to the buffer pool to"
627
654
" be finished.\n"
628
655
"InnoDB: Number of pending reads %lu,"