MDEV-9088 Server crashes on shutdown after the second post of feedback report

On shutdown feedback was sending a short report without creating
a THD. At that point current_thd was pointing to the already
destroyed THD from the previous full report.

backport from 10.1:
  commit bfe703a
  Author: Sergei Golubchik <serg@mariadb.org>
  Date:   Tue Feb 3 18:19:56 2015 +0100

      don't let current_thd to point to a destroyed THD
This commit is contained in:
Sergei Golubchik 2015-12-18 09:50:39 +01:00
parent 3b9423fda2
commit 865548fc8d
12 changed files with 1 additions and 55 deletions

View file

@ -907,10 +907,7 @@ end:
if (res)
deinit();
if (!had_thd)
{
delete thd;
set_current_thd(0);
}
DBUG_RETURN(res);
}

View file

@ -6334,7 +6334,6 @@ void handle_connections_sockets()
(void) mysql_socket_close(new_sock);
}
delete thd;
set_current_thd(0);
statistic_increment(connection_errors_internal, &LOCK_status);
continue;
}
@ -6449,7 +6448,6 @@ pthread_handler_t handle_connections_namedpipes(void *arg)
{
close_connection(thd, ER_OUT_OF_RESOURCES);
delete thd;
set_current_thd(0);
continue;
}
/* Host is unknown */

View file

@ -959,8 +959,6 @@ my_bool acl_init(bool dont_read_acl_tables)
*/
return_val= acl_reload(thd);
delete thd;
/* Remember that we don't have a THD */
set_current_thd(0);
DBUG_RETURN(return_val);
}
@ -6371,8 +6369,6 @@ my_bool grant_init()
thd->store_globals();
return_val= grant_reload(thd);
delete thd;
/* Remember that we don't have a THD */
set_current_thd(0);
DBUG_RETURN(return_val);
}

View file

@ -9045,7 +9045,6 @@ my_bool mysql_rm_tmp_tables(void)
my_dirend(dirp);
}
delete thd;
set_current_thd(0);
DBUG_RETURN(0);
}

View file

@ -1645,7 +1645,7 @@ THD::~THD()
DBUG_ASSERT(status_var.memory_used == 0); // Ensure everything is freed
}
set_current_thd(orig_thd);
set_current_thd(orig_thd == this ? 0 : orig_thd);
DBUG_VOID_RETURN;
}

View file

@ -1791,9 +1791,7 @@ static void plugin_load(MEM_ROOT *tmp_root)
table->m_needs_reopen= TRUE; // Force close to free memory
close_mysql_tables(new_thd);
end:
/* Remember that we don't have a THD */
delete new_thd;
set_current_thd(0);
DBUG_VOID_RETURN;
}

View file

@ -98,8 +98,6 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options,
if (tmp_thd)
{
delete tmp_thd;
/* Remember that we don't have a THD */
set_current_thd(0);
thd= 0;
}
reset_mqh((LEX_USER *)NULL, TRUE);

View file

@ -177,8 +177,6 @@ bool servers_init(bool dont_read_servers_table)
*/
return_val= servers_reload(thd);
delete thd;
/* Remember that we don't have a THD */
set_current_thd(0);
end:
DBUG_RETURN(return_val);

View file

@ -1674,8 +1674,6 @@ void execute_ddl_log_recovery()
mysql_mutex_unlock(&LOCK_gdl);
thd->reset_query();
delete thd;
/* Remember that we don't have a THD */
set_current_thd(0);
DBUG_VOID_RETURN;
}

View file

@ -258,8 +258,6 @@ void udf_init()
end:
close_mysql_tables(new_thd);
delete new_thd;
/* Remember that we don't have a THD */
set_current_thd(0);
DBUG_VOID_RETURN;
}

View file

@ -1803,11 +1803,7 @@ end:
if (org_thd)
org_thd->store_globals(); /* purecov: inspected */
else
{
/* Remember that we don't have a THD */
set_current_thd(0);
my_pthread_setspecific_ptr(THR_MALLOC, 0);
}
default_tz= default_tz_name ? global_system_variables.time_zone
: my_tz_SYSTEM;

View file

@ -2280,9 +2280,6 @@ void *spider_bg_conn_action(
if (!(trx = spider_get_trx(thd, FALSE, &error_num)))
{
delete thd;
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
set_current_thd(NULL);
#endif
pthread_mutex_lock(&conn->bg_conn_sync_mutex);
pthread_cond_signal(&conn->bg_conn_sync_cond);
pthread_mutex_unlock(&conn->bg_conn_sync_mutex);
@ -2346,9 +2343,6 @@ void *spider_bg_conn_action(
spider_free_trx(trx, TRUE);
/* lex_end(thd->lex); */
delete thd;
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
set_current_thd(NULL);
#endif
pthread_mutex_lock(&conn->bg_conn_sync_mutex);
pthread_cond_signal(&conn->bg_conn_sync_cond);
pthread_mutex_unlock(&conn->bg_conn_mutex);
@ -2799,9 +2793,6 @@ void *spider_bg_sts_action(
if (!(trx = spider_get_trx(thd, FALSE, &error_num)))
{
delete thd;
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
set_current_thd(NULL);
#endif
share->bg_sts_thd_wait = FALSE;
share->bg_sts_kill = FALSE;
share->bg_sts_init = FALSE;
@ -2867,9 +2858,6 @@ void *spider_bg_sts_action(
}
spider_free_trx(trx, TRUE);
delete thd;
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
set_current_thd(NULL);
#endif
share->bg_sts_thd_wait = FALSE;
share->bg_sts_kill = FALSE;
share->bg_sts_init = FALSE;
@ -2903,9 +2891,6 @@ void *spider_bg_sts_action(
}
spider_free_trx(trx, TRUE);
delete thd;
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
set_current_thd(NULL);
#endif
pthread_cond_signal(&share->bg_sts_sync_cond);
pthread_mutex_unlock(&share->sts_mutex);
#if !defined(MYSQL_DYNAMIC_PLUGIN) || !defined(_WIN32)
@ -3190,9 +3175,6 @@ void *spider_bg_crd_action(
if (!(trx = spider_get_trx(thd, FALSE, &error_num)))
{
delete thd;
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
set_current_thd(NULL);
#endif
share->bg_crd_thd_wait = FALSE;
share->bg_crd_kill = FALSE;
share->bg_crd_init = FALSE;
@ -3262,9 +3244,6 @@ void *spider_bg_crd_action(
}
spider_free_trx(trx, TRUE);
delete thd;
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
set_current_thd(NULL);
#endif
share->bg_crd_thd_wait = FALSE;
share->bg_crd_kill = FALSE;
share->bg_crd_init = FALSE;
@ -3298,9 +3277,6 @@ void *spider_bg_crd_action(
}
spider_free_trx(trx, TRUE);
delete thd;
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
set_current_thd(NULL);
#endif
pthread_cond_signal(&share->bg_crd_sync_cond);
pthread_mutex_unlock(&share->crd_mutex);
#if !defined(MYSQL_DYNAMIC_PLUGIN) || !defined(_WIN32)
@ -3688,9 +3664,6 @@ void *spider_bg_mon_action(
if (!(trx = spider_get_trx(thd, FALSE, &error_num)))
{
delete thd;
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
set_current_thd(NULL);
#endif
share->bg_mon_kill = FALSE;
share->bg_mon_init = FALSE;
pthread_cond_signal(&share->bg_mon_conds[link_idx]);
@ -3734,9 +3707,6 @@ void *spider_bg_mon_action(
pthread_mutex_unlock(&share->bg_mon_mutexes[link_idx]);
spider_free_trx(trx, TRUE);
delete thd;
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
set_current_thd(NULL);
#endif
#if !defined(MYSQL_DYNAMIC_PLUGIN) || !defined(_WIN32)
my_pthread_setspecific_ptr(THR_THD, NULL);
#endif