Skip to content

Commit d03adb8

Browse files
committed
Bug#28510721 TSAN: DATA RACE IN EVENT_QUEUE::LOCK_DATA
Fix data race in Event_queue::Lock_data() by making Event_queue::mutex_last_attempted_lock_at_line mutex_last_attempted_lock_in_func mutex_queue_data_attempting_lock atomic variables. The contents of these variables are printed by the SIGHUP signal handler and by COM_DEBUG if the events scheduler is active. Note that since these variables are updated separately, it is still not guaranteed that they together form a consistent state. Change-Id: Ie7719ab78eceb3a6afb0cdd2e959aaccc4a7c1b3
1 parent 34cd4f7 commit d03adb8

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

sql/event_queue.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,9 @@ void Event_queue::dump_internal_status() {
769769
printf("LUA : %s:%u\n", mutex_last_unlocked_in_func,
770770
mutex_last_unlocked_at_line);
771771
if (mutex_last_attempted_lock_at_line)
772-
printf("Last lock attempt at: %s:%u\n", mutex_last_attempted_lock_in_func,
773-
mutex_last_attempted_lock_at_line);
772+
printf("Last lock attempt at: %s:%u\n",
773+
mutex_last_attempted_lock_in_func.load(),
774+
mutex_last_attempted_lock_at_line.load());
774775
printf("WOC : %s\n", waiting_on_cond ? "YES" : "NO");
775776

776777
MYSQL_TIME time;

sql/event_queue.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#ifndef _EVENT_QUEUE_H_
22
#define _EVENT_QUEUE_H_
3-
/* Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
3+
/* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
44
55
This program is free software; you can redistribute it and/or modify
66
it under the terms of the GNU General Public License, version 2.0,
@@ -34,6 +34,7 @@
3434

3535
#include <sys/types.h>
3636
#include <time.h>
37+
#include <atomic>
3738
#include <vector>
3839

3940
#include "lex_string.h"
@@ -157,12 +158,12 @@ class Event_queue {
157158

158159
uint mutex_last_locked_at_line;
159160
uint mutex_last_unlocked_at_line;
160-
uint mutex_last_attempted_lock_at_line;
161+
std::atomic<uint> mutex_last_attempted_lock_at_line;
161162
const char *mutex_last_locked_in_func;
162163
const char *mutex_last_unlocked_in_func;
163-
const char *mutex_last_attempted_lock_in_func;
164+
std::atomic<const char *> mutex_last_attempted_lock_in_func;
164165
bool mutex_queue_data_locked;
165-
bool mutex_queue_data_attempting_lock;
166+
std::atomic<bool> mutex_queue_data_attempting_lock;
166167
bool waiting_on_cond;
167168
};
168169
/**

0 commit comments

Comments
 (0)