Commit graph

35 commits

Author SHA1 Message Date
Oleksandr Byelkin
04d9a46c41 Merge branch '10.6' into 10.10 2023-11-08 16:23:30 +01:00
Kristian Nielsen
2a4c573339 MDEV-32728: Wrong mutex usage 'LOCK_thd_data' and 'wait_mutex'
Checking for kill with thd_kill_level() or check_killed() runs apc
requests, which takes the LOCK_thd_kill mutex. But this is dangerous,
as checking for kill needs to be called while holding many different
mutexes, and can lead to cyclic mutex dependency and deadlock.

But running apc is only "best effort", so skip running the apc if the
LOCK_thd_kill is not available. The apc will then be run on next check
of kill signal.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2023-11-08 14:50:43 +01:00
Sergei Petrunia
3f68c2169e MDEV-28201: Server crashes upon SHOW ANALYZE/EXPLAIN FORMAT=JSON
- Describe the lifetime of EXPLAIN data structures in
  sql_explain.h:ExplainDataStructureLifetime.

- Make Item_field::set_field() call set_refers_to_temp_table()
  when it refers to a temp. table.
- Introduce QT_DONT_ACCESS_TMP_TABLES flag for Item::print.
  It directs Item_field::print to not try access its the
  temp table.
- Introduce Explain_query::notify_tables_are_closed()
  and call it right before the query closes its tables.
- Make Explain data stuctures' print_explain_json() methods
  accept "no_tmp_tbl" parameter which means pass
  QT_DONT_ACCESS_TMP_TABLES when printing items.
- Make Show_explain_request::call_in_target_thread() not call
  set_current_thd(). This wasn't needed as the code inside
  lex->print_explain() uses output->thd anyway. output->thd
  refers to the SHOW command's THD object.
2022-04-29 10:48:26 +03:00
Oleg Smirnov
02c3babdec MDEV-28124 Server crashes in Explain_aggr_filesort::print_json_members
SHOW EXPLAIN/ANALYZE FORMAT=JSON tries to access items that have already been
freed by a call to free_items() during THD::cleanup_after_query().
The solution is to disallow APC calls including SHOW EXPLAIN/ANALYZE
just before the call to free_items().
2022-04-29 10:48:25 +03:00
Marko Mäkelä
be85d3e61b Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
Vicențiu Ciorbaru
cb248f8806 Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
Marko Mäkelä
34841d2305 Merge bb-10.2-ext into 10.3 2017-12-12 09:57:17 +02:00
Monty
c2118a08b1 Move all kill mutex protection to LOCK_thd_kill
LOCK_thd_data was used to protect both THD data and
ensure that the THD is not deleted while it was in use

This patch moves the THD delete protection to LOCK_thd_kill,
which already protects the THD for kill.

The benefits are:
- More well defined what LOCK_thd_data protects
- LOCK_thd_data usage is now much simpler and easier to verify
- Less chance of deadlocks in SHOW PROCESS LIST as there is less
  chance of interactions between mutexes
- Remove not needed LOCK_thread_count from
  thd_get_error_context_description()
- Fewer mutex taken for thd->awake()

Other things:
- Don't take mysys->var mutex in show processlist to check if thread
  is kill marked
- thd->awake() now automatically takes the LOCK_thd_kill mutex
  (Simplifies code)
- Apc uses LOCK_thd_kill instead of LOCK_thd_data
2017-12-08 13:46:23 +02:00
Michael Widenius
4aaa38d26e Enusure that my_global.h is included first
- Added sql/mariadb.h file that should be included first by files in sql
  directory, if sql_plugin.h is not used (sql_plugin.h adds SHOW variables
  that must be done before my_global.h is included)
- Removed a lot of include my_global.h from include files
- Removed include's of some files that my_global.h automatically includes
- Removed duplicated include's of my_sys.h
- Replaced include my_config.h with my_global.h
2017-08-24 01:05:44 +02:00
iangilfillan
f0ec34002a Correct FSF address 2017-03-10 18:21:29 +01:00
Sergei Golubchik
3b0c7ac1f9 Merge branch '10.0' into 10.1 2016-03-21 13:02:53 +01:00
Otto Kekäläinen
1777fd5f55 Fix spelling: occurred, execute, which etc 2016-03-04 02:09:37 +02:00
Sergey Vojtovich
84568c2965 MDEV-8030 - Apc_target::disable() locks mutex twice
Moved Apc_target::destroy(), Apc_target::enable() and Apc_targe::disable()
definitions to my_apc.h so that they can be inlined.

Apc_targe::disable() now calls Apc_target::process_apc_requests() only if
there're APC requests. This saves one pthread_mutex_lock() call.

Overhead change:
Apc_target::disable              0.04% -> out of radar
Apc_target::enable               0.03% -> out of radar
Apc_target::process_apc_requests 0.02% -> out of radar
pthread_mutex_lock               0.43% -> 0.42%
pthread_mutex_unlock             0.26% -> 0.25%
2015-06-23 09:54:36 +04:00
Sergey Petrunya
e5d13c1567 Merge 10.0-base -> 10.0 2013-10-16 13:38:42 +04:00
Sergey Petrunya
9718b9763d SHOW EXPLAIN DELETE, post merge fixes
- Fix asserts, make sure that mysql_delete() operates on 
  thd->apc_target correctly* in all kinds of special cases 
  * - correctly means that one must switch it OFF iff it
  was switched ON.
- Added a few asserts to catch similar errors.
2013-05-27 13:53:18 +04:00
Sergei Golubchik
a9035be5b7 10.0-base merge 2013-04-15 15:09:22 +02:00
Sergei Golubchik
e56cad4b15 small cleanup 2013-04-07 14:03:43 +02:00
Sergei Golubchik
e1f681c99b 10.0-base -> 10.0-monty 2012-10-19 20:38:59 +02:00
Sergey Petrunya
2368f8895d MWL#182: Explain running statements
- Address feedback from the second code review.
2012-07-17 21:52:08 +04:00
Sergey Petrunya
725d76e1e8 MWL#182: Explain running statements: address review feedback
- switch SHOW EXPLAIN to using an INFORMATION_SCHEMA table.
2012-07-10 21:23:00 +04:00
Sergey Petrunya
a931467e17 Enable PERFORMANCE_SCHEMA tracking for SHOW EXPLAIN's conditions. 2012-07-07 08:47:41 +04:00
Sergey Petrunya
89820b4202 Better comments. 2012-07-06 00:28:30 +04:00
Sergey Petrunya
3e90dc1f77 MWL#182: Explain running statements
- Make SHOW EXPLAIN command be KILLable with KILL QUERY.
2012-07-05 22:04:13 +04:00
Sergey Petrunya
00ff7345fa - More "local" code in show_explain.test
- Better comments
- Make unittest compile on Windows
2012-06-30 06:05:06 +04:00
Sergey Petrunya
b9093d370b MWL#182: Explain running statements: address review feedback
- Fix the year in Monty Program Ab copyrights in the new files.
- Fix permissions handling so that SHOW EXPLAIN's handling is the 
  same as SHOW PROCESSLIST's.
2012-06-29 22:17:16 +04:00
Sergey Petrunya
84fd4e2542 MWL#182: Explain running statements: address review feedback
- Move standalone tests to a unittest.
- Added comments.
2012-06-28 16:46:24 +04:00
Sergey Petrunya
c62c0c5516 MWL#182: Explain running statements: address review feedback
- Add Monty Program Ab copyright in new files
- Change Apc_target::make_apc_call() to accept a C++-style
  functor (instead of C-style function + parameter)
2012-06-28 13:58:37 +04:00
Sergey Petrunya
66c62de103 MWL#182: Explain running statements
- Remove out-of-date comments, add dbug assertions.
2012-06-25 18:39:26 +04:00
Sergey Petrunya
2c1e737c6c MDEV-297: SHOW EXPLAIN: Server gets stuck until timeout occurs while executing SHOW
INDEX and SHOW EXPLAIN in parallel
- Rework locking code to use the LOCK_thd_data mutex for all synchronization. This also
  fixed MDEV-301.
2012-06-07 12:19:06 +04:00
Sergey Petrunya
34e9a4c1e2 Merge of recent changes in MWL#182 in 5.3 with {Merge of MWL#182 with 5.5} 2012-05-17 00:59:03 +04:00
Sergey Petrunya
dfbd777fd8 MWL#182: SHOW EXPLAIN: Merge 5.3->5.5 2012-05-16 19:20:00 +04:00
Sergey Petrunya
ca8aa3901c MWL#182: Explain running statements
- Code cleanup
2012-04-26 06:40:36 +05:30
Sergey Petrunya
203bbfe569 MWL#182: Explain running statements
- Implement new approach to testing (the DBUG_EXECUTE_IF variant)
- add an 'evalp' mysqltest command that is like 'eval' except that
  it prints the original query.
- Fix select_describe() not to change join_tab[i]->type
- More tests
2011-09-24 21:56:42 +04:00
Sergey Petrunya
0a08933036 MWL#182: Explain running statements
- Added TODO comments
2011-08-25 12:15:29 +04:00
Sergey Petrunya
7e66213444 MWL#182: Explain running statements
First code
- "Asynchronous procedure call" system
- new THD::check_killed() that serves APC request is called from within most important loops
- EXPLAIN code is now able to generate EXPLAIN output on-the-fly [incomplete]

Parts that are still missing:
- put THD::check_killed() call into every loop where we could spend significant amount of time
- Make sure EXPLAIN code works for group-by queries that replace JOIN::join_tab with make_simple_join() 
  and other such cases.
- User interface: what error code to use, where to get timeout settings from, etc.
2011-08-23 19:28:32 +04:00