diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2019-05-18 23:01:44 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2019-05-21 17:55:09 +0400 |
commit | 34dfcbe3a64deddd633ff62b51b6f12ecebe42be (patch) | |
tree | 70675bbb0d6761eb89e1fef945ef0b7de51d2e34 /sql/sql_connect.cc | |
parent | ebc55c8577be7b8b8c3d9433feb4ce457f5b6cc5 (diff) | |
download | mariadb-git-34dfcbe3a64deddd633ff62b51b6f12ecebe42be.tar.gz |
Move thread re-initialisation out of cache_thread
It mostly duplicates code of do_handle_one_connection(). Move it there,
so that it is easier to simplify it in future.
Moved PSI_CALL_delete_current_thread()/_db_pop_() out of mutex. Call them
consistently in all cases, unlike before:
- called for reused threads
- called for flushed threads
- called for threads that go down after 5 minutes timeout
- not called for threads attempting to cache themselves during flush
- not called for threads attempting to cache themselves when cache is full
Part of MDEV-19515 - Improve connect speed
Diffstat (limited to 'sql/sql_connect.cc')
-rw-r--r-- | sql/sql_connect.cc | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 1485ee9f363..c281769e616 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -1426,8 +1426,36 @@ end_thread: unlink_thd(thd); if (IF_WSREP(thd->wsrep_applier, false) || !put_in_cache || - !cache_thread(thd)) + !(connect= cache_thread(thd))) break; + + if (!(connect->create_thd(thd))) + { + /* Out of resources. Free thread to get more resources */ + connect->close_and_delete(); + break; + } + delete connect; + + /* + We have to call store_globals to update mysys_var->id and lock_info + with the new thread_id + */ + thd->store_globals(); + + /* + Create new instrumentation for the new THD job, + and attach it to this running pthread. + */ + PSI_CALL_set_thread(PSI_CALL_new_thread(key_thread_one_connection, + thd, thd->thread_id)); + + /* reset abort flag for the thread */ + thd->mysys_var->abort= 0; + thd->thr_create_utime= microsecond_interval_timer(); + thd->start_utime= thd->thr_create_utime; + + server_threads.insert(thd); } delete thd; } |