1 # name : innodb_extend_slow.patch
2 # introduced : 11 or before
3 # maintainer : Yasufumi
6 # Any small change to this file in the main branch
7 # should be done or reviewed by the maintainer!
8 --- a/storage/innobase/buf/buf0buf.c
9 +++ b/storage/innobase/buf/buf0buf.c
11 #include "dict0dict.h"
16 +/* prototypes for new functions added to ha_innodb.cc */
17 +trx_t* innobase_get_trx();
19 +inline void _increment_page_get_statistics(buf_block_t* block, trx_t* trx)
22 + ulint block_hash_byte;
23 + byte block_hash_offset;
27 + if (!innobase_get_slow_log() || !trx || !trx->take_stats)
30 + if (!trx->distinct_page_access_hash) {
31 + trx->distinct_page_access_hash = mem_alloc(DPAH_SIZE);
32 + memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
35 + block_hash = ut_hash_ulint((block->page.space << 20) + block->page.space +
36 + block->page.offset, DPAH_SIZE << 3);
37 + block_hash_byte = block_hash >> 3;
38 + block_hash_offset = (byte) block_hash & 0x07;
39 + if (block_hash_byte >= DPAH_SIZE)
40 + fprintf(stderr, "!!! block_hash_byte = %lu block_hash_offset = %d !!!\n", block_hash_byte, block_hash_offset);
41 + if (block_hash_offset > 7)
42 + fprintf(stderr, "!!! block_hash_byte = %lu block_hash_offset = %d !!!\n", block_hash_byte, block_hash_offset);
43 + if ((trx->distinct_page_access_hash[block_hash_byte] & ((byte) 0x01 << block_hash_offset)) == 0)
44 + trx->distinct_page_access++;
45 + trx->distinct_page_access_hash[block_hash_byte] |= (byte) 0x01 << block_hash_offset;
50 IMPLEMENTATION OF THE BUFFER POOL
51 @@ -1930,8 +1964,16 @@
58 + ib_uint64_t start_time;
59 + ib_uint64_t finish_time;
60 buf_pool_t* buf_pool = buf_pool_get(space, offset);
62 + if (innobase_get_slow_log()) {
63 + trx = innobase_get_trx();
65 buf_pool->stat.n_page_gets++;
69 //buf_pool_mutex_exit(buf_pool);
70 rw_lock_s_unlock(&buf_pool->page_hash_latch);
72 - buf_read_page(space, zip_size, offset);
73 + buf_read_page(space, zip_size, offset, trx);
75 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
76 ut_a(++buf_dbg_counter % 37 || buf_validate());
77 @@ -2045,6 +2087,13 @@
78 /* Let us wait until the read operation
81 + if (innobase_get_slow_log() && trx && trx->take_stats)
83 + ut_usectime(&sec, &ms);
84 + start_time = (ib_uint64_t)sec * 1000000 + ms;
89 enum buf_io_fix io_fix;
91 @@ -2059,6 +2108,12 @@
95 + if (innobase_get_slow_log() && trx && trx->take_stats && start_time)
97 + ut_usectime(&sec, &ms);
98 + finish_time = (ib_uint64_t)sec * 1000000 + ms;
99 + trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
103 #ifdef UNIV_IBUF_COUNT_DEBUG
104 @@ -2374,6 +2429,11 @@
107 mutex_t* block_mutex = NULL;
111 + ib_uint64_t start_time;
112 + ib_uint64_t finish_time;
113 buf_pool_t* buf_pool = buf_pool_get(space, offset);
116 @@ -2403,6 +2463,9 @@
117 || ibuf_page_low(space, zip_size, offset,
118 FALSE, file, line, NULL));
120 + if (innobase_get_slow_log()) {
121 + trx = innobase_get_trx();
123 buf_pool->stat.n_page_gets++;
124 fold = buf_page_address_fold(space, offset);
126 @@ -2473,7 +2536,7 @@
130 - if (buf_read_page(space, zip_size, offset)) {
131 + if (buf_read_page(space, zip_size, offset, trx)) {
133 } else if (retries < BUF_PAGE_READ_MAX_RETRIES) {
135 @@ -2782,6 +2845,13 @@
136 /* Let us wait until the read operation
139 + if (innobase_get_slow_log() && trx && trx->take_stats)
141 + ut_usectime(&sec, &ms);
142 + start_time = (ib_uint64_t)sec * 1000000 + ms;
147 enum buf_io_fix io_fix;
149 @@ -2796,6 +2866,12 @@
153 + if (innobase_get_slow_log() && trx && trx->take_stats && start_time)
155 + ut_usectime(&sec, &ms);
156 + finish_time = (ib_uint64_t)sec * 1000000 + ms;
157 + trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
161 fix_type = MTR_MEMO_BUF_FIX;
162 @@ -2822,13 +2898,17 @@
165 buf_read_ahead_linear(space, zip_size, offset,
167 + ibuf_inside(mtr), trx);
170 #ifdef UNIV_IBUF_COUNT_DEBUG
171 ut_a(ibuf_count_get(buf_block_get_space(block),
172 buf_block_get_page_no(block)) == 0);
174 + if (innobase_get_slow_log()) {
175 + _increment_page_get_statistics(block, trx);
181 @@ -2852,6 +2932,7 @@
182 unsigned access_time;
189 @@ -2929,6 +3010,10 @@
190 #if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
191 ut_a(block->page.file_page_was_freed == FALSE);
193 + if (innobase_get_slow_log()) {
194 + trx = innobase_get_trx();
197 if (UNIV_UNLIKELY(!access_time)) {
198 /* In the case of a first access, try to apply linear
200 @@ -2936,7 +3021,7 @@
201 buf_read_ahead_linear(buf_block_get_space(block),
202 buf_block_get_zip_size(block),
203 buf_block_get_page_no(block),
205 + ibuf_inside(mtr), trx);
208 #ifdef UNIV_IBUF_COUNT_DEBUG
209 @@ -2946,6 +3031,9 @@
210 buf_pool = buf_pool_from_block(block);
211 buf_pool->stat.n_page_gets++;
213 + if (innobase_get_slow_log()) {
214 + _increment_page_get_statistics(block, trx);
219 @@ -2968,6 +3056,7 @@
220 buf_pool_t* buf_pool;
226 ut_ad(mtr->state == MTR_ACTIVE);
227 @@ -3054,6 +3143,11 @@
229 buf_pool->stat.n_page_gets++;
231 + if (innobase_get_slow_log()) {
232 + trx = innobase_get_trx();
233 + _increment_page_get_statistics(block, trx);
239 --- a/storage/innobase/buf/buf0rea.c
240 +++ b/storage/innobase/buf/buf0rea.c
242 treat the tablespace as dropped; this is a timestamp we
243 use to stop dangling page reads from a tablespace
244 which we have DISCARDed + IMPORTed back */
245 - ulint offset) /*!< in: page number */
246 + ulint offset, /*!< in: page number */
251 @@ -179,15 +180,15 @@
253 thd_wait_begin(NULL, THD_WAIT_DISKIO);
255 - *err = fil_io(OS_FILE_READ | wake_later,
256 + *err = _fil_io(OS_FILE_READ | wake_later,
257 sync, space, zip_size, offset, 0, zip_size,
258 - bpage->zip.data, bpage);
259 + bpage->zip.data, bpage, trx);
261 ut_a(buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE);
263 - *err = fil_io(OS_FILE_READ | wake_later,
264 + *err = _fil_io(OS_FILE_READ | wake_later,
265 sync, space, 0, offset, 0, UNIV_PAGE_SIZE,
266 - ((buf_block_t*) bpage)->frame, bpage);
267 + ((buf_block_t*) bpage)->frame, bpage, trx);
270 ut_a(*err == DB_SUCCESS);
273 ulint space, /*!< in: space id */
274 ulint zip_size,/*!< in: compressed page size in bytes, or 0 */
275 - ulint offset) /*!< in: page number */
276 + ulint offset, /*!< in: page number */
279 buf_pool_t* buf_pool = buf_pool_get(space, offset);
280 ib_int64_t tablespace_version;
283 count = buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
285 - tablespace_version, offset);
286 + tablespace_version, offset, trx);
287 srv_buf_pool_reads += count;
288 if (err == DB_TABLESPACE_DELETED) {
289 ut_print_timestamp(stderr);
291 ulint space, /*!< in: space id */
292 ulint zip_size, /*!< in: compressed page size in bytes, or 0 */
293 ulint offset, /*!< in: page number; see NOTE 3 above */
294 - ibool inside_ibuf) /*!< in: TRUE if we are inside ibuf routine */
295 + ibool inside_ibuf, /*!< in: TRUE if we are inside ibuf routine */
298 buf_pool_t* buf_pool = buf_pool_get(space, offset);
299 ib_int64_t tablespace_version;
301 count += buf_read_page_low(
304 - space, zip_size, FALSE, tablespace_version, i);
305 + space, zip_size, FALSE, tablespace_version, i, trx);
306 if (err == DB_TABLESPACE_DELETED) {
307 ut_print_timestamp(stderr);
310 buf_read_page_low(&err, sync && (i + 1 == n_stored),
311 BUF_READ_ANY_PAGE, space_ids[i],
312 zip_size, TRUE, space_versions[i],
314 + page_nos[i], NULL);
316 if (UNIV_UNLIKELY(err == DB_TABLESPACE_DELETED)) {
318 @@ -733,12 +736,12 @@
319 if ((i + 1 == n_stored) && sync) {
320 buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
321 zip_size, TRUE, tablespace_version,
323 + page_nos[i], NULL);
325 buf_read_page_low(&err, FALSE, BUF_READ_ANY_PAGE
326 | OS_AIO_SIMULATED_WAKE_LATER,
327 space, zip_size, TRUE,
328 - tablespace_version, page_nos[i]);
329 + tablespace_version, page_nos[i], NULL);
333 --- a/storage/innobase/fil/fil0fil.c
334 +++ b/storage/innobase/fil/fil0fil.c
335 @@ -4748,7 +4748,7 @@
336 node->name, node->handle, buf,
337 offset_low, offset_high,
343 node->size += n_pages;
344 @@ -5075,7 +5075,7 @@
345 i/o on a tablespace which does not exist */
351 ulint type, /*!< in: OS_FILE_READ or OS_FILE_WRITE,
352 ORed to OS_FILE_LOG, if a log i/o
353 @@ -5100,8 +5100,9 @@
354 void* buf, /*!< in/out: buffer where to store read data
355 or from where to write; in aio this must be
356 appropriately aligned */
357 - void* message) /*!< in: message for aio handler if non-sync
358 + void* message, /*!< in: message for aio handler if non-sync
359 aio used, else ignored */
364 @@ -5269,7 +5270,7 @@
366 /* Queue the aio request */
367 ret = os_aio(type, mode | wake_later, node->name, node->handle, buf,
368 - offset_low, offset_high, len, node, message);
369 + offset_low, offset_high, len, node, message, trx);
373 --- a/storage/innobase/handler/ha_innodb.cc
374 +++ b/storage/innobase/handler/ha_innodb.cc
375 @@ -1578,6 +1578,16 @@
376 trx->check_unique_secondary = !thd_test_options(
377 thd, OPTION_RELAXED_UNIQUE_CHECKS);
379 +#ifdef EXTENDED_SLOWLOG
380 + if (thd_log_slow_verbosity(thd) & SLOG_V_INNODB) {
381 + trx->take_stats = TRUE;
383 + trx->take_stats = FALSE;
386 + trx->take_stats = FALSE;
392 @@ -1632,6 +1642,32 @@
396 +/*************************************************************************
397 +Gets current trx. */
402 + THD *thd=current_thd;
403 + if (likely(thd != 0)) {
404 + trx_t*& trx = thd_to_trx(thd);
413 +innobase_get_slow_log()
415 +#ifdef EXTENDED_SLOWLOG
416 + return((ibool) thd_opt_slow_log());
422 /*********************************************************************//**
423 Note that a transaction has been registered with MySQL.
424 @return true if transaction is registered with MySQL 2PC coordinator */
425 @@ -9312,6 +9348,25 @@
426 statement has ended */
428 if (trx->n_mysql_tables_in_use == 0) {
429 +#ifdef EXTENDED_SLOWLOG
430 + increment_thd_innodb_stats(thd,
431 + (unsigned long long) trx->id,
434 + trx->io_reads_wait_timer,
435 + trx->lock_que_wait_timer,
436 + trx->innodb_que_wait_timer,
437 + trx->distinct_page_access);
441 + trx->io_reads_wait_timer = 0;
442 + trx->lock_que_wait_timer = 0;
443 + trx->innodb_que_wait_timer = 0;
444 + trx->distinct_page_access = 0;
445 + if (trx->distinct_page_access_hash)
446 + memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
449 trx->mysql_n_tables_locked = 0;
450 prebuilt->used_in_HANDLER = FALSE;
451 --- a/storage/innobase/include/buf0rea.h
452 +++ b/storage/innobase/include/buf0rea.h
457 +#include "trx0types.h"
458 #include "buf0types.h"
460 /********************************************************************//**
463 ulint space, /*!< in: space id */
464 ulint zip_size,/*!< in: compressed page size in bytes, or 0 */
465 - ulint offset);/*!< in: page number */
466 + ulint offset, /*!< in: page number */
468 /********************************************************************//**
469 Applies linear read-ahead if in the buf_pool the page is a border page of
470 a linear read-ahead area and all the pages in the area have been accessed.
472 ulint space, /*!< in: space id */
473 ulint zip_size, /*!< in: compressed page size in bytes, or 0 */
474 ulint offset, /*!< in: page number; see NOTE 3 above */
475 - ibool inside_ibuf); /*!< in: TRUE if we are inside ibuf routine */
476 + ibool inside_ibuf, /*!< in: TRUE if we are inside ibuf routine */
478 /********************************************************************//**
479 Issues read requests for pages which the ibuf module wants to read in, in
480 order to contract the insert buffer tree. Technically, this function is like
481 --- a/storage/innobase/include/fil0fil.h
482 +++ b/storage/innobase/include/fil0fil.h
484 Reads or writes data. This operation is asynchronous (aio).
485 @return DB_SUCCESS, or DB_TABLESPACE_DELETED if we are trying to do
486 i/o on a tablespace which does not exist */
487 +#define fil_io(type, sync, space_id, zip_size, block_offset, byte_offset, len, buf, message) \
488 + _fil_io(type, sync, space_id, zip_size, block_offset, byte_offset, len, buf, message, NULL)
495 ulint type, /*!< in: OS_FILE_READ or OS_FILE_WRITE,
496 ORed to OS_FILE_LOG, if a log i/o
498 void* buf, /*!< in/out: buffer where to store read data
499 or from where to write; in aio this must be
500 appropriately aligned */
501 - void* message); /*!< in: message for aio handler if non-sync
502 + void* message, /*!< in: message for aio handler if non-sync
503 aio used, else ignored */
505 /**********************************************************************//**
506 Waits for an aio operation to complete. This function is used to write the
507 handler for completed requests. The aio array of pending requests is divided
508 --- a/storage/innobase/include/os0file.h
509 +++ b/storage/innobase/include/os0file.h
514 +#include "trx0types.h"
518 @@ -277,13 +278,17 @@
519 pfs_os_file_close_func(file, __FILE__, __LINE__)
521 # define os_aio(type, mode, name, file, buf, offset, offset_high, \
522 - n, message1, message2) \
523 + n, message1, message2, trx) \
524 pfs_os_aio_func(type, mode, name, file, buf, offset, \
525 - offset_high, n, message1, message2, \
526 + offset_high, n, message1, message2, trx, \
529 # define os_file_read(file, buf, offset, offset_high, n) \
530 - pfs_os_file_read_func(file, buf, offset, offset_high, n, \
531 + pfs_os_file_read_func(file, buf, offset, offset_high, n, NULL, \
532 + __FILE__, __LINE__)
534 +# define os_file_read_trx(file, buf, offset, offset_high, n, trx) \
535 + pfs_os_file_read_func(file, buf, offset, offset_high, n, trx, \
538 # define os_file_read_no_error_handling(file, buf, offset, \
539 @@ -319,12 +324,15 @@
540 # define os_file_close(file) os_file_close_func(file)
542 # define os_aio(type, mode, name, file, buf, offset, offset_high, \
543 - n, message1, message2) \
544 + n, message1, message2, trx) \
545 os_aio_func(type, mode, name, file, buf, offset, offset_high, n,\
546 - message1, message2)
547 + message1, message2, trx)
549 # define os_file_read(file, buf, offset, offset_high, n) \
550 - os_file_read_func(file, buf, offset, offset_high, n)
551 + os_file_read_func(file, buf, offset, offset_high, n, NULL)
553 +# define os_file_read_trx(file, buf, offset, offset_high, n, trx) \
554 + os_file_read_func(file, buf, offset, offset_high, n, trx)
556 # define os_file_read_no_error_handling(file, buf, offset, \
559 ulint offset_high,/*!< in: most significant 32 bits of
561 ulint n, /*!< in: number of bytes to read */
563 const char* src_file,/*!< in: file name where func invoked */
564 ulint src_line);/*!< in: line where the func invoked */
567 (can be used to identify a completed
568 aio operation); ignored if mode is
571 const char* src_file,/*!< in: file name where func invoked */
572 ulint src_line);/*!< in: line where the func invoked */
573 /*******************************************************************//**
575 offset where to read */
576 ulint offset_high,/*!< in: most significant 32 bits of
578 - ulint n); /*!< in: number of bytes to read */
579 + ulint n, /*!< in: number of bytes to read */
581 /*******************************************************************//**
582 Rewind file to its start, read at most size - 1 bytes from it to str, and
583 NUL-terminate str. All errors are silently ignored. This function is
584 @@ -1048,10 +1059,11 @@
585 (can be used to identify a completed
586 aio operation); ignored if mode is
588 - void* message2);/*!< in: message for the aio handler
589 + void* message2,/*!< in: message for the aio handler
590 (can be used to identify a completed
591 aio operation); ignored if mode is
594 /************************************************************************//**
595 Wakes up all async i/o threads so that they know to exit themselves in
597 --- a/storage/innobase/include/os0file.ic
598 +++ b/storage/innobase/include/os0file.ic
600 (can be used to identify a completed
601 aio operation); ignored if mode is
604 const char* src_file,/*!< in: file name where func invoked */
605 ulint src_line)/*!< in: line where the func invoked */
610 result = os_aio_func(type, mode, name, file, buf, offset, offset_high,
611 - n, message1, message2);
612 + n, message1, message2, trx);
614 register_pfs_file_io_end(locker, n);
617 ulint offset_high,/*!< in: most significant 32 bits of
619 ulint n, /*!< in: number of bytes to read */
621 const char* src_file,/*!< in: file name where func invoked */
622 ulint src_line)/*!< in: line where the func invoked */
625 register_pfs_file_io_begin(&state, locker, file, n, PSI_FILE_READ,
628 - result = os_file_read_func(file, buf, offset, offset_high, n);
629 + result = os_file_read_func(file, buf, offset, offset_high, n, trx);
631 register_pfs_file_io_end(locker, n);
633 --- a/storage/innobase/include/srv0srv.h
634 +++ b/storage/innobase/include/srv0srv.h
636 #define SRV_AUTO_EXTEND_INCREMENT \
637 (srv_auto_extend_increment * ((1024 * 1024) / UNIV_PAGE_SIZE))
639 +/* prototypes for new functions added to ha_innodb.cc */
640 +ibool innobase_get_slow_log();
642 /* Mutex for locking srv_monitor_file */
643 extern mutex_t srv_monitor_file_mutex;
644 /* Temporary file for innodb monitor output */
645 --- a/storage/innobase/include/trx0trx.h
646 +++ b/storage/innobase/include/trx0trx.h
648 /*------------------------------*/
649 char detailed_error[256]; /*!< detailed error message for last
651 + /*------------------------------*/
653 + ib_uint64_t io_read;
654 + ulint io_reads_wait_timer;
655 + ib_uint64_t lock_que_wait_ustarted;
656 + ulint lock_que_wait_timer;
657 + ulint innodb_que_wait_timer;
658 + ulint distinct_page_access;
659 +#define DPAH_SIZE 8192
660 + byte* distinct_page_access_hash;
664 #define TRX_MAX_N_THREADS 32 /* maximum number of
665 --- a/storage/innobase/lock/lock0lock.c
666 +++ b/storage/innobase/lock/lock0lock.c
667 @@ -1765,6 +1765,8 @@
674 ut_ad(mutex_own(&kernel_mutex));
676 @@ -1823,6 +1825,10 @@
677 trx->que_state = TRX_QUE_LOCK_WAIT;
678 trx->was_chosen_as_deadlock_victim = FALSE;
679 trx->wait_started = time(NULL);
680 + if (innobase_get_slow_log() && trx->take_stats) {
681 + ut_usectime(&sec, &ms);
682 + trx->lock_que_wait_ustarted = (ib_uint64_t)sec * 1000000 + ms;
685 ut_a(que_thr_stop(thr));
687 @@ -3766,6 +3772,8 @@
694 ut_ad(mutex_own(&kernel_mutex));
696 @@ -3821,6 +3829,10 @@
700 + if (innobase_get_slow_log() && trx->take_stats) {
701 + ut_usectime(&sec, &ms);
702 + trx->lock_que_wait_ustarted = (ib_uint64_t)sec * 1000000 + ms;
704 trx->que_state = TRX_QUE_LOCK_WAIT;
705 trx->was_chosen_as_deadlock_victim = FALSE;
706 trx->wait_started = time(NULL);
707 --- a/storage/innobase/os/os0file.c
708 +++ b/storage/innobase/os/os0file.c
710 #include "srv0start.h"
713 +#include "trx0sys.h"
714 +#include "trx0trx.h"
715 #include "log0recv.h"
716 #ifndef UNIV_HOTBACKUP
717 # include "os0sync.h"
718 @@ -2213,13 +2215,18 @@
719 ulint n, /*!< in: number of bytes to read */
720 ulint offset, /*!< in: least significant 32 bits of file
721 offset from where to read */
722 - ulint offset_high) /*!< in: most significant 32 bits of
723 + ulint offset_high, /*!< in: most significant 32 bits of
728 #if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD)
730 #endif /* HAVE_PREAD && !HAVE_BROKEN_PREAD */
733 + ib_uint64_t start_time;
734 + ib_uint64_t finish_time;
736 ut_a((offset & 0xFFFFFFFFUL) == offset);
738 @@ -2240,6 +2247,15 @@
742 + if (innobase_get_slow_log() && trx && trx->take_stats)
746 + ut_usectime(&sec, &ms);
747 + start_time = (ib_uint64_t)sec * 1000000 + ms;
751 #if defined(HAVE_PREAD) && !defined(HAVE_BROKEN_PREAD)
752 os_mutex_enter(os_file_count_mutex);
753 os_file_n_pending_preads++;
754 @@ -2253,6 +2269,13 @@
755 os_n_pending_reads--;
756 os_mutex_exit(os_file_count_mutex);
758 + if (innobase_get_slow_log() && trx && trx->take_stats && start_time)
760 + ut_usectime(&sec, &ms);
761 + finish_time = (ib_uint64_t)sec * 1000000 + ms;
762 + trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
768 @@ -2289,6 +2312,13 @@
769 os_n_pending_reads--;
770 os_mutex_exit(os_file_count_mutex);
772 + if (innobase_get_slow_log() && trx && trx->take_stats && start_time)
774 + ut_usectime(&sec, &ms);
775 + finish_time = (ib_uint64_t)sec * 1000000 + ms;
776 + trx->io_reads_wait_timer += (ulint)(finish_time - start_time);
782 @@ -2429,7 +2459,8 @@
783 offset where to read */
784 ulint offset_high, /*!< in: most significant 32 bits of
786 - ulint n) /*!< in: number of bytes to read */
787 + ulint n, /*!< in: number of bytes to read */
792 @@ -2504,7 +2535,7 @@
793 os_bytes_read_since_printout += n;
796 - ret = os_file_pread(file, buf, n, offset, offset_high);
797 + ret = os_file_pread(file, buf, n, offset, offset_high, trx);
799 if ((ulint)ret == n) {
801 @@ -2633,7 +2664,7 @@
802 os_bytes_read_since_printout += n;
805 - ret = os_file_pread(file, buf, n, offset, offset_high);
806 + ret = os_file_pread(file, buf, n, offset, offset_high, NULL);
808 if ((ulint)ret == n) {
810 @@ -4027,10 +4058,11 @@
811 (can be used to identify a completed
812 aio operation); ignored if mode is
814 - void* message2)/*!< in: message for the aio handler
815 + void* message2,/*!< in: message for the aio handler
816 (can be used to identify a completed
817 aio operation); ignored if mode is
821 os_aio_array_t* array;
823 @@ -4078,7 +4110,7 @@
825 if (type == OS_FILE_READ) {
826 return(os_file_read_func(file, buf, offset,
828 + offset_high, n, trx));
831 ut_a(type == OS_FILE_WRITE);
832 @@ -4119,6 +4151,11 @@
833 array = NULL; /* Eliminate compiler warning */
836 + if (trx && type == OS_FILE_READ)
841 slot = os_aio_array_reserve_slot(type, array, message1, message2, file,
842 name, buf, offset, offset_high, n);
843 if (type == OS_FILE_READ) {
844 --- a/storage/innobase/srv/srv0srv.c
845 +++ b/storage/innobase/srv/srv0srv.c
847 #include "mysql/plugin.h"
848 #include "mysql/service_thd_wait.h"
850 +/* prototypes for new functions added to ha_innodb.cc */
851 +ibool innobase_get_slow_log();
853 /* The following counter is incremented whenever there is some user activity
855 UNIV_INTERN ulint srv_activity_count = 0;
856 @@ -1232,6 +1235,10 @@
857 ibool has_slept = FALSE;
858 srv_conc_slot_t* slot = NULL;
860 + ib_uint64_t start_time = 0L;
861 + ib_uint64_t finish_time = 0L;
865 #ifdef UNIV_SYNC_DEBUG
866 ut_ad(!sync_thread_levels_nonempty_trx(trx->has_search_latch));
867 @@ -1312,6 +1319,7 @@
869 if (SRV_THREAD_SLEEP_DELAY > 0) {
870 os_thread_sleep(SRV_THREAD_SLEEP_DELAY);
871 + trx->innodb_que_wait_timer += SRV_THREAD_SLEEP_DELAY;
875 @@ -1371,6 +1379,14 @@
876 #ifdef UNIV_SYNC_DEBUG
877 ut_ad(!sync_thread_levels_nonempty_trx(trx->has_search_latch));
878 #endif /* UNIV_SYNC_DEBUG */
880 + if (innobase_get_slow_log() && trx->take_stats) {
881 + ut_usectime(&sec, &ms);
882 + start_time = (ib_uint64_t)sec * 1000000 + ms;
887 trx->op_info = "waiting in InnoDB queue";
889 thd_wait_begin(trx->mysql_thd, THD_WAIT_USER_LOCK);
890 @@ -1379,6 +1395,12 @@
894 + if (innobase_get_slow_log() && trx->take_stats && start_time) {
895 + ut_usectime(&sec, &ms);
896 + finish_time = (ib_uint64_t)sec * 1000000 + ms;
897 + trx->innodb_que_wait_timer += (ulint)(finish_time - start_time);
900 os_fast_mutex_lock(&srv_conc_mutex);
902 srv_conc_n_waiting_threads--;
903 --- a/storage/innobase/trx/trx0trx.c
904 +++ b/storage/innobase/trx/trx0trx.c
906 trx->global_read_view = NULL;
907 trx->read_view = NULL;
911 + trx->io_reads_wait_timer = 0;
912 + trx->lock_que_wait_timer = 0;
913 + trx->innodb_que_wait_timer = 0;
914 + trx->distinct_page_access = 0;
915 + trx->distinct_page_access_hash = NULL;
916 + trx->take_stats = FALSE;
918 /* Set X/Open XA transaction identification to NULL */
919 memset(&trx->xid, 0, sizeof(trx->xid));
920 trx->xid.formatID = -1;
923 mutex_exit(&kernel_mutex);
925 + if (innobase_get_slow_log() && trx->take_stats) {
926 + trx->distinct_page_access_hash = mem_alloc(DPAH_SIZE);
927 + memset(trx->distinct_page_access_hash, 0, DPAH_SIZE);
935 trx_t* trx) /*!< in, own: trx object */
937 + if (trx->distinct_page_access_hash)
939 + mem_free(trx->distinct_page_access_hash);
940 + trx->distinct_page_access_hash= NULL;
943 mutex_enter(&kernel_mutex);
945 UT_LIST_REMOVE(mysql_trx_list, trx_sys->mysql_trx_list, trx);
947 /*====================*/
948 trx_t* trx) /*!< in, own: trx object */
950 + if (trx->distinct_page_access_hash)
952 + mem_free(trx->distinct_page_access_hash);
953 + trx->distinct_page_access_hash= NULL;
956 mutex_enter(&kernel_mutex);
959 @@ -1212,6 +1238,9 @@
960 trx_t* trx) /*!< in: transaction */
967 ut_ad(mutex_own(&kernel_mutex));
968 ut_ad(trx->que_state == TRX_QUE_LOCK_WAIT);
969 @@ -1226,6 +1255,11 @@
970 thr = UT_LIST_GET_FIRST(trx->wait_thrs);
973 + if (innobase_get_slow_log() && trx->take_stats) {
974 + ut_usectime(&sec, &ms);
975 + now = (ib_uint64_t)sec * 1000000 + ms;
976 + trx->lock_que_wait_timer += (ulint)(now - trx->lock_que_wait_ustarted);
978 trx->que_state = TRX_QUE_RUNNING;
981 @@ -1239,6 +1273,9 @@
982 trx_t* trx) /*!< in: transaction in the TRX_QUE_LOCK_WAIT state */
989 ut_ad(mutex_own(&kernel_mutex));
990 ut_ad(trx->que_state == TRX_QUE_LOCK_WAIT);
991 @@ -1253,6 +1290,11 @@
992 thr = UT_LIST_GET_FIRST(trx->wait_thrs);
995 + if (innobase_get_slow_log() && trx->take_stats) {
996 + ut_usectime(&sec, &ms);
997 + now = (ib_uint64_t)sec * 1000000 + ms;
998 + trx->lock_que_wait_timer += (ulint)(now - trx->lock_que_wait_ustarted);
1000 trx->que_state = TRX_QUE_RUNNING;