summaryrefslogtreecommitdiff
path: root/storage/innobase/trx
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2017-02-16 19:40:03 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2017-02-20 12:20:52 +0200
commit13493078e9aea37f6714b3921921aa10864c8b30 (patch)
tree904582d100122e966de83891ce372908d128294d /storage/innobase/trx
parent72994d6442ec6156ccfefb260771537a8b6d80b9 (diff)
downloadmariadb-git-13493078e9aea37f6714b3921921aa10864c8b30.tar.gz
MDEV-11802 innodb.innodb_bug14676111 fails
The function trx_purge_stop() was calling os_event_reset(purge_sys->event) before calling rw_lock_x_lock(&purge_sys->latch). The os_event_set() call in srv_purge_coordinator_suspend() is protected by that X-latch. It would seem a good idea to consistently protect both os_event_set() and os_event_reset() calls with a common mutex or rw-lock in those cases where os_event_set() and os_event_reset() are used like condition variables, tied to changes of shared state. For each os_event_t, we try to document the mutex or rw-lock that is being used. For some events, frequent calls to os_event_set() seem to try to avoid hangs. Some events are never waited for infinitely, only timed waits, and os_event_set() is used for early termination of these waits. os_aio_simulated_put_read_threads_to_sleep(): Define as a null macro on other systems than Windows. TODO: remove this altogether and disable innodb_use_native_aio on Windows. os_aio_segment_wait_events[]: Initialize only if innodb_use_native_aio=0.
Diffstat (limited to 'storage/innobase/trx')
-rw-r--r--storage/innobase/trx/trx0purge.cc42
1 files changed, 14 insertions, 28 deletions
diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc
index efc600d16b1..f24c8f22277 100644
--- a/storage/innobase/trx/trx0purge.cc
+++ b/storage/innobase/trx/trx0purge.cc
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -171,10 +172,6 @@ trx_purge_sys_close(void)
sess_close(purge_sys->sess);
- purge_sys->sess = NULL;
-
- purge_sys->view = NULL;
-
rw_lock_free(&purge_sys->latch);
mutex_free(&purge_sys->bh_mutex);
@@ -183,9 +180,6 @@ trx_purge_sys_close(void)
ib_bh_free(purge_sys->ib_bh);
os_event_free(purge_sys->event);
-
- purge_sys->event = NULL;
-
mem_free(purge_sys);
purge_sys = NULL;
@@ -1301,20 +1295,16 @@ void
trx_purge_stop(void)
/*================*/
{
- purge_state_t state;
- ib_int64_t sig_count = os_event_reset(purge_sys->event);
-
ut_a(srv_n_purge_threads > 0);
rw_lock_x_lock(&purge_sys->latch);
- ut_a(purge_sys->state != PURGE_STATE_INIT);
- ut_a(purge_sys->state != PURGE_STATE_EXIT);
- ut_a(purge_sys->state != PURGE_STATE_DISABLED);
+ const ib_int64_t sig_count = os_event_reset(purge_sys->event);
+ const purge_state_t state = purge_sys->state;
- ++purge_sys->n_stop;
+ ut_a(state == PURGE_STATE_RUN || state == PURGE_STATE_STOP);
- state = purge_sys->state;
+ ++purge_sys->n_stop;
if (state == PURGE_STATE_RUN) {
ib_logf(IB_LOG_LEVEL_INFO, "Stopping purge");
@@ -1327,33 +1317,29 @@ trx_purge_stop(void)
purge_sys->state = PURGE_STATE_STOP;
- rw_lock_x_unlock(&purge_sys->latch);
-
if (state != PURGE_STATE_STOP) {
-
+ rw_lock_x_unlock(&purge_sys->latch);
/* Wait for purge coordinator to signal that it
is suspended. */
os_event_wait_low(purge_sys->event, sig_count);
- } else {
- bool once = true;
-
- rw_lock_x_lock(&purge_sys->latch);
+ } else {
+ bool once = true;
- /* Wait for purge to signal that it has actually stopped. */
- while (purge_sys->running) {
+ /* Wait for purge to signal that it has actually stopped. */
+ while (purge_sys->running) {
- if (once) {
+ if (once) {
ib_logf(IB_LOG_LEVEL_INFO,
"Waiting for purge to stop");
- once = false;
+ once = false;
}
rw_lock_x_unlock(&purge_sys->latch);
- os_thread_sleep(10000);
+ os_thread_sleep(10000);
rw_lock_x_lock(&purge_sys->latch);
- }
+ }
rw_lock_x_unlock(&purge_sys->latch);
}