summaryrefslogtreecommitdiff
path: root/innobase
diff options
context:
space:
mode:
authorunknown <jan@hundin.mysql.fi>2004-12-21 07:49:38 +0200
committerunknown <jan@hundin.mysql.fi>2004-12-21 07:49:38 +0200
commit52d080f09979deb2063a8010feee3b925a3d7938 (patch)
tree5d3767a8558fd05da17b5d4e3f361ef643d3a9b8 /innobase
parent868266f1b1ec0adde75db2887bbc73306441caeb (diff)
parent272b380b459633454ad0ffbd877a986e06196216 (diff)
downloadmariadb-git-52d080f09979deb2063a8010feee3b925a3d7938.tar.gz
Content merge.
sql/ha_innodb.cc: Auto merged sql/ha_innodb.h: Auto merged sql/handler.h: Auto merged sql/mysql_priv.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_yacc.yy: Auto merged innobase/trx/trx0roll.c: Auto merged.
Diffstat (limited to 'innobase')
-rw-r--r--innobase/buf/buf0buf.c56
-rw-r--r--innobase/buf/buf0flu.c6
-rw-r--r--innobase/include/Makefile.am2
-rw-r--r--innobase/include/buf0buf.h2
-rw-r--r--innobase/include/os0proc.h28
-rw-r--r--innobase/include/page0page.ic26
-rw-r--r--innobase/include/rem0rec.ic81
-rw-r--r--innobase/include/srv0srv.h1
-rw-r--r--innobase/include/trx0roll.h16
-rw-r--r--innobase/log/log0recv.c1
-rw-r--r--innobase/os/os0proc.c87
-rw-r--r--innobase/srv/srv0srv.c1
-rw-r--r--innobase/srv/srv0start.c12
-rw-r--r--innobase/trx/trx0roll.c68
-rw-r--r--innobase/trx/trx0sys.c19
15 files changed, 312 insertions, 94 deletions
diff --git a/innobase/buf/buf0buf.c b/innobase/buf/buf0buf.c
index 3930ea93889..89f851709db 100644
--- a/innobase/buf/buf0buf.c
+++ b/innobase/buf/buf0buf.c
@@ -331,33 +331,43 @@ buf_page_is_corrupted(
}
}
#endif
- old_checksum = buf_calc_page_old_checksum(read_buf);
-
- old_checksum_field = mach_read_from_4(read_buf + UNIV_PAGE_SIZE
+
+ /* If we use checksums validation, make additional check before returning
+ TRUE to ensure that the checksum is not equal to BUF_NO_CHECKSUM_MAGIC which
+ might be stored by InnoDB with checksums disabled.
+ Otherwise, skip checksum calculation and return FALSE */
+
+ if (srv_use_checksums) {
+ old_checksum = buf_calc_page_old_checksum(read_buf);
+
+ old_checksum_field = mach_read_from_4(read_buf + UNIV_PAGE_SIZE
- FIL_PAGE_END_LSN_OLD_CHKSUM);
- /* There are 2 valid formulas for old_checksum_field:
- 1. Very old versions of InnoDB only stored 8 byte lsn to the start
- and the end of the page.
- 2. Newer InnoDB versions store the old formula checksum there. */
+ /* There are 2 valid formulas for old_checksum_field:
+ 1. Very old versions of InnoDB only stored 8 byte lsn to the start
+ and the end of the page.
+ 2. Newer InnoDB versions store the old formula checksum there. */
- if (old_checksum_field != mach_read_from_4(read_buf + FIL_PAGE_LSN)
- && old_checksum_field != old_checksum) {
+ if (old_checksum_field != mach_read_from_4(read_buf + FIL_PAGE_LSN)
+ && old_checksum_field != old_checksum
+ && old_checksum_field != BUF_NO_CHECKSUM_MAGIC) {
- return(TRUE);
- }
+ return(TRUE);
+ }
- checksum = buf_calc_page_new_checksum(read_buf);
- checksum_field = mach_read_from_4(read_buf + FIL_PAGE_SPACE_OR_CHKSUM);
+ checksum = buf_calc_page_new_checksum(read_buf);
+ checksum_field = mach_read_from_4(read_buf + FIL_PAGE_SPACE_OR_CHKSUM);
- /* InnoDB versions < 4.0.14 and < 4.1.1 stored the space id
- (always equal to 0), to FIL_PAGE_SPACE_SPACE_OR_CHKSUM */
+ /* InnoDB versions < 4.0.14 and < 4.1.1 stored the space id
+ (always equal to 0), to FIL_PAGE_SPACE_SPACE_OR_CHKSUM */
- if (checksum_field != 0 && checksum_field != checksum) {
-
- return(TRUE);
- }
+ if (checksum_field != 0 && checksum_field != checksum
+ && checksum_field != BUF_NO_CHECKSUM_MAGIC) {
+ return(TRUE);
+ }
+ }
+
return(FALSE);
}
@@ -379,8 +389,10 @@ buf_page_print(
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);
+ checksum = srv_use_checksums ?
+ buf_calc_page_new_checksum(read_buf) : BUF_NO_CHECKSUM_MAGIC;
+ old_checksum = srv_use_checksums ?
+ buf_calc_page_old_checksum(read_buf) : BUF_NO_CHECKSUM_MAGIC;
ut_print_timestamp(stderr);
fprintf(stderr,
@@ -548,7 +560,7 @@ buf_pool_init(
}
/*----------------------------------------*/
} else {
- buf_pool->frame_mem = ut_malloc_low(
+ buf_pool->frame_mem = os_mem_alloc_large(
UNIV_PAGE_SIZE * (n_frames + 1),
TRUE, FALSE);
}
diff --git a/innobase/buf/buf0flu.c b/innobase/buf/buf0flu.c
index aff4fe92a71..a0ca614d9b3 100644
--- a/innobase/buf/buf0flu.c
+++ b/innobase/buf/buf0flu.c
@@ -448,7 +448,8 @@ buf_flush_init_for_writing(
/* Store the new formula checksum */
mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM,
- buf_calc_page_new_checksum(page));
+ srv_use_checksums ?
+ buf_calc_page_new_checksum(page) : BUF_NO_CHECKSUM_MAGIC);
/* We overwrite the first 4 bytes of the end lsn field to store
the old formula checksum. Since it depends also on the field
@@ -456,7 +457,8 @@ buf_flush_init_for_writing(
new formula checksum. */
mach_write_to_4(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM,
- buf_calc_page_old_checksum(page));
+ srv_use_checksums ?
+ buf_calc_page_old_checksum(page) : BUF_NO_CHECKSUM_MAGIC);
}
/************************************************************************
diff --git a/innobase/include/Makefile.am b/innobase/include/Makefile.am
index 102d25566da..eb1e3b72877 100644
--- a/innobase/include/Makefile.am
+++ b/innobase/include/Makefile.am
@@ -49,7 +49,7 @@ noinst_HEADERS = btr0btr.h btr0btr.ic btr0cur.h btr0cur.ic \
thr0loc.h thr0loc.ic trx0purge.h trx0purge.ic trx0rec.h \
trx0rec.ic trx0roll.h trx0roll.ic trx0rseg.h trx0rseg.ic \
trx0sys.h trx0sys.ic trx0trx.h trx0trx.ic trx0types.h \
- trx0undo.h trx0undo.ic univ.i \
+ trx0undo.h trx0undo.ic trx0xa.h univ.i \
usr0sess.h usr0sess.ic usr0types.h ut0byte.h ut0byte.ic \
ut0dbg.h ut0lst.h ut0mem.h ut0mem.ic ut0rnd.h ut0rnd.ic \
ut0sort.h ut0ut.h ut0ut.ic
diff --git a/innobase/include/buf0buf.h b/innobase/include/buf0buf.h
index 8df1211327f..5ee323f1b1e 100644
--- a/innobase/include/buf0buf.h
+++ b/innobase/include/buf0buf.h
@@ -52,6 +52,8 @@ Created 11/5/1995 Heikki Tuuri
/* Modes for buf_page_get_known_nowait */
#define BUF_MAKE_YOUNG 51
#define BUF_KEEP_OLD 52
+/* Magic value to use instead of checksums when they are disabled */
+#define BUF_NO_CHECKSUM_MAGIC 0xDEADBEEFUL
extern buf_pool_t* buf_pool; /* The buffer pool of the database */
extern ibool buf_debug_prints;/* If this is set TRUE, the program
diff --git a/innobase/include/os0proc.h b/innobase/include/os0proc.h
index d0d3cf82e38..b0b72e18675 100644
--- a/innobase/include/os0proc.h
+++ b/innobase/include/os0proc.h
@@ -12,6 +12,11 @@ Created 9/30/1995 Heikki Tuuri
#include "univ.i"
+#ifdef UNIV_LINUX
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#endif
+
typedef void* os_process_t;
typedef unsigned long int os_process_id_t;
@@ -27,6 +32,10 @@ page size of an Intel x86 processor. We cannot use AWE with 2 MB or 4 MB
pages. */
#define OS_AWE_X86_PAGE_SIZE 4096
+extern ibool os_use_large_pages;
+/* Large page size. This may be a boot-time option on some platforms */
+extern ulint os_large_page_size;
+
/********************************************************************
Windows AWE support. Tries to enable the "lock pages in memory" privilege for
the current process so that the current process can allocate memory-locked
@@ -103,6 +112,25 @@ os_mem_alloc_nocache(
/* out: allocated memory */
ulint n); /* in: number of bytes */
/********************************************************************
+Allocates large pages memory. */
+
+void*
+os_mem_alloc_large(
+/*=================*/
+ /* out: allocated memory */
+ ulint n, /* in: number of bytes */
+ ibool set_to_zero, /* in: TRUE if allocated memory should be set
+ to zero if UNIV_SET_MEM_TO_ZERO is defined */
+ ibool assert_on_error); /* in: if TRUE, we crash mysqld if the memory
+ cannot be allocated */
+/********************************************************************
+Frees large pages memory. */
+
+void
+os_mem_free_large(
+/*=================*/
+void *ptr); /* in: number of bytes */
+/********************************************************************
Sets the priority boost for threads released from waiting within the current
process. */
diff --git a/innobase/include/page0page.ic b/innobase/include/page0page.ic
index 1d5ea337031..a63b5ca4238 100644
--- a/innobase/include/page0page.ic
+++ b/innobase/include/page0page.ic
@@ -153,6 +153,19 @@ page_header_reset_last_insert(
}
/****************************************************************
+Determine whether the page is in new-style compact format. */
+UNIV_INLINE
+ibool
+page_is_comp(
+/*=========*/
+ /* out: TRUE if the page is in compact format
+ FALSE if it is in old-style format */
+ page_t* page) /* in: index page */
+{
+ return(!!(page_header_get_field(page, PAGE_N_HEAP) & 0x8000));
+}
+
+/****************************************************************
Gets the first record on the page. */
UNIV_INLINE
rec_t*
@@ -514,19 +527,6 @@ page_dir_calc_reserved_space(
}
/****************************************************************
-Determine whether the page is in new-style compact format. */
-UNIV_INLINE
-ibool
-page_is_comp(
-/*=========*/
- /* out: TRUE if the page is in compact format
- FALSE if it is in old-style format */
- page_t* page) /* in: index page */
-{
- return(!!(page_header_get_field(page, PAGE_N_HEAP) & 0x8000));
-}
-
-/****************************************************************
Gets the pointer to the next record on the page. */
UNIV_INLINE
rec_t*
diff --git a/innobase/include/rem0rec.ic b/innobase/include/rem0rec.ic
index db938aa9fa5..6c3dabf04a2 100644
--- a/innobase/include/rem0rec.ic
+++ b/innobase/include/rem0rec.ic
@@ -40,8 +40,18 @@ most significant bytes and bits are written below less significant.
(1) byte offset (2) bit usage within byte
downward from
- origin -> 1 8 bits pointer to next record (relative)
- 2 8 bits pointer to next record (relative)
+ origin -> 1 8 bits relative offset of next record
+ 2 8 bits relative offset of next record
+ the relative offset is an unsigned 16-bit
+ integer:
+ (offset_of_next_record
+ - offset_of_this_record) mod 64Ki,
+ where mod is the modulo as a non-negative
+ number;
+ we can calculate the the offset of the next
+ record with the formula:
+ relative_offset + offset_of_this_record
+ mod UNIV_PAGE_SIZE
3 3 bits status:
000=conventional record
001=node pointer record (inside B-tree)
@@ -252,26 +262,37 @@ UNIV_INLINE
ulint
rec_get_next_offs(
/*==============*/
- /* out: the page offset of the next chained record */
+ /* out: the page offset of the next chained record, or
+ 0 if none */
rec_t* rec, /* in: physical record */
ibool comp) /* in: TRUE=compact page format */
{
+ ulint field_value;
+
+ ut_ad(REC_NEXT_MASK == 0xFFFFUL);
+ ut_ad(REC_NEXT_SHIFT == 0);
+
+ field_value = mach_read_from_2(rec - REC_NEXT);
+
if (comp) {
- lint ret = (int16_t) rec_get_bit_field_2(rec, REC_NEXT,
- REC_NEXT_MASK, REC_NEXT_SHIFT);
#if UNIV_PAGE_SIZE <= 32768
- /* with 64 KiB page size, the pointer will "wrap around",
- and the following assertions are invalid */
- ut_ad(ret + ut_align_offset(rec, UNIV_PAGE_SIZE) <
- UNIV_PAGE_SIZE);
+ /* Note that for 64 KiB pages, field_value can 'wrap around'
+ and the debug assertion is not valid */
+
+ ut_ad((int16_t)field_value
+ + ut_align_offset(rec, UNIV_PAGE_SIZE)
+ < UNIV_PAGE_SIZE);
#endif
- return(ret ? ut_align_offset(rec + ret, UNIV_PAGE_SIZE) : 0);
- }
- else {
- ulint ret = rec_get_bit_field_2(rec, REC_NEXT,
- REC_NEXT_MASK, REC_NEXT_SHIFT);
- ut_ad(ret < UNIV_PAGE_SIZE);
- return(ret);
+ if (field_value == 0) {
+
+ return(0);
+ }
+
+ return(ut_align_offset(rec + field_value, UNIV_PAGE_SIZE));
+ } else {
+ ut_ad(field_value < UNIV_PAGE_SIZE);
+
+ return(field_value);
}
}
@@ -284,21 +305,31 @@ rec_set_next_offs(
/*==============*/
rec_t* rec, /* in: physical record */
ibool comp, /* in: TRUE=compact page format */
- ulint next) /* in: offset of the next record */
+ ulint next) /* in: offset of the next record, or 0 if none */
{
ut_ad(rec);
ut_ad(UNIV_PAGE_SIZE > next);
+ ut_ad(REC_NEXT_MASK == 0xFFFFUL);
+ ut_ad(REC_NEXT_SHIFT == 0);
if (comp) {
- rec_set_bit_field_2(rec, next
- ? (next - ut_align_offset(rec, UNIV_PAGE_SIZE))
-#ifdef UNIV_DEBUG /* avoid an assertion failure */
- & (REC_NEXT_MASK >> REC_NEXT_SHIFT)
-#endif
- : 0, REC_NEXT, REC_NEXT_MASK, REC_NEXT_SHIFT);
+ ulint field_value;
+
+ if (next) {
+ /* The following two statements calculate
+ next - offset_of_rec mod 64Ki, where mod is the modulo
+ as a non-negative number */
+
+ field_value = (ulint)((lint)next
+ - (lint)ut_align_offset(rec, UNIV_PAGE_SIZE));
+ field_value &= REC_NEXT_MASK;
+ } else {
+ field_value = 0;
+ }
+
+ mach_write_to_2(rec - REC_NEXT, field_value);
} else {
- rec_set_bit_field_2(rec, next,
- REC_NEXT, REC_NEXT_MASK, REC_NEXT_SHIFT);
+ mach_write_to_2(rec - REC_NEXT, next);
}
}
diff --git a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
index d4cc7d8222f..84b7d14ca00 100644
--- a/innobase/include/srv0srv.h
+++ b/innobase/include/srv0srv.h
@@ -107,6 +107,7 @@ extern ibool srv_very_fast_shutdown; /* if this TRUE, do not flush the
extern ibool srv_innodb_status;
extern ibool srv_use_doublewrite_buf;
+extern ibool srv_use_checksums;
extern ibool srv_set_thread_priorities;
extern int srv_query_thread_priority;
diff --git a/innobase/include/trx0roll.h b/innobase/include/trx0roll.h
index 893e5af6c01..9d025da4a5f 100644
--- a/innobase/include/trx0roll.h
+++ b/innobase/include/trx0roll.h
@@ -105,11 +105,19 @@ trx_rollback(
Rollback or clean up transactions which have no user session. If the
transaction already was committed, then we clean up a possible insert
undo log. If the transaction was not yet committed, then we roll it back.
-Note: this is done in a background thread */
+Note: this is done in a background thread. */
-void *
-trx_rollback_or_clean_all_without_sess(void *);
-/*============================================*/
+#ifndef __WIN__
+void*
+#else
+ulint
+#endif
+trx_rollback_or_clean_all_without_sess(
+/*===================================*/
+ /* out: a dummy parameter */
+ void* arg __attribute__((unused)));
+ /* in: a dummy parameter required by
+ os_thread_create */
/********************************************************************
Finishes a transaction rollback. */
diff --git a/innobase/log/log0recv.c b/innobase/log/log0recv.c
index f42f0eb8c72..5eefd32c8a6 100644
--- a/innobase/log/log0recv.c
+++ b/innobase/log/log0recv.c
@@ -2937,7 +2937,6 @@ recv_recovery_from_checkpoint_finish(void)
#ifndef UNIV_LOG_DEBUG
recv_sys_free();
#endif
-
if (srv_force_recovery < SRV_FORCE_NO_TRX_UNDO) {
os_thread_create(trx_rollback_or_clean_all_without_sess,
(void *)&i, &recovery_thread_id);
diff --git a/innobase/os/os0proc.c b/innobase/os/os0proc.c
index 2f155788420..167aed93de7 100644
--- a/innobase/os/os0proc.c
+++ b/innobase/os/os0proc.c
@@ -69,6 +69,10 @@ byte* os_awe_window;
ulint os_awe_window_size;
#endif
+ibool os_use_large_pages;
+/* Large page size. This may be a boot-time option on some platforms */
+ulint os_large_page_size;
+
/********************************************************************
Windows AWE support. Tries to enable the "lock pages in memory" privilege for
the current process so that the current process can allocate memory-locked
@@ -516,6 +520,89 @@ os_mem_alloc_nocache(
}
/********************************************************************
+Allocates large pages memory. */
+
+void*
+os_mem_alloc_large(
+/*=================*/
+ /* out: allocated memory */
+ ulint n, /* in: number of bytes */
+ ibool set_to_zero, /* in: TRUE if allocated memory should be set
+ to zero if UNIV_SET_MEM_TO_ZERO is defined */
+ ibool assert_on_error) /* in: if TRUE, we crash mysqld if the memory
+ cannot be allocated */
+{
+#ifdef HAVE_LARGE_PAGES
+ ulint size;
+ int shmid;
+ void *ptr = NULL;
+ struct shmid_ds buf;
+
+ if (!os_use_large_pages || !os_large_page_size) {
+ goto skip;
+ }
+
+#ifdef UNIV_LINUX
+ /* Align block size to os_large_page_size */
+ size = ((n - 1) & ~(os_large_page_size - 1)) + os_large_page_size;
+
+ shmid = shmget(IPC_PRIVATE, (size_t)size, SHM_HUGETLB | SHM_R | SHM_W);
+ if (shmid < 0) {
+ fprintf(stderr, "InnoDB: HugeTLB: Warning: Failed to allocate %lu bytes. "
+ "errno %d\n", n, errno);
+ } else {
+ ptr = shmat(shmid, NULL, 0);
+ if (ptr == (void *)-1) {
+ fprintf(stderr, "InnoDB: HugeTLB: Warning: Failed to attach shared memory "
+ "segment, errno %d\n", errno);
+ }
+ /*
+ Remove the shared memory segment so that it will be automatically freed
+ after memory is detached or process exits
+ */
+ shmctl(shmid, IPC_RMID, &buf);
+ }
+#endif
+
+ if (ptr) {
+ if (set_to_zero) {
+#ifdef UNIV_SET_MEM_TO_ZERO
+ memset(ptr, '\0', size);
+#endif
+ }
+
+ return(ptr);
+ }
+
+ fprintf(stderr, "InnoDB HugeTLB: Warning: Using conventional memory pool\n");
+skip:
+#endif /* HAVE_LARGE_PAGES */
+
+ return(ut_malloc_low(n, set_to_zero, assert_on_error));
+}
+
+/********************************************************************
+Frees large pages memory. */
+
+void
+os_mem_free_large(
+/*=================*/
+ void *ptr) /* in: number of bytes */
+{
+#ifdef HAVE_LARGE_PAGES
+ if (os_use_large_pages && os_large_page_size
+#ifdef UNIV_LINUX
+ && !shmdt(ptr)
+#endif
+ ) {
+ return;
+ }
+#endif
+
+ ut_free(ptr);
+}
+
+/********************************************************************
Sets the priority boost for threads released from waiting within the current
process. */
diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
index 40befae424e..83d4fb4d39d 100644
--- a/innobase/srv/srv0srv.c
+++ b/innobase/srv/srv0srv.c
@@ -313,6 +313,7 @@ ibool srv_very_fast_shutdown = FALSE; /* if this TRUE, do not flush the
ibool srv_innodb_status = FALSE;
ibool srv_use_doublewrite_buf = TRUE;
+ibool srv_use_checksums = TRUE;
ibool srv_set_thread_priorities = TRUE;
int srv_query_thread_priority = 0;
diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
index 69341a1d7d1..a0e763d7a44 100644
--- a/innobase/srv/srv0start.c
+++ b/innobase/srv/srv0start.c
@@ -1403,15 +1403,13 @@ NetWare. */
fsp_header_inc_size(0, sum_of_new_sizes, &mtr);
mtr_commit(&mtr);
- }
- if (recv_needed_recovery) {
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Flushing modified pages from the buffer pool...\n");
- }
+ /* Immediately write the log record about increased tablespace
+ size to disk, so that it is durable even if mysqld would crash
+ quickly */
- log_make_checkpoint_at(ut_dulint_max, TRUE);
+ log_buffer_flush_to_disk();
+ }
#ifdef UNIV_LOG_ARCHIVE
/* Archiving is always off under MySQL */
diff --git a/innobase/trx/trx0roll.c b/innobase/trx/trx0roll.c
index 105fa97080f..e5cffd2a4f3 100644
--- a/innobase/trx/trx0roll.c
+++ b/innobase/trx/trx0roll.c
@@ -30,9 +30,13 @@ Created 3/26/1996 Heikki Tuuri
/* This many pages must be undone before a truncate is tried within rollback */
#define TRX_ROLL_TRUNC_THRESHOLD 1
+/* In crash recovery, the current trx to be rolled back */
+trx_t* trx_roll_crash_recv_trx = NULL;
+
/* In crash recovery we set this to the undo n:o of the current trx to be
rolled back. Then we can print how many % the rollback has progressed. */
ib_longlong trx_roll_max_undo_no;
+
/* Auxiliary variable which tells the previous progress % we printed */
ulint trx_roll_progress_printed_pct;
@@ -332,13 +336,19 @@ trx_savept_take(
Rollback or clean up transactions which have no user session. If the
transaction already was committed, then we clean up a possible insert
undo log. If the transaction was not yet committed, then we roll it back.
-Note: this is done in a background thread */
+Note: this is done in a background thread. */
-void *
+#ifndef __WIN__
+void*
+#else
+ulint
+#endif
trx_rollback_or_clean_all_without_sess(
/*===================================*/
- /* out: arguments */
- void *i) /* in: arguments (unused) */
+ /* out: a dummy parameter */
+ void* arg __attribute__((unused)))
+ /* in: a dummy parameter required by
+ os_thread_create */
{
mem_heap_t* heap;
que_fork_t* fork;
@@ -363,9 +373,9 @@ trx_rollback_or_clean_all_without_sess(
if (UT_LIST_GET_FIRST(trx_sys->trx_list)) {
fprintf(stderr,
- "InnoDB: Starting rollback of uncommitted transactions\n");
+"InnoDB: Starting in background the rollback of uncommitted transactions\n");
} else {
- os_thread_exit(i);
+ goto leave_function;
}
loop:
heap = mem_heap_create(512);
@@ -375,7 +385,6 @@ loop:
trx = UT_LIST_GET_FIRST(trx_sys->trx_list);
while (trx) {
-
if ((trx->sess || (trx->conc_state == TRX_NOT_STARTED))) {
trx = UT_LIST_GET_NEXT(trx_list, trx);
} else if (trx->conc_state == TRX_PREPARED) {
@@ -388,17 +397,17 @@ loop:
mutex_exit(&kernel_mutex);
if (trx == NULL) {
+ ut_print_timestamp(stderr);
fprintf(stderr,
- "InnoDB: Rollback of uncommitted transactions completed\n");
+ " InnoDB: Rollback of uncommitted transactions completed\n");
mem_heap_free(heap);
-
- os_thread_exit(i);
+
+ goto leave_function;
}
trx->sess = trx_dummy_sess;
-
if (trx->conc_state == TRX_COMMITTED_IN_MEMORY) {
fprintf(stderr, "InnoDB: Cleaning up trx with id %lu %lu\n",
(ulong) ut_dulint_get_high(trx->id),
@@ -427,21 +436,28 @@ loop:
ut_a(thr == que_fork_start_command(fork));
+ trx_roll_crash_recv_trx = trx;
trx_roll_max_undo_no = ut_conv_dulint_to_longlong(trx->undo_no);
trx_roll_progress_printed_pct = 0;
rows_to_undo = trx_roll_max_undo_no;
+
if (rows_to_undo > 1000000000) {
rows_to_undo = rows_to_undo / 1000000;
unit = "M";
}
+ ut_print_timestamp(stderr);
fprintf(stderr,
-"InnoDB: Rolling back trx with id %lu %lu, %lu%s rows to undo",
+" InnoDB: Rolling back trx with id %lu %lu, %lu%s rows to undo\n",
(ulong) ut_dulint_get_high(trx->id),
(ulong) ut_dulint_get_low(trx->id),
(ulong) rows_to_undo, unit);
mutex_exit(&kernel_mutex);
+ trx->mysql_thread_id = os_thread_get_curr_id();
+
+ trx->mysql_process_no = os_proc_get_number();
+
if (trx->dict_operation) {
row_mysql_lock_data_dictionary(trx);
}
@@ -456,7 +472,7 @@ loop:
fprintf(stderr,
"InnoDB: Waiting for rollback of trx id %lu to end\n",
- (ulong) ut_dulint_get_low(trx->id));
+ (ulong) ut_dulint_get_low(trx->id));
os_thread_sleep(100000);
mutex_enter(&kernel_mutex);
@@ -495,10 +511,23 @@ loop:
(ulong) ut_dulint_get_low(trx->id));
mem_heap_free(heap);
+ trx_roll_crash_recv_trx = NULL;
+
goto loop;
- os_thread_exit(i); /* not reached */
- return(i);
+leave_function:
+ /* We count the number of threads in os_thread_exit(). A created
+ thread should always use that to exit and not use return() to exit. */
+
+ os_thread_exit(NULL);
+
+ /* The following is dummy code to keep the compiler happy: */
+
+#ifndef __WIN__
+ return(NULL);
+#else
+ return(0);
+#endif
}
/***********************************************************************
@@ -859,16 +888,17 @@ try_again:
ut_ad(ut_dulint_cmp(ut_dulint_add(undo_no, 1), trx->undo_no) == 0);
/* We print rollback progress info if we are in a crash recovery
- and the transaction has at least 1000 row operations to undo */
+ and the transaction has at least 1000 row operations to undo. */
+
+ if (trx == trx_roll_crash_recv_trx && trx_roll_max_undo_no > 1000) {
- if (srv_is_being_started && trx_roll_max_undo_no > 1000) {
- progress_pct = 100 - (ulint)
+ progress_pct = 100 - (ulint)
((ut_conv_dulint_to_longlong(undo_no) * 100)
/ trx_roll_max_undo_no);
if (progress_pct != trx_roll_progress_printed_pct) {
if (trx_roll_progress_printed_pct == 0) {
fprintf(stderr,
- "\nInnoDB: Progress in percents: %lu", (ulong) progress_pct);
+"\nInnoDB: Progress in percents: %lu\n", (ulong) progress_pct);
} else {
fprintf(stderr,
" %lu", (ulong) progress_pct);
diff --git a/innobase/trx/trx0sys.c b/innobase/trx/trx0sys.c
index 35e18064329..57166e98f45 100644
--- a/innobase/trx/trx0sys.c
+++ b/innobase/trx/trx0sys.c
@@ -125,6 +125,22 @@ trx_doublewrite_init(
}
/********************************************************************
+Frees the doublewrite buffer. */
+static
+void
+trx_doublewrite_free(void)
+/*======================*/
+{
+ mutex_free(&(trx_doublewrite->mutex));
+
+ mem_free(trx_doublewrite->buf_block_arr);
+ ut_free(trx_doublewrite->write_buf_unaligned);
+
+ mem_free(trx_doublewrite);
+ trx_doublewrite = NULL;
+}
+
+/********************************************************************
Marks the trx sys header when we have successfully upgraded to the >= 4.1.x
multiple tablespace format. */
@@ -512,6 +528,9 @@ trx_sys_doublewrite_init_or_restore_pages(
fil_flush_file_spaces(FIL_TABLESPACE);
+ if (!srv_use_doublewrite_buf)
+ trx_doublewrite_free();
+
leave_func:
ut_free(unaligned_read_buf);
}