mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Merge 10.2 into 10.3 (except MDEV-17556)
The fix of MDEV-17556 (commite25623e78a
and commit61a362c949
) has been omitted due to conflicts and will have to be applied separately later.
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Copyright (c) 2000, 2015, Oracle and/or its affiliates.
|
||||
Copyright (c) 2008, 2020, MariaDB Corporation.
|
||||
Copyright (c) 2008, 2021, MariaDB Corporation.
|
||||
|
||||
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
|
||||
@ -1458,12 +1458,15 @@ void THD::reset_db(const LEX_CSTRING *new_db)
|
||||
|
||||
/* Do operations that may take a long time */
|
||||
|
||||
void THD::cleanup(void)
|
||||
void THD::cleanup(bool have_mutex)
|
||||
{
|
||||
DBUG_ENTER("THD::cleanup");
|
||||
DBUG_ASSERT(cleanup_done == 0);
|
||||
|
||||
set_killed(KILL_CONNECTION);
|
||||
if (have_mutex)
|
||||
set_killed_no_mutex(KILL_CONNECTION,0,0);
|
||||
else
|
||||
set_killed(KILL_CONNECTION);
|
||||
#ifdef ENABLE_WHEN_BINLOG_WILL_BE_ABLE_TO_PREPARE
|
||||
if (transaction.xid_state.xa_state == XA_PREPARED)
|
||||
{
|
||||
@ -1541,7 +1544,29 @@ void THD::cleanup(void)
|
||||
void THD::free_connection()
|
||||
{
|
||||
DBUG_ASSERT(free_connection_done == 0);
|
||||
my_free((char*) db.str);
|
||||
/* Check that we have already called thd->unlink() */
|
||||
DBUG_ASSERT(prev == 0 && next == 0);
|
||||
|
||||
/*
|
||||
Other threads may have a lock on THD::LOCK_thd_data or
|
||||
THD::LOCK_thd_kill to ensure that this THD is not deleted
|
||||
while they access it. The following mutex_lock ensures
|
||||
that no one else is using this THD and it's now safe to
|
||||
continue.
|
||||
|
||||
For example consider KILL-statement execution on
|
||||
sql_parse.cc kill_one_thread() that will use
|
||||
THD::LOCK_thd_data to protect victim thread during
|
||||
THD::awake().
|
||||
*/
|
||||
mysql_mutex_lock(&LOCK_thd_data);
|
||||
mysql_mutex_lock(&LOCK_thd_kill);
|
||||
|
||||
#ifdef WITH_WSREP
|
||||
delete wsrep_rgi;
|
||||
wsrep_rgi= 0;
|
||||
#endif /* WITH_WSREP */
|
||||
my_free(const_cast<char*>(db.str));
|
||||
db= null_clex_str;
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
if (net.vio)
|
||||
@ -1549,8 +1574,8 @@ void THD::free_connection()
|
||||
net.vio= 0;
|
||||
net_end(&net);
|
||||
#endif
|
||||
if (!cleanup_done)
|
||||
cleanup();
|
||||
if (!cleanup_done)
|
||||
cleanup(true); // We have locked THD::LOCK_thd_kill
|
||||
ha_close_connection(this);
|
||||
plugin_thdvar_cleanup(this);
|
||||
mysql_audit_free_thd(this);
|
||||
@ -1561,6 +1586,8 @@ void THD::free_connection()
|
||||
#if defined(ENABLED_PROFILING)
|
||||
profiling.restart(); // Reset profiling
|
||||
#endif
|
||||
mysql_mutex_unlock(&LOCK_thd_kill);
|
||||
mysql_mutex_unlock(&LOCK_thd_data);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1620,9 +1647,6 @@ THD::~THD()
|
||||
mysql_mutex_lock(&LOCK_thd_kill);
|
||||
mysql_mutex_unlock(&LOCK_thd_kill);
|
||||
|
||||
#ifdef WITH_WSREP
|
||||
delete wsrep_rgi;
|
||||
#endif
|
||||
if (!free_connection_done)
|
||||
free_connection();
|
||||
|
||||
@ -3070,12 +3094,12 @@ static File create_file(THD *thd, char *path, sql_exchange *exchange,
|
||||
}
|
||||
/* Create the file world readable */
|
||||
if ((file= mysql_file_create(key_select_to_file,
|
||||
path, 0666, O_WRONLY|O_EXCL, MYF(MY_WME))) < 0)
|
||||
path, 0644, O_WRONLY|O_EXCL, MYF(MY_WME))) < 0)
|
||||
return file;
|
||||
#ifdef HAVE_FCHMOD
|
||||
(void) fchmod(file, 0666); // Because of umask()
|
||||
(void) fchmod(file, 0644); // Because of umask()
|
||||
#else
|
||||
(void) chmod(path, 0666);
|
||||
(void) chmod(path, 0644);
|
||||
#endif
|
||||
if (init_io_cache(cache, file, 0L, WRITE_CACHE, 0L, 1, MYF(MY_WME)))
|
||||
{
|
||||
|
Reference in New Issue
Block a user