diff options
author | unknown <gbichot@quadita2.mysql.com> | 2005-03-09 00:32:58 +0100 |
---|---|---|
committer | unknown <gbichot@quadita2.mysql.com> | 2005-03-09 00:32:58 +0100 |
commit | b0e1389b82e1f05de98e436377e08c3c6ff9eed2 (patch) | |
tree | 2f2a2dd0468b4a571930cb61c93081197e333f87 /innobase | |
parent | 50985b6783d544c6eeae9066fd6e2e1526547412 (diff) | |
download | mariadb-git-b0e1389b82e1f05de98e436377e08c3c6ff9eed2.tar.gz |
This code change has 0 effects as it's about the case where innobase_very_fast_shutdown!=0,
which is always false. In a very fast InnoDB shutdown, we just ensure that
no more transactions are running, flush InnoDB log, signal InnoDB threads to die,
and then return from InnoDB (from innobase_end()) without waiting for those threads
to actually die. I have tested on a 4CPU machine that even with --innodb_flush_log_at_trx_commit=0,
this optimized InnoDB very fast shutdown loses no committed transactions. Patch pre-approved by Heikki.
innobase/log/log0log.c:
In an InnoDB very fast shutdown, we just need to wait for no more transactions to be happening
and then we can flush the InnoDB log and don't need to wait for the
signaled-to-die InnoDB threads to finish (saves seconds).
innobase/srv/srv0start.c:
In an InnoDB very fast shutdown, once we have forced a flush of the InnoDB
log to disk, and signalled InnoDB threads to die, we needn't wait
for these threads to die.
Diffstat (limited to 'innobase')
-rw-r--r-- | innobase/log/log0log.c | 49 | ||||
-rw-r--r-- | innobase/srv/srv0start.c | 7 |
2 files changed, 32 insertions, 24 deletions
diff --git a/innobase/log/log0log.c b/innobase/log/log0log.c index 5915146b466..e8a720e8a88 100644 --- a/innobase/log/log0log.c +++ b/innobase/log/log0log.c @@ -3047,7 +3047,10 @@ loop: mutex_enter(&kernel_mutex); - /* Check that there are no longer transactions */ + /* Check that there are no longer transactions. We need this wait even + for the 'very fast' shutdown, because the InnoDB layer may have + committed or prepared transactions and we don't want to lose them. */ + if (trx_n_mysql_transactions > 0 || UT_LIST_GET_LEN(trx_sys->trx_list) > 0) { @@ -3056,6 +3059,23 @@ loop: goto loop; } + if (srv_very_fast_shutdown) { + /* In a 'very fast' shutdown we do not flush the buffer pool: + it is essentially a 'crash' of the InnoDB server. + Make sure that the log is all flushed to disk, so that + we can recover all committed transactions in a crash + recovery. + In a 'very fast' shutdown we do not flush the buffer pool: + it is essentially a 'crash' of the InnoDB server. Then we must + not write the lsn stamps to the data files, since at a + startup InnoDB deduces from the stamps if the previous + shutdown was clean. */ + + log_buffer_flush_to_disk(); + return; /* We SKIP ALL THE REST !! */ + } + + /* Check that the master thread is suspended */ if (srv_n_threads_active[SRV_MASTER] != 0) { @@ -3092,24 +3112,13 @@ loop: log_archive_all(); #endif /* UNIV_LOG_ARCHIVE */ - if (!srv_very_fast_shutdown) { - /* In a 'very fast' shutdown we do not flush the buffer pool: - it is essentially a 'crash' of the InnoDB server. */ - log_make_checkpoint_at(ut_dulint_max, TRUE); - } else { - /* Make sure that the log is all flushed to disk, so that - we can recover all committed transactions in a crash - recovery */ - log_buffer_flush_to_disk(); - } mutex_enter(&(log_sys->mutex)); lsn = log_sys->lsn; - if ((ut_dulint_cmp(lsn, log_sys->last_checkpoint_lsn) != 0 - && !srv_very_fast_shutdown) + if ((ut_dulint_cmp(lsn, log_sys->last_checkpoint_lsn) != 0) #ifdef UNIV_LOG_ARCHIVE || (srv_log_archive_on && ut_dulint_cmp(lsn, @@ -3158,7 +3167,7 @@ loop: completely flushed to disk! (We do not call fil_write... if the 'very fast' shutdown is enabled.) */ - if (!srv_very_fast_shutdown && !buf_all_freed()) { + if (!buf_all_freed()) { goto loop; } @@ -3181,7 +3190,7 @@ loop: /* Make some checks that the server really is quiet */ ut_a(srv_n_threads_active[SRV_MASTER] == 0); - ut_a(srv_very_fast_shutdown || buf_all_freed()); + ut_a(buf_all_freed()); ut_a(0 == ut_dulint_cmp(lsn, log_sys->lsn)); if (ut_dulint_cmp(lsn, srv_start_lsn) < 0) { @@ -3196,15 +3205,7 @@ loop: srv_shutdown_lsn = lsn; - if (!srv_very_fast_shutdown) { - /* In a 'very fast' shutdown we do not flush the buffer pool: - it is essentially a 'crash' of the InnoDB server. Then we must - not write the lsn stamps to the data files, since at a - startup InnoDB deduces from the stamps if the previous - shutdown was clean. */ - fil_write_flushed_lsn_to_data_files(lsn, arch_log_no); - } fil_flush_file_spaces(FIL_TABLESPACE); @@ -3212,7 +3213,7 @@ loop: /* Make some checks that the server really is quiet */ ut_a(srv_n_threads_active[SRV_MASTER] == 0); - ut_a(srv_very_fast_shutdown || buf_all_freed()); + ut_a(buf_all_freed()); ut_a(0 == ut_dulint_cmp(lsn, log_sys->lsn)); } diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c index 210739b26fd..c65b7d3e141 100644 --- a/innobase/srv/srv0start.c +++ b/innobase/srv/srv0start.c @@ -1740,6 +1740,13 @@ innobase_shutdown_for_mysql(void) srv_shutdown_state = SRV_SHUTDOWN_EXIT_THREADS; + /* In a 'very fast' shutdown, we do not need to wait for these threads + to die; all which counts is that we flushed the log; a 'very fast' + shutdown is essentially a crash. */ + + if (srv_fast_shutdown) + return((int) DB_SUCCESS); + /* All threads end up waiting for certain events. Put those events to the signaled state. Then the threads will exit themselves in os_thread_event_wait(). */ |