Skip to content

Commit 1349307

Browse files
committed
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.
1 parent 72994d6 commit 1349307

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+272
-195
lines changed

storage/innobase/buf/buf0dump.cc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All Rights Reserved.
4+
Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
45
56
This program is free software; you can redistribute it and/or modify it under
67
the terms of the GNU General Public License as published by the Free Software
@@ -52,8 +53,8 @@ enum status_severity {
5253

5354
/* Flags that tell the buffer pool dump/load thread which action should it
5455
take after being waked up. */
55-
static ibool buf_dump_should_start = FALSE;
56-
static ibool buf_load_should_start = FALSE;
56+
static volatile bool buf_dump_should_start;
57+
static volatile bool buf_load_should_start;
5758

5859
static ibool buf_load_abort_flag = FALSE;
5960

@@ -78,7 +79,7 @@ void
7879
buf_dump_start()
7980
/*============*/
8081
{
81-
buf_dump_should_start = TRUE;
82+
buf_dump_should_start = true;
8283
os_event_set(srv_buf_dump_event);
8384
}
8485

@@ -92,7 +93,7 @@ void
9293
buf_load_start()
9394
/*============*/
9495
{
95-
buf_load_should_start = TRUE;
96+
buf_load_should_start = true;
9697
os_event_set(srv_buf_dump_event);
9798
}
9899

@@ -695,15 +696,18 @@ DECLARE_THREAD(buf_dump_thread)(
695696
os_event_wait(srv_buf_dump_event);
696697

697698
if (buf_dump_should_start) {
698-
buf_dump_should_start = FALSE;
699+
buf_dump_should_start = false;
699700
buf_dump(TRUE /* quit on shutdown */);
700701
}
701702

702703
if (buf_load_should_start) {
703-
buf_load_should_start = FALSE;
704+
buf_load_should_start = false;
704705
buf_load();
705706
}
706707

708+
if (buf_dump_should_start || buf_load_should_start) {
709+
continue;
710+
}
707711
os_event_reset(srv_buf_dump_event);
708712
}
709713

storage/innobase/buf/buf0flu.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
4+
Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
45
56
This program is free software; you can redistribute it and/or modify it under
67
the terms of the GNU General Public License as published by the Free Software
@@ -732,8 +733,7 @@ buf_flush_write_complete(
732733
flush_type = buf_page_get_flush_type(bpage);
733734
buf_pool->n_flush[flush_type]--;
734735

735-
/* fprintf(stderr, "n pending flush %lu\n",
736-
buf_pool->n_flush[flush_type]); */
736+
ut_ad(buf_pool_mutex_own(buf_pool));
737737

738738
if (buf_pool->n_flush[flush_type] == 0
739739
&& buf_pool->init_flush[flush_type] == FALSE) {

storage/innobase/dict/dict0stats_bg.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved.
4+
Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
45
56
This program is free software; you can redistribute it and/or modify it under
67
the terms of the GNU General Public License as published by the Free Software
@@ -39,8 +40,9 @@ Created Apr 25, 2012 Vasil Dimov
3940

4041
#define SHUTTING_DOWN() (srv_shutdown_state != SRV_SHUTDOWN_NONE)
4142

42-
/** Event to wake up the stats thread */
43-
UNIV_INTERN os_event_t dict_stats_event = NULL;
43+
/** Event to wake up dict_stats_thread on dict_stats_recalc_pool_add()
44+
or shutdown. Not protected by any mutex. */
45+
UNIV_INTERN os_event_t dict_stats_event;
4446

4547
/** This mutex protects the "recalc_pool" variable. */
4648
static ib_mutex_t recalc_pool_mutex;

storage/innobase/include/buf0buf.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
4+
Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
45
56
This program is free software; you can redistribute it and/or modify it under
67
the terms of the GNU General Public License as published by the Free Software
@@ -1905,7 +1906,9 @@ struct buf_pool_t{
19051906
os_event_t no_flush[BUF_FLUSH_N_TYPES];
19061907
/*!< this is in the set state
19071908
when there is no flush batch
1908-
of the given type running */
1909+
of the given type running;
1910+
os_event_set() and os_event_reset()
1911+
are protected by buf_pool_t::mutex */
19091912
ib_rbt_t* flush_rbt; /*!< a red-black tree is used
19101913
exclusively during recovery to
19111914
speed up insertions in the

storage/innobase/include/buf0dblwr.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved.
4+
Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
45
56
This program is free software; you can redistribute it and/or modify it under
67
the terms of the GNU General Public License as published by the Free Software
@@ -134,11 +135,13 @@ struct buf_dblwr_t{
134135
ulint b_reserved;/*!< number of slots currently reserved
135136
for batch flush. */
136137
os_event_t b_event;/*!< event where threads wait for a
137-
batch flush to end. */
138+
batch flush to end;
139+
os_event_set() and os_event_reset()
140+
are protected by buf_dblwr_t::mutex */
138141
ulint s_reserved;/*!< number of slots currently
139142
reserved for single page flushes. */
140143
os_event_t s_event;/*!< event where threads wait for a
141-
single page flush slot. */
144+
single page flush slot. Protected by mutex. */
142145
bool* in_use; /*!< flag used to indicate if a slot is
143146
in use. Only used for single page
144147
flushes. */

storage/innobase/include/dict0stats_bg.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved.
4+
Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
45
56
This program is free software; you can redistribute it and/or modify it under
67
the terms of the GNU General Public License as published by the Free Software
@@ -32,7 +33,8 @@ Created Apr 26, 2012 Vasil Dimov
3233
#include "os0sync.h" /* os_event_t */
3334
#include "os0thread.h" /* DECLARE_THREAD */
3435

35-
/** Event to wake up the stats thread */
36+
/** Event to wake up dict_stats_thread on dict_stats_recalc_pool_add()
37+
or shutdown. Not protected by any mutex. */
3638
extern os_event_t dict_stats_event;
3739

3840
/*****************************************************************//**

storage/innobase/include/fil0fil.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
4+
Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
45
56
This program is free software; you can redistribute it and/or modify it under
67
the terms of the GNU General Public License as published by the Free Software
@@ -206,7 +207,9 @@ struct fil_node_t {
206207
ibool open; /*!< TRUE if file open */
207208
os_file_t handle; /*!< OS handle to the file, if file open */
208209
os_event_t sync_event;/*!< Condition event to group and
209-
serialize calls to fsync */
210+
serialize calls to fsync;
211+
os_event_set() and os_event_reset()
212+
are protected by fil_system_t::mutex */
210213
ibool is_raw_disk;/*!< TRUE if the 'file' is actually a raw
211214
device or a raw disk partition */
212215
ulint size; /*!< size of the file in database pages, 0 if

storage/innobase/include/fsp0types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 1995, 2009, Oracle and/or its affiliates. All Rights Reserved.
4+
Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
45
56
This program is free software; you can redistribute it and/or modify it under
67
the terms of the GNU General Public License as published by the Free Software

storage/innobase/include/fts0types.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ struct fts_sync_t {
126126
bool in_progress; /*!< flag whether sync is in progress.*/
127127
bool unlock_cache; /*!< flag whether unlock cache when
128128
write fts node */
129-
os_event_t event; /*!< sync finish event */
129+
os_event_t event; /*!< sync finish event;
130+
only os_event_set() and os_event_wait()
131+
are used */
130132
};
131133

132134
/** The cache for the FTS system. It is a memory-based inverted index

storage/innobase/include/lock0lock.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,12 @@ struct lock_sys_t{
918918
srv_slot_t* waiting_threads; /*!< Array of user threads
919919
suspended while waiting for
920920
locks within InnoDB, protected
921-
by the lock_sys->wait_mutex */
921+
by the lock_sys->wait_mutex;
922+
os_event_set() and
923+
os_event_reset() on
924+
waiting_threads[]->event
925+
are protected by
926+
trx_t::mutex */
922927
srv_slot_t* last_slot; /*!< highest slot ever used
923928
in the waiting_threads array,
924929
protected by
@@ -931,10 +936,11 @@ struct lock_sys_t{
931936

932937
ulint n_lock_max_wait_time; /*!< Max wait time */
933938

934-
os_event_t timeout_event; /*!< Set to the event that is
935-
created in the lock wait monitor
936-
thread. A value of 0 means the
937-
thread is not active */
939+
os_event_t timeout_event; /*!< An event waited for by
940+
lock_wait_timeout_thread.
941+
Not protected by a mutex,
942+
but the waits are timed.
943+
Signaled on shutdown only. */
938944

939945
bool timeout_thread_active; /*!< True if the timeout thread
940946
is running */

0 commit comments

Comments
 (0)