Commit 73efafc2 authored by marko's avatar marko

branches/zip: recv_no_log_write: New debug flag for tracking down

Mantis Issue #347.  No modifications should be made to the database
while recv_apply_hashed_log_recs() is about to complete.
parent a5877b47
...@@ -433,6 +433,11 @@ are allowed yet: the variable name is misleading. */ ...@@ -433,6 +433,11 @@ are allowed yet: the variable name is misleading. */
extern ibool recv_no_ibuf_operations; extern ibool recv_no_ibuf_operations;
/** TRUE when recv_init_crash_recovery() has been called. */ /** TRUE when recv_init_crash_recovery() has been called. */
extern ibool recv_needed_recovery; extern ibool recv_needed_recovery;
#ifdef UNIV_DEBUG
/** TRUE if writing to the redo log (mtr_commit) is forbidden.
Protected by log_sys->mutex. */
extern ibool recv_no_log_write;
#endif /* UNIV_DEBUG */
/** TRUE if buf_page_is_corrupted() should check if the log sequence /** TRUE if buf_page_is_corrupted() should check if the log sequence
number (FIL_PAGE_LSN) is in the future. Initially FALSE, and set by number (FIL_PAGE_LSN) is in the future. Initially FALSE, and set by
......
...@@ -241,6 +241,7 @@ log_reserve_and_open( ...@@ -241,6 +241,7 @@ log_reserve_and_open(
ut_a(len < log->buf_size / 2); ut_a(len < log->buf_size / 2);
loop: loop:
mutex_enter(&(log->mutex)); mutex_enter(&(log->mutex));
ut_ad(!recv_no_log_write);
/* Calculate an upper limit for the space the string may take in the /* Calculate an upper limit for the space the string may take in the
log buffer */ log buffer */
...@@ -309,6 +310,7 @@ log_write_low( ...@@ -309,6 +310,7 @@ log_write_low(
ut_ad(mutex_own(&(log->mutex))); ut_ad(mutex_own(&(log->mutex)));
part_loop: part_loop:
ut_ad(!recv_no_log_write);
/* Calculate a part length */ /* Calculate a part length */
data_len = (log->buf_free % OS_FILE_LOG_BLOCK_SIZE) + str_len; data_len = (log->buf_free % OS_FILE_LOG_BLOCK_SIZE) + str_len;
...@@ -377,6 +379,7 @@ log_close(void) ...@@ -377,6 +379,7 @@ log_close(void)
ib_uint64_t checkpoint_age; ib_uint64_t checkpoint_age;
ut_ad(mutex_own(&(log->mutex))); ut_ad(mutex_own(&(log->mutex)));
ut_ad(!recv_no_log_write);
lsn = log->lsn; lsn = log->lsn;
...@@ -668,8 +671,6 @@ log_calc_max_ages(void) ...@@ -668,8 +671,6 @@ log_calc_max_ages(void)
ulint archive_margin; ulint archive_margin;
ulint smallest_archive_margin; ulint smallest_archive_margin;
ut_ad(!mutex_own(&(log_sys->mutex)));
mutex_enter(&(log_sys->mutex)); mutex_enter(&(log_sys->mutex));
group = UT_LIST_GET_FIRST(log_sys->log_groups); group = UT_LIST_GET_FIRST(log_sys->log_groups);
...@@ -1117,6 +1118,7 @@ log_io_complete( ...@@ -1117,6 +1118,7 @@ log_io_complete(
} }
mutex_enter(&(log_sys->mutex)); mutex_enter(&(log_sys->mutex));
ut_ad(!recv_no_log_write);
ut_a(group->n_pending_writes > 0); ut_a(group->n_pending_writes > 0);
ut_a(log_sys->n_pending_writes > 0); ut_a(log_sys->n_pending_writes > 0);
...@@ -1148,6 +1150,7 @@ log_group_file_header_flush( ...@@ -1148,6 +1150,7 @@ log_group_file_header_flush(
ulint dest_offset; ulint dest_offset;
ut_ad(mutex_own(&(log_sys->mutex))); ut_ad(mutex_own(&(log_sys->mutex)));
ut_ad(!recv_no_log_write);
ut_a(nth_file < group->n_files); ut_a(nth_file < group->n_files);
buf = *(group->file_header_bufs + nth_file); buf = *(group->file_header_bufs + nth_file);
...@@ -1219,6 +1222,7 @@ log_group_write_buf( ...@@ -1219,6 +1222,7 @@ log_group_write_buf(
ulint i; ulint i;
ut_ad(mutex_own(&(log_sys->mutex))); ut_ad(mutex_own(&(log_sys->mutex)));
ut_ad(!recv_no_log_write);
ut_a(len % OS_FILE_LOG_BLOCK_SIZE == 0); ut_a(len % OS_FILE_LOG_BLOCK_SIZE == 0);
ut_a(((ulint) start_lsn) % OS_FILE_LOG_BLOCK_SIZE == 0); ut_a(((ulint) start_lsn) % OS_FILE_LOG_BLOCK_SIZE == 0);
...@@ -1361,6 +1365,7 @@ log_write_up_to( ...@@ -1361,6 +1365,7 @@ log_write_up_to(
#endif #endif
mutex_enter(&(log_sys->mutex)); mutex_enter(&(log_sys->mutex));
ut_ad(!recv_no_log_write);
if (flush_to_disk if (flush_to_disk
&& log_sys->flushed_to_disk_lsn >= lsn) { && log_sys->flushed_to_disk_lsn >= lsn) {
...@@ -1974,6 +1979,7 @@ log_checkpoint( ...@@ -1974,6 +1979,7 @@ log_checkpoint(
mutex_enter(&(log_sys->mutex)); mutex_enter(&(log_sys->mutex));
ut_ad(!recv_no_log_write);
oldest_lsn = log_buf_pool_get_oldest_modification(); oldest_lsn = log_buf_pool_get_oldest_modification();
mutex_exit(&(log_sys->mutex)); mutex_exit(&(log_sys->mutex));
...@@ -2086,6 +2092,7 @@ log_checkpoint_margin(void) ...@@ -2086,6 +2092,7 @@ log_checkpoint_margin(void)
do_checkpoint = FALSE; do_checkpoint = FALSE;
mutex_enter(&(log->mutex)); mutex_enter(&(log->mutex));
ut_ad(!recv_no_log_write);
if (log->check_flush_or_checkpoint == FALSE) { if (log->check_flush_or_checkpoint == FALSE) {
mutex_exit(&(log->mutex)); mutex_exit(&(log->mutex));
...@@ -3035,6 +3042,7 @@ log_check_margins(void) ...@@ -3035,6 +3042,7 @@ log_check_margins(void)
#endif /* UNIV_LOG_ARCHIVE */ #endif /* UNIV_LOG_ARCHIVE */
mutex_enter(&(log_sys->mutex)); mutex_enter(&(log_sys->mutex));
ut_ad(!recv_no_log_write);
if (log_sys->check_flush_or_checkpoint) { if (log_sys->check_flush_or_checkpoint) {
......
...@@ -78,6 +78,11 @@ UNIV_INTERN ibool recv_recovery_from_backup_on = FALSE; ...@@ -78,6 +78,11 @@ UNIV_INTERN ibool recv_recovery_from_backup_on = FALSE;
#ifndef UNIV_HOTBACKUP #ifndef UNIV_HOTBACKUP
/** TRUE when recv_init_crash_recovery() has been called. */ /** TRUE when recv_init_crash_recovery() has been called. */
UNIV_INTERN ibool recv_needed_recovery = FALSE; UNIV_INTERN ibool recv_needed_recovery = FALSE;
# ifdef UNIV_DEBUG
/** TRUE if writing to the redo log (mtr_commit) is forbidden.
Protected by log_sys->mutex. */
UNIV_INTERN ibool recv_no_log_write = FALSE;
# endif /* UNIV_DEBUG */
/** TRUE if buf_page_is_corrupted() should check if the log sequence /** TRUE if buf_page_is_corrupted() should check if the log sequence
number (FIL_PAGE_LSN) is in the future. Initially FALSE, and set by number (FIL_PAGE_LSN) is in the future. Initially FALSE, and set by
...@@ -1705,6 +1710,7 @@ recv_apply_hashed_log_recs( ...@@ -1705,6 +1710,7 @@ recv_apply_hashed_log_recs(
/* Flush all the file pages to disk and invalidate them in /* Flush all the file pages to disk and invalidate them in
the buffer pool */ the buffer pool */
ut_d(recv_no_log_write = TRUE);
mutex_exit(&(recv_sys->mutex)); mutex_exit(&(recv_sys->mutex));
mutex_exit(&(log_sys->mutex)); mutex_exit(&(log_sys->mutex));
...@@ -1718,6 +1724,7 @@ recv_apply_hashed_log_recs( ...@@ -1718,6 +1724,7 @@ recv_apply_hashed_log_recs(
mutex_enter(&(log_sys->mutex)); mutex_enter(&(log_sys->mutex));
mutex_enter(&(recv_sys->mutex)); mutex_enter(&(recv_sys->mutex));
ut_d(recv_no_log_write = FALSE);
recv_no_ibuf_operations = FALSE; recv_no_ibuf_operations = FALSE;
} }
......
...@@ -35,6 +35,7 @@ Created 11/26/1995 Heikki Tuuri ...@@ -35,6 +35,7 @@ Created 11/26/1995 Heikki Tuuri
#include "log0log.h" #include "log0log.h"
#ifndef UNIV_HOTBACKUP #ifndef UNIV_HOTBACKUP
# include "log0recv.h"
/*****************************************************************//** /*****************************************************************//**
Releases the item in the slot given. */ Releases the item in the slot given. */
UNIV_INLINE UNIV_INLINE
...@@ -181,6 +182,8 @@ mtr_commit( ...@@ -181,6 +182,8 @@ mtr_commit(
ut_d(mtr->state = MTR_COMMITTING); ut_d(mtr->state = MTR_COMMITTING);
#ifndef UNIV_HOTBACKUP #ifndef UNIV_HOTBACKUP
/* This is a dirty read, for debugging. */
ut_ad(!recv_no_log_write);
write_log = mtr->modifications && mtr->n_log_recs; write_log = mtr->modifications && mtr->n_log_recs;
if (write_log) { if (write_log) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment