Skip to content

Commit

Permalink
Cleanups and fixes
Browse files Browse the repository at this point in the history
- Added missing delete thd in bootstrap()
- Delete wrong 'delete thd' in start_wsrep_THD()
- Added missing 'delete thd' in case of SCHEDULER_ONE_THREAD_PER_CONNECTION
- Delete wrong dec_thread_running() in destroy_thd() as it caused thread_running
  to be wrong.
- Moved reset_killed() to a normal function to make it easier to debug
- Added check of mutex in wsrep_aborting_thd... functions
  • Loading branch information
montywi committed Sep 8, 2017
1 parent 4cb1a4f commit e022dde
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
1 change: 1 addition & 0 deletions sql/mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6396,6 +6396,7 @@ static void bootstrap(MYSQL_FILE *file)
sql_print_warning("Can't create thread to handle bootstrap (errno= %d)",
error);
bootstrap_error=-1;
delete thd;
DBUG_VOID_RETURN;
}
/* Wait for thread to die */
Expand Down
18 changes: 17 additions & 1 deletion sql/sql_class.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2067,6 +2067,23 @@ int THD::killed_errno()
}


void THD::reset_killed()
{
/*
Resetting killed has to be done under a mutex to ensure
its not done during an awake() call.
*/
DBUG_ENTER("reset_killed");
if (killed != NOT_KILLED)
{
mysql_mutex_lock(&LOCK_thd_kill);
killed= NOT_KILLED;
killed_err= 0;
mysql_mutex_unlock(&LOCK_thd_kill);
}
DBUG_VOID_RETURN;
}

/*
Remember the location of thread info, the structure needed for
the structure for the net buffer
Expand Down Expand Up @@ -4630,7 +4647,6 @@ void destroy_thd(MYSQL_THD thd)
thd->add_status_to_global();
unlink_not_visible_thd(thd);
delete thd;
dec_thread_running();
}

void reset_thd(MYSQL_THD thd)
Expand Down
15 changes: 1 addition & 14 deletions sql/sql_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -3737,20 +3737,7 @@ class THD :public Statement,
}
}
int killed_errno();
inline void reset_killed()
{
/*
Resetting killed has to be done under a mutex to ensure
its not done during an awake() call.
*/
if (killed != NOT_KILLED)
{
mysql_mutex_lock(&LOCK_thd_kill);
killed= NOT_KILLED;
killed_err= 0;
mysql_mutex_unlock(&LOCK_thd_kill);
}
}
void reset_killed();
inline void reset_kill_query()
{
if (killed < KILL_CONNECTION)
Expand Down
12 changes: 3 additions & 9 deletions sql/wsrep_mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1935,7 +1935,6 @@ pthread_handler_t start_wsrep_THD(void *arg)
close_connection(thd, ER_OUT_OF_RESOURCES);
statistic_increment(aborted_connects,&LOCK_status);
MYSQL_CALLBACK(thread_scheduler, end_thread, (thd, 0));

goto error;
}

Expand All @@ -1958,7 +1957,6 @@ pthread_handler_t start_wsrep_THD(void *arg)
close_connection(thd, ER_OUT_OF_RESOURCES);
statistic_increment(aborted_connects,&LOCK_status);
MYSQL_CALLBACK(thread_scheduler, end_thread, (thd, 0));
delete thd;
goto error;
}

Expand Down Expand Up @@ -2002,13 +2000,8 @@ pthread_handler_t start_wsrep_THD(void *arg)
// at server shutdown
}

if (thread_handling > SCHEDULER_ONE_THREAD_PER_CONNECTION)
{
mysql_mutex_lock(&LOCK_thread_count);
thd->unlink();
mysql_mutex_unlock(&LOCK_thread_count);
delete thd;
}
unlink_not_visible_thd(thd);
delete thd;
my_thread_end();
return(NULL);

Expand Down Expand Up @@ -2733,6 +2726,7 @@ void wsrep_unlock_rollback()

my_bool wsrep_aborting_thd_contains(THD *thd)
{
mysql_mutex_assert_owner(&LOCK_wsrep_rollback);
wsrep_aborting_thd_t abortees = wsrep_aborting_thd;
while (abortees)
{
Expand Down

0 comments on commit e022dde

Please sign in to comment.