Skip to content

Commit 2db724c

Browse files
committed
MDEV-10218 - rpl.rpl_binlog_errors fails in buildbot with valgrind warnings -
bytes are possibly lost Timer thread of threadpool is created "joinable", but they're not "joined" on completion. This causes memory leaks around thread local storage. Fixed by joining timer thread.
1 parent 3c77a00 commit 2db724c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

sql/threadpool_unix.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ struct pool_timer_t
166166
volatile uint64 next_timeout_check;
167167
int tick_interval;
168168
bool shutdown;
169+
pthread_t timer_thread_id;
169170
};
170171

171172
static pool_timer_t pool_timer;
@@ -603,12 +604,12 @@ void check_stall(thread_group_t *thread_group)
603604

604605
static void start_timer(pool_timer_t* timer)
605606
{
606-
pthread_t thread_id;
607607
DBUG_ENTER("start_timer");
608608
mysql_mutex_init(key_timer_mutex,&timer->mutex, NULL);
609609
mysql_cond_init(key_timer_cond, &timer->cond, NULL);
610610
timer->shutdown = false;
611-
mysql_thread_create(key_timer_thread,&thread_id, NULL, timer_thread, timer);
611+
mysql_thread_create(key_timer_thread, &timer->timer_thread_id, NULL,
612+
timer_thread, timer);
612613
DBUG_VOID_RETURN;
613614
}
614615

@@ -620,6 +621,7 @@ static void stop_timer(pool_timer_t *timer)
620621
timer->shutdown = true;
621622
mysql_cond_signal(&timer->cond);
622623
mysql_mutex_unlock(&timer->mutex);
624+
pthread_join(timer->timer_thread_id, NULL);
623625
DBUG_VOID_RETURN;
624626
}
625627

0 commit comments

Comments
 (0)