summaryrefslogtreecommitdiff
path: root/innobase/buf
diff options
context:
space:
mode:
authorunknown <heikki@hundin.mysql.fi>2002-03-21 18:03:09 +0200
committerunknown <heikki@hundin.mysql.fi>2002-03-21 18:03:09 +0200
commitd3c0752b6aec6afef1f0dba85c9a0f1237843e6d (patch)
tree8484c3bb65d40af0743b44a24a788dc2d5cf7d48 /innobase/buf
parent838c6427b278a016f968338468761dabcfecba29 (diff)
downloadmariadb-git-d3c0752b6aec6afef1f0dba85c9a0f1237843e6d.tar.gz
Many files:
Merge InnoDB-3.23.50 innobase/btr/btr0btr.c: Merge InnoDB-3.23.50 innobase/btr/btr0cur.c: Merge InnoDB-3.23.50 innobase/btr/btr0sea.c: Merge InnoDB-3.23.50 innobase/buf/buf0buf.c: Merge InnoDB-3.23.50 innobase/buf/buf0flu.c: Merge InnoDB-3.23.50 innobase/dict/dict0dict.c: Merge InnoDB-3.23.50 innobase/dict/dict0load.c: Merge InnoDB-3.23.50 innobase/fil/fil0fil.c: Merge InnoDB-3.23.50 innobase/fsp/fsp0fsp.c: Merge InnoDB-3.23.50 innobase/include/buf0flu.h: Merge InnoDB-3.23.50 innobase/include/dict0dict.h: Merge InnoDB-3.23.50 innobase/include/fil0fil.h: Merge InnoDB-3.23.50 innobase/include/fsp0fsp.h: Merge InnoDB-3.23.50 innobase/include/log0log.h: Merge InnoDB-3.23.50 innobase/include/log0recv.h: Merge InnoDB-3.23.50 innobase/include/mem0mem.h: Merge InnoDB-3.23.50 innobase/include/os0file.h: Merge InnoDB-3.23.50 innobase/include/row0mysql.h: Merge InnoDB-3.23.50 innobase/include/srv0srv.h: Merge InnoDB-3.23.50 innobase/include/srv0start.h: Merge InnoDB-3.23.50 innobase/include/trx0sys.h: Merge InnoDB-3.23.50 innobase/include/ut0byte.h: Merge InnoDB-3.23.50 innobase/include/ut0rnd.h: Merge InnoDB-3.23.50 innobase/include/ut0ut.h: Merge InnoDB-3.23.50 innobase/log/log0log.c: Merge InnoDB-3.23.50 innobase/log/log0recv.c: Merge InnoDB-3.23.50 innobase/mem/mem0mem.c: Merge InnoDB-3.23.50 innobase/os/os0file.c: Merge InnoDB-3.23.50 innobase/rem/rem0cmp.c: Merge InnoDB-3.23.50 innobase/row/row0ins.c: Merge InnoDB-3.23.50 innobase/row/row0mysql.c: Merge InnoDB-3.23.50 innobase/row/row0sel.c: Merge InnoDB-3.23.50 innobase/row/row0upd.c: Merge InnoDB-3.23.50 innobase/srv/srv0srv.c: Merge InnoDB-3.23.50 innobase/srv/srv0start.c: Merge InnoDB-3.23.50 innobase/trx/trx0sys.c: Merge InnoDB-3.23.50 innobase/ut/ut0mem.c: Merge InnoDB-3.23.50 innobase/ut/ut0ut.c: Merge InnoDB-3.23.50 sql/ha_innobase.cc: Merge InnoDB-3.23.50 sql/ha_innobase.h: Merge InnoDB-3.23.50
Diffstat (limited to 'innobase/buf')
-rw-r--r--innobase/buf/buf0buf.c82
-rw-r--r--innobase/buf/buf0flu.c47
2 files changed, 94 insertions, 35 deletions
diff --git a/innobase/buf/buf0buf.c b/innobase/buf/buf0buf.c
index 055d76e6d81..f1a2d915d46 100644
--- a/innobase/buf/buf0buf.c
+++ b/innobase/buf/buf0buf.c
@@ -220,6 +220,10 @@ buf_calc_page_checksum(
{
ulint checksum;
+ /* Since the fields FIL_PAGE_FILE_FLUSH_LSN and ..._ARCH_LOG_NO
+ are written outside the buffer pool to the first pages of data
+ files, we have to skip them in page checksum calculation */
+
checksum = ut_fold_binary(page, FIL_PAGE_FILE_FLUSH_LSN);
+ ut_fold_binary(page + FIL_PAGE_DATA,
UNIV_PAGE_SIZE - FIL_PAGE_DATA
@@ -279,8 +283,9 @@ buf_page_print(
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",
+ " InnoDB: Page dump in ascii and hex (%lu bytes):\n%s",
UNIV_PAGE_SIZE, buf);
fprintf(stderr, "InnoDB: End of page dump\n");
@@ -288,7 +293,8 @@ buf_page_print(
checksum = buf_calc_page_checksum(read_buf);
- fprintf(stderr, "InnoDB: Page checksum %lu stored checksum %lu\n",
+ ut_print_timestamp(stderr);
+ fprintf(stderr, " InnoDB: Page checksum %lu stored checksum %lu\n",
checksum, mach_read_from_4(read_buf
+ UNIV_PAGE_SIZE
- FIL_PAGE_END_LSN));
@@ -1358,47 +1364,87 @@ buf_page_io_complete(
/*=================*/
buf_block_t* block) /* in: pointer to the block in question */
{
- dulint id;
dict_index_t* index;
+ dulint id;
ulint io_type;
-
+ ulint read_page_no;
+
ut_ad(block);
io_type = block->io_fix;
if (io_type == BUF_IO_READ) {
+ /* If this page is not uninitialized and not in the
+ doublewrite buffer, then the page number should be the
+ same as in block */
+
+ read_page_no = mach_read_from_4((block->frame)
+ + FIL_PAGE_OFFSET);
+ if (read_page_no != 0
+ && !trx_doublewrite_page_inside(read_page_no)
+ && read_page_no != block->offset) {
+
+ fprintf(stderr,
+"InnoDB: Error: page n:o stored in the page read in is %lu, should be %lu!\n",
+ read_page_no, block->offset);
+ }
+#ifdef notdefined
+ if (block->offset != 0 && read_page_no == 0) {
+ /* Check that the page is really uninited */
+
+ for (i = 0; i < UNIV_PAGE_SIZE; i++) {
+
+ if (*((block->frame) + i) != '\0') {
+ fprintf(stderr,
+"InnoDB: Error: page n:o in the page read in is 0, but page %lu is inited!\n",
+ block->offset);
+ break;
+ }
+ }
+ }
+#endif
/* From version 3.23.38 up we store the page checksum
- to the 4 upper bytes of the page end lsn field */
+ to the 4 first bytes of the page end lsn field */
if (buf_page_is_corrupted(block->frame)) {
fprintf(stderr,
- "InnoDB: Database page corruption or a failed\n"
- "InnoDB: file read of page %lu.\n", block->offset);
+ "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");
+ "InnoDB: You may have to recover from a backup.\n");
buf_page_print(block->frame);
fprintf(stderr,
- "InnoDB: Database page corruption or a failed\n"
- "InnoDB: file read of page %lu.\n", block->offset);
+ "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");
+ "InnoDB: You may have to recover from a backup.\n");
fprintf(stderr,
- "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"
- "InnoDB: error.\n");
+ "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"
+ "InnoDB: error.\n"
+ "InnoDB: If the corrupt page is an index page\n"
+ "InnoDB: you can also try to fix the corruption\n"
+ "InnoDB: by dumping, dropping, and reimporting\n"
+ "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");
- if (srv_force_recovery < SRV_FORCE_IGNORE_CORRUPT) {
+ if (srv_force_recovery < SRV_FORCE_IGNORE_CORRUPT) {
+ fprintf(stderr,
+ "InnoDB: Ending processing because of a corrupt database page.\n");
exit(1);
}
}
if (recv_recovery_is_on()) {
- recv_recover_page(TRUE, block->frame, block->space,
- block->offset);
+ recv_recover_page(FALSE, TRUE, block->frame,
+ block->space, block->offset);
}
if (!recv_no_ibuf_operations) {
diff --git a/innobase/buf/buf0flu.c b/innobase/buf/buf0flu.c
index 8184f10d6e9..4c6850af078 100644
--- a/innobase/buf/buf0flu.c
+++ b/innobase/buf/buf0flu.c
@@ -328,6 +328,34 @@ try_again:
}
/************************************************************************
+Initializes a page for writing to the tablespace. */
+
+void
+buf_flush_init_for_writing(
+/*=======================*/
+ byte* page, /* in: page */
+ dulint newest_lsn, /* in: newest modification lsn to the page */
+ ulint space, /* in: space id */
+ ulint page_no) /* in: page number */
+{
+ /* Write the newest modification lsn to the page */
+ mach_write_to_8(page + FIL_PAGE_LSN, newest_lsn);
+
+ mach_write_to_8(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN, newest_lsn);
+
+ /* Write to the page the space id and page number */
+
+ mach_write_to_4(page + FIL_PAGE_SPACE, space);
+ mach_write_to_4(page + FIL_PAGE_OFFSET, page_no);
+
+ /* We overwrite the first 4 bytes of the end lsn field to store
+ a page checksum */
+
+ mach_write_to_4(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN,
+ buf_calc_page_checksum(page));
+}
+
+/************************************************************************
Does an asynchronous write of a buffer page. NOTE: in simulated aio and
also when the doublewrite buffer is used, we must call
buf_flush_buffered_writes after we have posted a batch of writes! */
@@ -349,23 +377,8 @@ buf_flush_write_block_low(
/* Force the log to the disk before writing the modified block */
log_flush_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS);
#endif
- /* Write the newest modification lsn to the page */
- mach_write_to_8(block->frame + FIL_PAGE_LSN,
- block->newest_modification);
- mach_write_to_8(block->frame + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN,
- block->newest_modification);
-
- /* Write to the page the space id and page number */
-
- mach_write_to_4(block->frame + FIL_PAGE_SPACE, block->space);
- mach_write_to_4(block->frame + FIL_PAGE_OFFSET, block->offset);
-
- /* We overwrite the first 4 bytes of the end lsn field to store
- a page checksum */
-
- mach_write_to_4(block->frame + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN,
- buf_calc_page_checksum(block->frame));
-
+ buf_flush_init_for_writing(block->frame, block->newest_modification,
+ block->space, block->offset);
if (!trx_doublewrite) {
fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER,
FALSE, block->space, block->offset, 0, UNIV_PAGE_SIZE,