diff options
Diffstat (limited to 'innobase/buf/buf0buf.c')
-rw-r--r-- | innobase/buf/buf0buf.c | 220 |
1 files changed, 98 insertions, 122 deletions
diff --git a/innobase/buf/buf0buf.c b/innobase/buf/buf0buf.c index 844880238fa..7a5ef3c5e14 100644 --- a/innobase/buf/buf0buf.c +++ b/innobase/buf/buf0buf.c @@ -223,12 +223,14 @@ in the free list to the frames. buf_pool_t* buf_pool = NULL; /* The buffer buf_pool of the database */ -ulint buf_dbg_counter = 0; /* This is used to insert validation +#ifdef UNIV_DEBUG +static ulint buf_dbg_counter = 0; /* This is used to insert validation operations in excution in the debug version */ ibool buf_debug_prints = FALSE; /* If this is set TRUE, the program prints info whenever read-ahead or flush occurs */ +#endif /* UNIV_DEBUG */ /************************************************************************ Calculates a page checksum which is stored to the page when it is written @@ -372,19 +374,12 @@ buf_page_print( dict_index_t* index; ulint checksum; ulint old_checksum; - char* buf; - - buf = mem_alloc(4 * UNIV_PAGE_SIZE); - - ut_sprintf_buf(buf, read_buf, UNIV_PAGE_SIZE); ut_print_timestamp(stderr); - fprintf(stderr, -" InnoDB: Page dump in ascii and hex (%lu bytes):\n%s", - (ulong) UNIV_PAGE_SIZE, buf); - fprintf(stderr, "InnoDB: End of page dump\n"); - - mem_free(buf); + fprintf(stderr, " InnoDB: Page dump in ascii and hex (%lu bytes):\n", + (ulint)UNIV_PAGE_SIZE); + ut_print_buf(stderr, read_buf, UNIV_PAGE_SIZE); + fputs("InnoDB: End of page dump\n", stderr); checksum = buf_calc_page_new_checksum(read_buf); old_checksum = buf_calc_page_old_checksum(read_buf); @@ -433,17 +428,16 @@ buf_page_print( index = dict_index_find_on_id_low( btr_page_get_index_id(read_buf)); if (index) { - fprintf(stderr, - "InnoDB: and table %s index %s\n", - index->table_name, - index->name); + fputs("InnoDB: (", stderr); + dict_index_name_print(stderr, index); + fputs(")\n", stderr); } } } else if (fil_page_get_type(read_buf) == FIL_PAGE_INODE) { - fprintf(stderr, "InnoDB: Page may be an 'inode' page\n"); + fputs("InnoDB: Page may be an 'inode' page\n", stderr); } else if (fil_page_get_type(read_buf) == FIL_PAGE_IBUF_FREE_LIST) { - fprintf(stderr, - "InnoDB: Page may be an insert buffer free list page\n"); + fputs("InnoDB: Page may be an insert buffer free list page\n", + stderr); } } @@ -1551,11 +1545,12 @@ buf_page_init( "InnoDB: Error: page %lu %lu already found from the hash table\n", (ulong) space, (ulong) offset); +#ifdef UNIV_DEBUG buf_print(); buf_LRU_print(); buf_validate(); buf_LRU_validate(); - +#endif /* UNIV_DEBUG */ ut_a(0); } @@ -1732,11 +1727,12 @@ buf_page_create( /* If we get here, the page was not in buf_pool: init it there */ +#ifdef UNIV_DEBUG if (buf_debug_prints) { - printf("Creating space %lu page %lu to buffer\n", - (ulong) space, - (ulong) offset); + fprintf(stderr, "Creating space %lu page %lu to buffer\n", + (ulong) space, (ulong) offset); } +#endif /* UNIV_DEBUG */ block = free_block; @@ -1789,8 +1785,6 @@ buf_page_io_complete( /*=================*/ buf_block_t* block) /* in: pointer to the block in question */ { - dict_index_t* index; - dulint id; ulint io_type; ulint read_page_no; @@ -1823,17 +1817,17 @@ buf_page_io_complete( "InnoDB: Database page corruption on disk or a failed\n" "InnoDB: file read of page %lu.\n", (ulong) block->offset); - fprintf(stderr, - "InnoDB: You may have to recover from a backup.\n"); + fputs( + "InnoDB: You may have to recover from a backup.\n", stderr); buf_page_print(block->frame); fprintf(stderr, "InnoDB: Database page corruption on disk or a failed\n" "InnoDB: file read of page %lu.\n", (ulong) block->offset); - fprintf(stderr, - "InnoDB: You may have to recover from a backup.\n"); - fprintf(stderr, + fputs( + "InnoDB: You may have to recover from a backup.\n", stderr); + fputs( "InnoDB: It is also possible that your operating\n" "InnoDB: system has corrupted its own file cache\n" "InnoDB: and rebooting your computer removes the\n" @@ -1844,12 +1838,13 @@ buf_page_io_complete( "InnoDB: the corrupt table. You can use CHECK\n" "InnoDB: TABLE to scan your table for corruption.\n" "InnoDB: Look also at section 6.1 of\n" - "InnoDB: http://www.innodb.com/ibman.html about\n" - "InnoDB: forcing recovery.\n"); + "InnoDB: http://www.innodb.com/ibman.php about\n" + "InnoDB: forcing recovery.\n", stderr); if (srv_force_recovery < SRV_FORCE_IGNORE_CORRUPT) { - fprintf(stderr, - "InnoDB: Ending processing because of a corrupt database page.\n"); + fputs( + "InnoDB: Ending processing because of a corrupt database page.\n", + stderr); exit(1); } } @@ -1888,9 +1883,11 @@ buf_page_io_complete( rw_lock_x_unlock_gen(&(block->lock), BUF_IO_READ); +#ifdef UNIV_DEBUG if (buf_debug_prints) { - printf("Has read "); + fputs("Has read ", stderr); } +#endif /* UNIV_DEBUG */ } else { ut_ad(io_type == BUF_IO_WRITE); @@ -1903,31 +1900,21 @@ buf_page_io_complete( buf_pool->n_pages_written++; +#ifdef UNIV_DEBUG if (buf_debug_prints) { - printf("Has written "); + fputs("Has written ", stderr); } +#endif /* UNIV_DEBUG */ } mutex_exit(&(buf_pool->mutex)); +#ifdef UNIV_DEBUG if (buf_debug_prints) { - printf("page space %lu page no %lu", (ulong) block->space, - (ulong) block->offset); - id = btr_page_get_index_id(block->frame); - - index = NULL; - /* The following can cause deadlocks if used: */ - /* - index = dict_index_get_if_in_cache(id); - - if (index) { - printf(" index name %s table %s", index->name, - index->table->name); - } - */ - - printf("\n"); + fprintf(stderr, "page space %lu page no %lu\n", + (ulong) block->space, (ulong) block->offset); } +#endif /* UNIV_DEBUG */ } /************************************************************************* @@ -1956,6 +1943,7 @@ buf_pool_invalidate(void) mutex_exit(&(buf_pool->mutex)); } +#ifdef UNIV_DEBUG /************************************************************************* Validates the buffer buf_pool data structure. */ @@ -2027,16 +2015,14 @@ buf_validate(void) } if (n_lru + n_free > buf_pool->curr_size) { - printf("n LRU %lu, n free %lu\n", (ulong) n_lru, - (ulong) n_free); + fprintf(stderr, "n LRU %lu, n free %lu\n", (ulong) n_lru, (ulong) n_free); ut_error; } ut_a(UT_LIST_GET_LEN(buf_pool->LRU) == n_lru); if (UT_LIST_GET_LEN(buf_pool->free) != n_free) { - printf("Free list len %lu, free blocks %lu\n", - (ulong) UT_LIST_GET_LEN(buf_pool->free), - (ulong) n_free); + fprintf(stderr, "Free list len %lu, free blocks %lu\n", + (ulong) UT_LIST_GET_LEN(buf_pool->free), (ulong) n_free); ut_error; } ut_a(UT_LIST_GET_LEN(buf_pool->flush_list) == n_flush); @@ -2079,23 +2065,24 @@ buf_print(void) mutex_enter(&(buf_pool->mutex)); - printf("buf_pool size %lu \n", (ulong) size); - printf("database pages %lu \n", (ulong) UT_LIST_GET_LEN(buf_pool->LRU)); - printf("free pages %lu \n", (ulong) UT_LIST_GET_LEN(buf_pool->free)); - printf("modified database pages %lu \n", - (ulong) UT_LIST_GET_LEN(buf_pool->flush_list)); - - printf("n pending reads %lu \n", (ulong) buf_pool->n_pend_reads); - - printf("n pending flush LRU %lu list %lu single page %lu\n", - (ulong) buf_pool->n_flush[BUF_FLUSH_LRU], - (ulong) buf_pool->n_flush[BUF_FLUSH_LIST], - (ulong) buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]); - - printf("pages read %lu, created %lu, written %lu\n", - (ulong) buf_pool->n_pages_read, - (ulong) buf_pool->n_pages_created, - (ulong) buf_pool->n_pages_written); + fprintf(stderr, + "buf_pool size %lu\n" + "database pages %lu\n" + "free pages %lu\n" + "modified database pages %lu\n" + "n pending reads %lu\n" + "n pending flush LRU %lu list %lu single page %lu\n" + "pages read %lu, created %lu, written %lu\n", + (ulong) size, + (ulong) UT_LIST_GET_LEN(buf_pool->LRU), + (ulong) UT_LIST_GET_LEN(buf_pool->free), + (ulong) UT_LIST_GET_LEN(buf_pool->flush_list), + (ulong) buf_pool->n_pend_reads, + (ulong) buf_pool->n_flush[BUF_FLUSH_LRU], + (ulong) buf_pool->n_flush[BUF_FLUSH_LIST], + (ulong) buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE], + (ulong) buf_pool->n_pages_read, buf_pool->n_pages_created, + (ulong) buf_pool->n_pages_written); /* Count the number of blocks belonging to each index in the buffer */ @@ -2138,16 +2125,17 @@ buf_print(void) for (i = 0; i < n_found; i++) { index = dict_index_get_if_in_cache(index_ids[i]); - printf("Block count for index %lu in buffer is about %lu", + fprintf(stderr, + "Block count for index %lu in buffer is about %lu", (ulong) ut_dulint_get_low(index_ids[i]), (ulong) counts[i]); if (index) { - printf(" index name %s table %s", index->name, - index->table->name); + putc(' ', stderr); + dict_index_name_print(stderr, index); } - printf("\n"); + putc('\n', stderr); } mem_free(index_ids); @@ -2155,6 +2143,7 @@ buf_print(void) ut_a(buf_validate()); } +#endif /* UNIV_DEBUG */ /************************************************************************* Returns the number of pending buf pool ios. */ @@ -2198,57 +2187,42 @@ Prints info of the buffer i/o. */ void buf_print_io( /*=========*/ - char* buf, /* in/out: buffer where to print */ - char* buf_end)/* in: buffer end */ + FILE* file) /* in/out: buffer where to print */ { time_t current_time; double time_elapsed; ulint size; ut_ad(buf_pool); - - if (buf_end - buf < 400) { - - return; - } - size = buf_pool->curr_size; mutex_enter(&(buf_pool->mutex)); - buf += sprintf(buf, - "Buffer pool size %lu\n", (ulong) size); - buf += sprintf(buf, - "Free buffers %lu\n", (ulong) UT_LIST_GET_LEN(buf_pool->free)); - buf += sprintf(buf, - "Database pages %lu\n", (ulong) UT_LIST_GET_LEN(buf_pool->LRU)); -/* - buf += sprintf(buf, - "Lock heap buffers %lu\n", (ulong) buf_pool->n_lock_heap_pages); - buf += sprintf(buf, - "Hash index buffers %lu\n", (ulong) buf_pool->n_adaptive_hash_pages); -*/ - buf += sprintf(buf, - "Modified db pages %lu\n", - (ulong) UT_LIST_GET_LEN(buf_pool->flush_list)); if (srv_use_awe) { - buf += sprintf(buf, + fprintf(stderr, "AWE: Buffer pool memory frames %lu\n", (ulong) buf_pool->n_frames); - buf += sprintf(buf, + fprintf(stderr, "AWE: Database pages and free buffers mapped in frames %lu\n", (ulong) UT_LIST_GET_LEN(buf_pool->awe_LRU_free_mapped)); } - - buf += sprintf(buf, "Pending reads %lu \n", (ulong) buf_pool->n_pend_reads); - - buf += sprintf(buf, + fprintf(file, + "Buffer pool size %lu\n" + "Free buffers %lu\n" + "Database pages %lu\n" + "Modified db pages %lu\n" + "Pending reads %lu\n" "Pending writes: LRU %lu, flush list %lu, single page %lu\n", - (ulong) (buf_pool->n_flush[BUF_FLUSH_LRU] - + buf_pool->init_flush[BUF_FLUSH_LRU]), - (ulong) (buf_pool->n_flush[BUF_FLUSH_LIST] - + buf_pool->init_flush[BUF_FLUSH_LIST]), + (ulong) size, + (ulong) UT_LIST_GET_LEN(buf_pool->free), + (ulong) UT_LIST_GET_LEN(buf_pool->LRU), + (ulong) UT_LIST_GET_LEN(buf_pool->flush_list), + (ulong) buf_pool->n_pend_reads, + (ulong) buf_pool->n_flush[BUF_FLUSH_LRU] + + buf_pool->init_flush[BUF_FLUSH_LRU], + (ulong) buf_pool->n_flush[BUF_FLUSH_LIST] + + buf_pool->init_flush[BUF_FLUSH_LIST], (ulong) buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]); current_time = time(NULL); @@ -2256,11 +2230,12 @@ buf_print_io( buf_pool->last_printout_time); buf_pool->last_printout_time = current_time; - buf += sprintf(buf, "Pages read %lu, created %lu, written %lu\n", - (ulong) buf_pool->n_pages_read, - (ulong) buf_pool->n_pages_created, - (ulong) buf_pool->n_pages_written); - buf += sprintf(buf, "%.2f reads/s, %.2f creates/s, %.2f writes/s\n", + fprintf(file, + "Pages read %lu, created %lu, written %lu\n" + "%.2f reads/s, %.2f creates/s, %.2f writes/s\n", + (ulong) buf_pool->n_pages_read, + (ulong) buf_pool->n_pages_created, + (ulong) buf_pool->n_pages_written, (buf_pool->n_pages_read - buf_pool->n_pages_read_old) / time_elapsed, (buf_pool->n_pages_created - buf_pool->n_pages_created_old) @@ -2269,21 +2244,21 @@ buf_print_io( / time_elapsed); if (srv_use_awe) { - buf += sprintf(buf, "AWE: %.2f page remaps/s\n", + fprintf(file, "AWE: %.2f page remaps/s\n", (buf_pool->n_pages_awe_remapped - buf_pool->n_pages_awe_remapped_old) / time_elapsed); } if (buf_pool->n_page_gets > buf_pool->n_page_gets_old) { - buf += sprintf(buf, "Buffer pool hit rate %lu / 1000\n", + fprintf(file, "Buffer pool hit rate %lu / 1000\n", (ulong) (1000 - ((1000 * (buf_pool->n_pages_read - buf_pool->n_pages_read_old)) / (buf_pool->n_page_gets - buf_pool->n_page_gets_old)))); } else { - buf += sprintf(buf, - "No buffer pool page gets since the last printout\n"); + fputs("No buffer pool page gets since the last printout\n", + file); } buf_pool->n_page_gets_old = buf_pool->n_page_gets; @@ -2332,8 +2307,9 @@ buf_all_freed(void) if (!buf_flush_ready_for_replace(block)) { - /* printf("Page %lu %lu still fixed or dirty\n", - block->space, block->offset); */ + fprintf(stderr, + "Page %lu %lu still fixed or dirty\n", + (ulong) block->space, (ulong) block->offset); ut_error; } } |