Merge pull request #2846 from sysown/v2.1.0-2834

Fixes #2834: Segfault due to invalid access to threads during startup / shutdown
pull/2869/head
René Cannaò 6 years ago committed by GitHub
commit ac4585be5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -505,6 +505,7 @@ class MySQL_Threads_Handler
} variables;
struct {
unsigned int mirror_sessions_current;
int threads_initialized = 0;
/// Prometheus metrics arrays
std::array<prometheus::Counter*, p_th_counter::__size> p_counter_array {};
std::array<prometheus::Gauge*, p_th_gauge::__size> p_gauge_array {};

@ -5747,6 +5747,7 @@ __exit_kill_session:
}
unsigned long long MySQL_Threads_Handler::get_total_mirror_queue() {
if ((__sync_fetch_and_add(&status_variables.threads_initialized, 0) == 0) || this->shutdown_) return 0;
unsigned long long q=0;
unsigned int i;
for (i=0;i<num_threads;i++) {
@ -5763,6 +5764,7 @@ unsigned long long MySQL_Threads_Handler::get_total_mirror_queue() {
unsigned long long MySQL_Threads_Handler::get_status_variable(enum MySQL_Thread_status_variable v_idx, p_th_counter::metric m_idx) {
if ((__sync_fetch_and_add(&status_variables.threads_initialized, 0) == 0) || this->shutdown_) return 0;
unsigned long long q=0;
unsigned int i;
for (i=0;i<num_threads;i++) {
@ -5781,6 +5783,7 @@ unsigned long long MySQL_Threads_Handler::get_status_variable(enum MySQL_Thread_
}
unsigned int MySQL_Threads_Handler::get_active_transations() {
if ((__sync_fetch_and_add(&status_variables.threads_initialized, 0) == 0) || this->shutdown_) return 0;
unsigned long long q=0;
unsigned int i;
for (i=0;i<num_threads;i++) {
@ -5797,6 +5800,7 @@ unsigned int MySQL_Threads_Handler::get_active_transations() {
#ifdef IDLE_THREADS
unsigned int MySQL_Threads_Handler::get_non_idle_client_connections() {
if ((__sync_fetch_and_add(&status_variables.threads_initialized, 0) == 0) || this->shutdown_) return 0;
unsigned long long q=0;
unsigned int i;
for (i=0;i<num_threads;i++) {
@ -5813,6 +5817,7 @@ unsigned int MySQL_Threads_Handler::get_non_idle_client_connections() {
#endif // IDLE_THREADS
unsigned long long MySQL_Threads_Handler::get_mysql_backend_buffers_bytes() {
if ((__sync_fetch_and_add(&status_variables.threads_initialized, 0) == 0) || this->shutdown_) return 0;
unsigned long long q=0;
unsigned int i;
for (i=0;i<num_threads;i++) {
@ -5829,6 +5834,7 @@ unsigned long long MySQL_Threads_Handler::get_mysql_backend_buffers_bytes() {
}
unsigned long long MySQL_Threads_Handler::get_mysql_frontend_buffers_bytes() {
if ((__sync_fetch_and_add(&status_variables.threads_initialized, 0) == 0) || this->shutdown_) return 0;
unsigned long long q=0;
unsigned int i;
for (i=0;i<num_threads;i++) {
@ -5854,6 +5860,7 @@ unsigned long long MySQL_Threads_Handler::get_mysql_frontend_buffers_bytes() {
}
unsigned long long MySQL_Threads_Handler::get_mysql_session_internal_bytes() {
if ((__sync_fetch_and_add(&status_variables.threads_initialized, 0) == 0) || this->shutdown_) return 0;
unsigned long long q=0;
unsigned int i;
for (i=0;i<num_threads;i++) {

@ -1372,6 +1372,7 @@ void ProxySQL_Main_init_phase3___start_all() {
do { /* nothing */ } while (load_ != 1);
load_ = 0;
__sync_fetch_and_add(&GloMTH->status_variables.threads_initialized, 1);
{
cpu_timer t;

Loading…
Cancel
Save