Skip to content

Commit fd2c5d1

Browse files
kevgssvoj
authored andcommitted
fix a data race
reapply 6192f0b TSAN warnings count decreased from 206 to 195
1 parent a02b81d commit fd2c5d1

File tree

1 file changed

+2
-41
lines changed

1 file changed

+2
-41
lines changed

storage/innobase/sync/sync0debug.cc

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,7 @@ my_bool srv_sync_debug;
4949
/** The global mutex which protects debug info lists of all rw-locks.
5050
To modify the debug info list of an rw-lock, this mutex has to be
5151
acquired in addition to the mutex protecting the lock. */
52-
static ib_mutex_t rw_lock_debug_mutex;
53-
54-
/** If deadlock detection does not get immediately the mutex,
55-
it may wait for this event */
56-
static os_event_t rw_lock_debug_event;
57-
58-
/** This is set to true, if there may be waiters for the event */
59-
static bool rw_lock_debug_waiters;
52+
static SysMutex rw_lock_debug_mutex;
6053

6154
/** The latch held by a thread */
6255
struct Latched {
@@ -1242,13 +1235,7 @@ void
12421235
LatchDebug::init()
12431236
UNIV_NOTHROW
12441237
{
1245-
ut_a(rw_lock_debug_event == NULL);
1246-
12471238
mutex_create(LATCH_ID_RW_LOCK_DEBUG, &rw_lock_debug_mutex);
1248-
1249-
rw_lock_debug_event = os_event_create("rw_lock_debug_event");
1250-
1251-
rw_lock_debug_waiters = FALSE;
12521239
}
12531240

12541241
/** Shutdown the latch debug checking
@@ -1259,12 +1246,6 @@ void
12591246
LatchDebug::shutdown()
12601247
UNIV_NOTHROW
12611248
{
1262-
ut_a(rw_lock_debug_event != NULL);
1263-
1264-
os_event_destroy(rw_lock_debug_event);
1265-
1266-
rw_lock_debug_event = NULL;
1267-
12681249
mutex_free(&rw_lock_debug_mutex);
12691250

12701251
ut_a(s_initialized);
@@ -1284,34 +1265,14 @@ mutex. */
12841265
void
12851266
rw_lock_debug_mutex_enter()
12861267
{
1287-
for (;;) {
1288-
1289-
if (0 == mutex_enter_nowait(&rw_lock_debug_mutex)) {
1290-
return;
1291-
}
1292-
1293-
os_event_reset(rw_lock_debug_event);
1294-
1295-
rw_lock_debug_waiters = TRUE;
1296-
1297-
if (0 == mutex_enter_nowait(&rw_lock_debug_mutex)) {
1298-
return;
1299-
}
1300-
1301-
os_event_wait(rw_lock_debug_event);
1302-
}
1268+
mutex_enter(&rw_lock_debug_mutex);
13031269
}
13041270

13051271
/** Releases the debug mutex. */
13061272
void
13071273
rw_lock_debug_mutex_exit()
13081274
{
13091275
mutex_exit(&rw_lock_debug_mutex);
1310-
1311-
if (rw_lock_debug_waiters) {
1312-
rw_lock_debug_waiters = FALSE;
1313-
os_event_set(rw_lock_debug_event);
1314-
}
13151276
}
13161277
#endif /* UNIV_DEBUG */
13171278

0 commit comments

Comments
 (0)