mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
InnoDB: send diagnostic output to stderr or files
instead of stdout or fixed-size memory buffers
This commit is contained in:
@ -348,19 +348,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",
|
||||
(ulint)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);
|
||||
@ -407,18 +400,17 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1464,8 +1456,8 @@ buf_page_create(
|
||||
/* If we get here, the page was not in buf_pool: init it there */
|
||||
|
||||
if (buf_debug_prints) {
|
||||
printf("Creating space %lu page %lu to buffer\n", space,
|
||||
offset);
|
||||
fprintf(stderr, "Creating space %lu page %lu to buffer\n",
|
||||
space, offset);
|
||||
}
|
||||
|
||||
block = free_block;
|
||||
@ -1519,8 +1511,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;
|
||||
|
||||
@ -1551,17 +1541,17 @@ buf_page_io_complete(
|
||||
"InnoDB: Database page corruption on disk or a failed\n"
|
||||
"InnoDB: file read of page %lu.\n", 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", 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"
|
||||
@ -1572,12 +1562,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);
|
||||
}
|
||||
}
|
||||
@ -1619,7 +1610,7 @@ buf_page_io_complete(
|
||||
rw_lock_x_unlock_gen(&(block->read_lock), BUF_IO_READ);
|
||||
|
||||
if (buf_debug_prints) {
|
||||
printf("Has read ");
|
||||
fputs("Has read ", stderr);
|
||||
}
|
||||
} else {
|
||||
ut_ad(io_type == BUF_IO_WRITE);
|
||||
@ -1634,29 +1625,15 @@ buf_page_io_complete(
|
||||
buf_pool->n_pages_written++;
|
||||
|
||||
if (buf_debug_prints) {
|
||||
printf("Has written ");
|
||||
fputs("Has written ", stderr);
|
||||
}
|
||||
}
|
||||
|
||||
mutex_exit(&(buf_pool->mutex));
|
||||
|
||||
if (buf_debug_prints) {
|
||||
printf("page space %lu page no %lu", block->space,
|
||||
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",
|
||||
block->space, block->offset);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1757,14 +1734,14 @@ buf_validate(void)
|
||||
}
|
||||
|
||||
if (n_lru + n_free > buf_pool->curr_size) {
|
||||
printf("n LRU %lu, n free %lu\n", n_lru, n_free);
|
||||
fprintf(stderr, "n LRU %lu, n free %lu\n", n_lru, 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",
|
||||
UT_LIST_GET_LEN(buf_pool->free), n_free);
|
||||
fprintf(stderr, "Free list len %lu, free blocks %lu\n",
|
||||
UT_LIST_GET_LEN(buf_pool->free), n_free);
|
||||
ut_error;
|
||||
}
|
||||
ut_a(UT_LIST_GET_LEN(buf_pool->flush_list) == n_flush);
|
||||
@ -1807,22 +1784,24 @@ buf_print(void)
|
||||
|
||||
mutex_enter(&(buf_pool->mutex));
|
||||
|
||||
printf("buf_pool size %lu \n", size);
|
||||
printf("database pages %lu \n", UT_LIST_GET_LEN(buf_pool->LRU));
|
||||
printf("free pages %lu \n", UT_LIST_GET_LEN(buf_pool->free));
|
||||
printf("modified database pages %lu \n",
|
||||
UT_LIST_GET_LEN(buf_pool->flush_list));
|
||||
|
||||
printf("n pending reads %lu \n", buf_pool->n_pend_reads);
|
||||
|
||||
printf("n pending flush LRU %lu list %lu single page %lu\n",
|
||||
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",
|
||||
size,
|
||||
UT_LIST_GET_LEN(buf_pool->LRU),
|
||||
UT_LIST_GET_LEN(buf_pool->free),
|
||||
UT_LIST_GET_LEN(buf_pool->flush_list),
|
||||
buf_pool->n_pend_reads,
|
||||
buf_pool->n_flush[BUF_FLUSH_LRU],
|
||||
buf_pool->n_flush[BUF_FLUSH_LIST],
|
||||
buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]);
|
||||
|
||||
printf("pages read %lu, created %lu, written %lu\n",
|
||||
buf_pool->n_pages_read, buf_pool->n_pages_created,
|
||||
buf_pool->n_pages_written);
|
||||
buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE],
|
||||
buf_pool->n_pages_read, buf_pool->n_pages_created,
|
||||
buf_pool->n_pages_written);
|
||||
|
||||
/* Count the number of blocks belonging to each index in the buffer */
|
||||
|
||||
@ -1865,15 +1844,16 @@ 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",
|
||||
ut_dulint_get_low(index_ids[i]), 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);
|
||||
@ -1924,44 +1904,29 @@ 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_get_curr_size() / UNIV_PAGE_SIZE;
|
||||
|
||||
mutex_enter(&(buf_pool->mutex));
|
||||
|
||||
buf += sprintf(buf,
|
||||
"Buffer pool size %lu\n", size);
|
||||
buf += sprintf(buf,
|
||||
"Free buffers %lu\n", UT_LIST_GET_LEN(buf_pool->free));
|
||||
buf += sprintf(buf,
|
||||
"Database pages %lu\n", UT_LIST_GET_LEN(buf_pool->LRU));
|
||||
/*
|
||||
buf += sprintf(buf,
|
||||
"Lock heap buffers %lu\n", buf_pool->n_lock_heap_pages);
|
||||
buf += sprintf(buf,
|
||||
"Hash index buffers %lu\n", buf_pool->n_adaptive_hash_pages);
|
||||
*/
|
||||
buf += sprintf(buf,
|
||||
"Modified db pages %lu\n",
|
||||
UT_LIST_GET_LEN(buf_pool->flush_list));
|
||||
|
||||
buf += sprintf(buf, "Pending reads %lu \n", 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",
|
||||
size,
|
||||
UT_LIST_GET_LEN(buf_pool->free),
|
||||
UT_LIST_GET_LEN(buf_pool->LRU),
|
||||
UT_LIST_GET_LEN(buf_pool->flush_list),
|
||||
buf_pool->n_pend_reads,
|
||||
buf_pool->n_flush[BUF_FLUSH_LRU]
|
||||
+ buf_pool->init_flush[BUF_FLUSH_LRU],
|
||||
buf_pool->n_flush[BUF_FLUSH_LIST]
|
||||
@ -1973,10 +1938,11 @@ 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",
|
||||
buf_pool->n_pages_read, buf_pool->n_pages_created,
|
||||
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",
|
||||
buf_pool->n_pages_read, buf_pool->n_pages_created,
|
||||
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)
|
||||
@ -1985,14 +1951,14 @@ buf_print_io(
|
||||
/ 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",
|
||||
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;
|
||||
@ -2039,8 +2005,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",
|
||||
block->space, block->offset);
|
||||
ut_error;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user