Bug #25167032 CRASH WHEN ASSIGNING MY_ERRNO - MISSING

		MY_THREAD_INIT IN BACKGROUND THREAD

Description:
===========
Add my_thread_init() and my_thread_exit() for background threads which
initializes and frees the st_my_thread_var structure.

Reviewed-by: Jimmy Yang<jimmy.yang@oracle.com>
RB: 15003
parent 69bbf9ef
/***************************************************************************** /*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2008, 2009 Google Inc.
Copyright (c) 2009, Percona Inc. Copyright (c) 2009, Percona Inc.
...@@ -2767,6 +2767,7 @@ srv_master_thread( ...@@ -2767,6 +2767,7 @@ srv_master_thread(
ulint i; ulint i;
ib_time_t last_print_time; ib_time_t last_print_time;
my_thread_init();
#ifdef UNIV_DEBUG_THREAD_CREATION #ifdef UNIV_DEBUG_THREAD_CREATION
fprintf(stderr, "Master thread starts, id %lu\n", fprintf(stderr, "Master thread starts, id %lu\n",
os_thread_pf(os_thread_get_curr_id())); os_thread_pf(os_thread_get_curr_id()));
...@@ -3222,6 +3223,7 @@ srv_master_thread( ...@@ -3222,6 +3223,7 @@ srv_master_thread(
os_event_wait(slot->event); os_event_wait(slot->event);
if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) { if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) {
my_thread_end();
os_thread_exit(NULL); os_thread_exit(NULL);
} }
...@@ -3245,6 +3247,7 @@ srv_purge_thread( ...@@ -3245,6 +3247,7 @@ srv_purge_thread(
ulint retries = 0; ulint retries = 0;
ulint n_total_purged = ULINT_UNDEFINED; ulint n_total_purged = ULINT_UNDEFINED;
my_thread_init();
ut_a(srv_n_purge_threads == 1); ut_a(srv_n_purge_threads == 1);
#ifdef UNIV_PFS_THREAD #ifdef UNIV_PFS_THREAD
...@@ -3329,6 +3332,8 @@ srv_purge_thread( ...@@ -3329,6 +3332,8 @@ srv_purge_thread(
os_thread_pf(os_thread_get_curr_id())); os_thread_pf(os_thread_get_curr_id()));
#endif /* UNIV_DEBUG_THREAD_CREATION */ #endif /* UNIV_DEBUG_THREAD_CREATION */
my_thread_end();
/* We count the number of threads in os_thread_exit(). A created /* We count the number of threads in os_thread_exit(). A created
thread should always use that to exit and not use return() to exit. */ thread should always use that to exit and not use return() to exit. */
os_thread_exit(NULL); os_thread_exit(NULL);
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved. Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
Copyright (c) 2017, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -610,12 +611,15 @@ trx_rollback_or_clean_all_recovered( ...@@ -610,12 +611,15 @@ trx_rollback_or_clean_all_recovered(
/*!< in: a dummy parameter required by /*!< in: a dummy parameter required by
os_thread_create */ os_thread_create */
{ {
my_thread_init();
#ifdef UNIV_PFS_THREAD #ifdef UNIV_PFS_THREAD
pfs_register_thread(trx_rollback_clean_thread_key); pfs_register_thread(trx_rollback_clean_thread_key);
#endif /* UNIV_PFS_THREAD */ #endif /* UNIV_PFS_THREAD */
trx_rollback_or_clean_recovered(TRUE); trx_rollback_or_clean_recovered(TRUE);
my_thread_end();
/* We count the number of threads in os_thread_exit(). A created /* We count the number of threads in os_thread_exit(). A created
thread should always use that to exit and not use return() to exit. */ thread should always use that to exit and not use return() to exit. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment