Commit graph

126 commits

Author SHA1 Message Date
Sergei Golubchik
474fe6d9d9 fixes for test failures
and small collateral changes

mysql-test/lib/My/Test.pm:
  somehow with "print" we get truncated writes sometimes
mysql-test/suite/perfschema/r/digest_table_full.result:
  md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/dml_handler.result:
  host table is not ported over yet
mysql-test/suite/perfschema/r/information_schema.result:
  host table is not ported over yet
mysql-test/suite/perfschema/r/nesting.result:
  this differs, because we don't rewrite general log queries, and multi-statement
  packets are logged as a one entry. this result file is identical to what mysql-5.6.5
  produces with the --log-raw option.
mysql-test/suite/perfschema/r/relaylog.result:
  MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB.
mysql-test/suite/perfschema/r/server_init.result:
  MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup.
mysql-test/suite/perfschema/r/stage_mdl_global.result:
  this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not
  do that, and this causes useless mutex locks and waits.
mysql-test/suite/perfschema/r/statement_digest.result:
  md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_consumers.result:
  md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/perfschema/r/statement_digest_long_query.result:
  md5 hashes of statement digests differ, because yacc token codes are different in mariadb
mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result:
  will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result:
  will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
2012-09-27 20:09:46 +02:00
Vladislav Vaintroub
8bf7aae23e fix application verifier crashes 2012-04-15 01:40:00 +02:00
Sergei Golubchik
262a2ab59d monty's cleanup of my_thr_init.c
and collateral changes
2012-03-13 13:29:44 +01:00
Vladislav Vaintroub
c4f5908a79 Fixed crashes found by application verifier:
- leaking mutex in lf_hash_destroy
- pthread_getspecific() before pthread_key_create() in my_thread_var_dbug()
(called by static C++ object constructors called in sys_vars)
- perfschema destroys mutexes that were  not created.
2011-12-02 15:35:05 +01:00
Sergei Golubchik
dfc1901e80 compilation fixes
cmake/maintainer.cmake:
  don't do -Werror just yet
config.h.cmake:
  according to MSDN PSAPI_VERSION should be 1 in a portable application
mysys/my_thr_init.c:
  first, reset THR_KEY_mysys, and then free dbug data,
  because dbug data are automacially created on the next dbug call,
  unless THR_KEY_mysys is null.
2011-11-27 17:50:08 +01:00
Sergei Golubchik
0e007344ea mysql-5.5.18 merge 2011-11-03 19:17:05 +01:00
Sergei Golubchik
76f0b94bb0 merge with 5.3
sql/sql_insert.cc:
  CREATE ... IF NOT EXISTS may do nothing, but
  it is still not a failure. don't forget to my_ok it.
  ******
  CREATE ... IF NOT EXISTS may do nothing, but
  it is still not a failure. don't forget to my_ok it.
sql/sql_table.cc:
  small cleanup
  ******
  small cleanup
2011-10-19 21:45:18 +02:00
Sergei Golubchik
49501b4ccb fix memory leaks and other problems found by safemalloc
client/mysql_upgrade.c:
  missing DBUG_RETURN
client/mysqladmin.cc:
  client plugin memory wasn't freed
client/mysqlcheck.c:
  client plugin memory, defaults, a result set, a command-line option value were not freed.
  missing DBUG_RETURN.
client/mysqldump.c:
  client plugin memory wasn't freed
client/mysqlslap.c:
  client plugin memory wasn't freed
client/mysqltest.cc:
  hopeless. cannot be fixed.
mysql-test/valgrind.supp:
  Bug#56666 is now fixed.
mysys/array.c:
  really, don't allocate if the caller didn't ask to.
mysys/my_init.c:
  safemalloc checks must be done at the very end
mysys/my_thr_init.c:
  not needed anymore
sql-common/client.c:
  memory leak
sql/log.cc:
  log_file was not closed, memory leak.
sql/mysqld.cc:
  fix bug#56666 (causing many P_S related memory leaks).
  close_active_mi() not called for --bootstrap, memory leak.
sql/sql_lex.cc:
  redo Lex->mi handling
sql/sql_lex.h:
  redo Lex->mi handling
sql/sql_plugin.cc:
  plugins having PLUGIN_VAR_MEMALLOC string variables have this variables allocated in every THD.
  The memory was freed in ~THD but only if plugin was still active. If plugin was unloaded the
  variable was not found and the memory was lost. By loading and unloading plugins an arbitrary
  amount of memory can be lost.
sql/sql_repl.cc:
  redo Lex->mi handling
sql/sql_yacc.yy:
  completely wrong handling of Lex->mi - run-time memory leak, by repeating the statement
  arbitrary amount of memory can be lost.
  
  Lex->mi.repl_ignore_server_ids_opt was allocated when parsing CHANGE MASTER,
  and freed after executing the statement. if parser failed on syntax (or another)
  error the statement was never executed. Lex->mi was simply bzero-ed for the next
  CHANGE MASTER  statement.
sql/table.cc:
  didn't compile
storage/perfschema/pfs_lock.h:
  Bug#56666 is fixed
2011-07-10 20:09:17 +02:00
Sergei Golubchik
02b8232629 small dbug cleanup 2011-07-10 19:50:29 +02:00
Sergei Golubchik
9809f05199 5.5-merge 2011-07-02 22:08:51 +02:00
Kent Boortz
02e07e3b51 Updated/added copyright headers 2011-06-30 17:46:53 +02:00
Kent Boortz
68f00a5686 Updated/added copyright headers 2011-06-30 17:37:13 +02:00
Kent Boortz
44135d4725 Updated/added copyright headers 2011-06-30 17:31:31 +02:00
Sergei Golubchik
0accbd0364 lots of post-merge changes 2011-04-25 17:22:25 +02:00
Davi Arnaut
8aadfb4065 Remove some leftovers from the removal of the gethostbyname wrappers. 2011-04-13 16:05:26 -03:00
Magne Mahre
a4481d3222 Post-push cleanup, for Bug#11763065 et al. 2011-03-01 14:36:47 +01:00
Magne Mahre
c4715a8076 Bug#11765237 - 58179: CANNOT START MYSQLD WITH APP VERIFIER
Bug#11763065 - 55730: KILL_SERVER() CALLS SETEVENT ON A NULL 
               HANDLE, SMEM_EVENT_CONNECT_REQUEST
      
Application Verifier is a Microsoft tool used for
detecting certain classes of programming errors.
In particular, MS Windows OS resource usage is
monitored for wrong usage (handles, thread local
storage, critical sections, ...)
      
In MySQL 5.5.x, an error was introduced where an
object on thread local storage was used before the
TLS and the object was created.
      
The fix has been to move the mysys initialization
to an earlier stage in the boot process when built for
Windows.  For non-win builds, the init already happens
early.

Some un-tangling of calls to my_init(), my_basic_init()
and my_thread_global_init() was done.  There is no
longer a need to do init in steps, so the full my_init()
is called instead of my_init_basic().
      
In addition,  Bug#11763065 was fixed.  The event handle
'smem_event_connect_request' is only created if
'opt_enable_shared_memory' is set.  When killing the
server, an event was flagged on the handle
unconditionally.  Added a test, so it will only be
flagged if created.


include/my_pthread.h:
  my_thread_basic_global_init is no longer
  necessary, and the my_thread_basic_global_reinit 
  function is renamed to reflect that it now
  reinits mutexes and condvars originating from
  my_thread_global_init
mysys/my_thr_init.c:
  Reorganized code.
2011-03-01 13:03:31 +01:00
Davi Arnaut
eb58939395 Bug#42054: SELECT CURDATE() is returning bad value
The problem from a user point of view was that on Solaris the
time related functions (e.g. NOW(), SYSDATE(), etc) would always
return a fixed time.

This bug was happening due to a logic in the time retrieving
wrapper function which would only call the time() function every
half second. This interval between calls would be calculated
using the gethrtime() and the logic relied on the fact that time
returned by it is monotonic.

Unfortunately, due to bugs in the gethrtime() implementation,
there are some cases where the time returned by it can drift
(See Solaris bug id 6600939), potentially causing the interval
calculation logic to fail.

Since newer versions of Solaris (10+) have alleviated the
performance degradation associated with time(2), the solution is
to simply directly rely on time() at each invocation.

This simplification has an upside that it allows us to eliminate
a lock which was used to control access to the variables used
to track the half second interval, thus improving the overall
scalability of timekeeping related functions (e.g. NOW()).

Benchmarks runs have shown no significant degradation associated
with this change. With this, there are actually improvements in
performance for cases involving many connections.

In summary, the changes introduced by this patch are:

a) my_time() and my_micro_time_and_time() no longer use gethrtime().
   Instead, time() and gettimeofdate() are used correspondingly.

b) my_micro_time() is changed to not use gethrtime() so as to
   have the same time source as my_micro_time_and_time().
   There shouldn't be any performance impact from this change
   since this function is used only a few times during statement
   execution and, on Solaris, gettimeofday() shows acceptable
   performance.

mysys/my_getsystime.c:
  Use time() even if gethrtime() is available. Remove logic which
  relied on gethrtime() to only call time() every half second.
  Since gethrtime() is not used anymore, also remove it from
  my_micro_time() to keep a common time source.
  
  Also, function comments are cleaned up (fixed typos and wrong
  information) and converted to doxygen.
mysys/my_thr_init.c:
  Remove mutex which is no longer used.
mysys/mysys_priv.h:
  Remove mutex which is no longer used.
2011-01-12 18:36:39 -02:00
Magne Mahre
8ede0759c3 Remove configuration preprocessor symbols 'THREAD'
and 'THREAD_SAFE_CLIENT'.
  
As of MySQL 5.5, we no longer support non-threaded
builds.   This patch removes all references to the
obsolete THREAD and THREAD_SAFE_CLIENT preprocessor
symbols.  These were used to distinguish between
threaded and non-threaded builds.
2011-01-11 10:07:37 +01:00
Sergei Golubchik
65ca700def merge.
checkpoint.
does not compile.
2010-11-25 18:17:28 +01:00
Christopher Powers
f49c88c8e7 Bug #55345, "mysql_library_init causes segfault if executed after calling mysql_library_end"
my_thread_global_end() now sets mysql_thread_basic_global_init_done= 0
to ensure destroyed mutexes are not reused.

I verified that clearing this flag will not result in the redundant allocation
of other resources allocated by my_thread_global_init() and
my_thread_basic_global_init().

mysys/my_thr_init.c:
  Clear mysql_thread_basic_global_init_done flag at the end of my_thread_global_end()
2010-08-22 20:41:42 -05:00
unknown
4bf849c23c Merge MySQL 5.1.44 into MariaDB. 2010-03-04 09:03:07 +01:00
Michael Widenius
e9bce6c9d4 Patch set contributed by Alex Budovski (MCA)
Fix for Bug#31173: mysqlslap.exe crashes if called without any parameters

.bzrignore:
  Fixed .bzrignore rules. Many were simply not ignoring what they were meant to.
client/mysqlslap.c:
  Fixed bug for Bug#31173: mysqlslap.exe crashes if called without any parameters
  The original patch could cause memory leaks and odd problems depending on how connection was made.
  This code ensures that all mysql_options() are set for each mysql_real_connect().
  (This patch by Monty)
mysys/my_thr_init.c:
  Fixed multiply-initialized critical section on Windows, due to code incorrectly
  checking the wrong field in an attempt to prevent multiple-initialization.
sql-common/client.c:
  Don't use shared memory if it's not set (for example after failed mysql_real_connect).
  Ensure that mysql_close() resets all resources so that it's safe to call it twice.
  (Patch by monty, related to Bug#31173: mysqlslap.exe crashes if called without any parameters)
sql/CMakeLists.txt:
   Added page fault counters for SHOW PROFILE on Windows.
sql/mysqld.cc:
  Fixed attempt to set a NULL event. The code now only sets the event if appropriate (i.e. shared memory is being used)
sql/sql_profile.cc:
  Added page fault counters for SHOW PROFILE on Windows.
sql/sql_profile.h:
  Added page fault counters for SHOW PROFILE on Windows.
sql/udf_example.def:
  Some cleanup functions were not exported from udf_example.dll, causing them to
  never be executed, and as a result multiple-initialization of kernel objects
  occurred and resources were not being freed correctly.
storage/maria/ma_close.c:
  Condition variable share->key_del_cond was never being destroyed, while its
  containing heap block was being freed in maria_close(), leaking kernel
  resources.
2010-01-29 20:42:22 +02:00
Vladislav Vaintroub
b5a3b81402 Bug #50362 comp_err crashes during compilation on FreeBSD.
The reason for the crash is using uinitialized mutex attribute (MY_MUTEX_FAST_INIT)
in pthread_mutex_init.

The fix is to initialize the attribute before the first use.
2010-01-20 14:04:17 +01:00
Marc Alff
3d91522561 WL#2360 Performance schema
Part IV: sql instrumentation
2010-01-06 22:42:07 -07:00
Alexander Nozdrin
6e5c7b80bd Manual merge from mysql-next-mr.
Conflicts:
  - mysys/charset.c
  - mysys/my_thr_init.c
2009-12-17 23:02:52 +03:00
Alexander Nozdrin
0e3a80e0a8 Manual merge from mysql-trunk-merge.
Conflicts:
  - storage/myisam/mi_packrec.c
2009-12-17 22:16:54 +03:00
Alexey Kopytov
5069a66670 Automerge from mysql-5.1-bugteam to mysql-trunk-merge. 2009-12-17 18:09:04 +03:00
Satya B
bbf079cf2c merge mysql-5.0-bugteam to mysql-5.1-bugteam 2009-12-17 17:15:13 +05:30
Satya B
cf9966f86f Fix for Bug#37408 - Compressed MyISAM files should not require/use mmap()
When compressed myisam files are opened, they are always memory mapped
sometimes causing memory swapping problems.

When we mmap the myisam compressed tables of size greater than the memory 
available, the kswapd0 process utilization is very high consuming 30-40% of 
the cpu. This happens only with linux kernels older than 2.6.9

With newer linux kernels, we don't have this problem of high cpu consumption
and this option may not be required.
 
The option 'myisam_mmap_size' is added to limit the amount of memory used for
memory mapping of myisam files. This option is not dynamic.

The default value on 32 bit system is 4294967295 bytes and on 64 bit system it
is 18446744073709547520 bytes.

Note: Testcase only tests the option variable. The actual bug has be to 
tested manually.

include/my_global.h:
  Fix for Bug #37408 - Compressed MyISAM files should not require/use mmap()
  
  define SIZE_T_MAX
include/myisam.h:
  Fix for Bug #37408 - Compressed MyISAM files should not require/use mmap()
  
  declare 'myisam_mmap_size' and 'myisam_mmap_used' variables and the mutex
  THR_LOCK_myisam_mmap
myisam/mi_packrec.c:
  Fix for Bug #37408 - Compressed MyISAM files should not require/use mmap()
  
  add 'myisam_mmap_size' option which limits the memory available to mmap of 
  myisam files
myisam/mi_static.c:
  Fix for Bug #37408 - Compressed MyISAM files should not require/use mmap()
  
  declare 'myisam_mmap_size' and 'myisam_mmap_used' variables and the mutex
  THR_LOCK_myisam_mmap
myisam/myisamdef.h:
  Fix for Bug #37408 - Compressed MyISAM files should not require/use mmap()
  
  move MEMMAP_EXTRA_MARGIN to myisam.h so that it can be used in mysqld.cc
mysql-test/r/variables.result:
  Fix for Bug #37408 - Compressed MyISAM files should not require/use mmap()
  
  Testcase for BUG#37408 to test the myisam_mmap_size option
mysql-test/t/variables.test:
  Fix for Bug #37408 - Compressed MyISAM files should not require/use mmap()
  
  Testcase for BUG#37408 to test the myisam_mmap_size option
mysys/my_thr_init.c:
  Fix for Bug #37408 - Compressed MyISAM files should not require/use mmap()
  
  intialize the lock THR_LOCK_myisam_mmap
sql/mysqld.cc:
  Fix for Bug #37408 - Compressed MyISAM files should not require/use mmap()
  
  add the 'myisam_mmap_size' option
sql/set_var.cc:
  Fix for Bug #37408 - Compressed MyISAM files should not require/use mmap()
  
  add the 'myisam_mmap_size' to the SHOW VARIABLES list
2009-12-17 16:55:50 +05:30
Marc Alff
c082955f06 WL#2360 Performance schema
Part III: mysys instrumentation
2009-12-09 20:19:51 -07:00
Marc Alff
244eced1a7 WL#3230 concurrent hash
Backport from 6.0.14 to 5.6.0

Original code from Sergei Golubchik
2009-11-17 19:31:40 -07:00
unknown
a962160eec Merge with MySQL 5.1, with following additions:
- Moved some code from innodb_plugin to xtradb, to ensure that all tests runs
- Did changes in pbxt and maria storage engines becasue of changes in thd->query
- Reverted wrong code in sql_table.cc for how ROW_FORMAT is used.

This is a re-commit of Monty's merge to eliminate an extra commit from
MySQL-5.1.42 that was accidentally included in the merge.

This is a merge of the MySQL 5.1.41 clone-off (clone-5.1.41-build). In
case there are any extra changes done before final MySQL 5.1.41
release, these will need to be merged later before MariaDB 5.1.41
release.
2009-11-16 21:49:51 +01:00
Sergei Golubchik
319847a4ec backport of dbug extensions from 6.0:
function/ syntax
  glob(7) wildcards
  unit tests
2009-10-30 19:13:58 +01:00
Alexander Nozdrin
c30d924dd5 Manual merge from mysql-trunk-merge. 2009-10-14 12:25:39 +04:00
Vladislav Vaintroub
4acaca0202 backport of
Revision: 
2597.72.1 revid:sp1r-Reggie@core.-20080403153947-15243
removed instances of __NT__ from code. We now only build "NT" binaries
2009-09-30 22:10:22 +02:00
Vladislav Vaintroub
14c2cfb568 Backport of this changeset
http://lists.mysql.com/commits/59686

Cleanup pthread_self(), pthread_create(), pthread_join() implementation on Windows.
Prior implementation is was unnecessarily complicated and even differs in embedded
and non-embedded case.
      
Improvements in this patch:
* pthread_t is now the unique thread ID, instead of HANDLE returned by beginthread
      
This simplifies pthread_self() to be just straight GetCurrentThreadId().
prior it was much  art involved in passing the beginthread() handle from the caller
to the TLS structure in the child thread ( did not work for the main thread of
course)
      
* remove MySQL specific my_thread_init()/my_thread_end() from pthread_create.
No automagic is done on Unix on pthread_create(). Having the same on Windows will 
improve portability and avoid extra #ifdef's
      
* remove redefinition of getpid() - it was defined as GetCurrentThreadId()
2009-09-30 17:40:12 +02:00
Vladislav Vaintroub
2bc1930c6c Windows improvements : manual backport of
htttp://lists.mysql.com/commits/50957?f=plain
      
Always use TLS functions instead of __declspec(thread) to access 
thread local storage variables.
The change removes the necessity to recomplile the same source
files twice -  with USE_TLS for DLLs and without USE_TLS for EXEs.
Real benefit of this change is better readability and maintainability
of TLS functions within MySQL.
              
There is a performance loss using TlsXXX functions compared to __declspec 
but the difference is negligible in practice. In a sysbench-like benchmark 
I ran with with TlsGetValue, pthread_[get|set]_specific was called 600000000 
times and took 0.17sec of total 35min CPU time, or 0.008%.
2009-09-30 03:22:57 +02:00
Magnus Blåudd
0b8953ba67 Merge bug#42850 to 5.1 2009-09-28 14:40:45 +02:00
Magnus Blåudd
9eab1cdb9a Bug#42850 race condition in my_thr_init.c
- Create the "dummy" thread joinable and wait for it to
   exit before continuing in 'my_thread_global_init'
 - This way we know that the pthread library is initialized
   by one thread only
2009-09-24 08:30:31 +02:00
Michael Widenius
945fa0d913 Merge with mysql-maria tree
mysql-test/t/variables.test:
  Reset delay_key_write, otherwise maria.maria test may fail
sql/set_var.cc:
  Reset ha_open_options if one resets the delay_key_write variable.
  Before there was no way to reset it without restarting mysqld, which caused some tests to fail
2009-02-19 11:01:25 +02:00
Michael Widenius
a8fdaa6f2c Merge with base MySQL 5.1
Contains fixes for test cases
Changed release tag to beta

configure.in:
  change release tag to beta
2009-02-15 12:58:34 +02:00
Guilhem Bichot
b90ff5340f Fixing problems of previous 5.1-main->5.1-maria merge:
- adding back Serg's "mtr --list-options"
- safe_mutex deadlock detector started raising wrong deadlock warnings, fixed
here by a backport from 6.0-main.

include/my_pthread.h:
  Porting changes done to 6.0-main which satisfy the safe_mutex deadlock detector (those
  in 5.1-main don't), see chad@mysql.com-20090126155607-n0j3zbmgbfepnmmo for explanations
mysql-test/mysql-test-run.pl:
  adding back Serg's --list-options
mysys/my_init.c:
  Porting changes done to 6.0-main which satisfy the safe_mutex deadlock detector (those
  in 5.1-main don't), see chad@mysql.com-20090126155607-n0j3zbmgbfepnmmo for explanations
mysys/my_thr_init.c:
  Porting changes done to 6.0-main which satisfy the safe_mutex deadlock detector (those
  in 5.1-main don't), see chad@mysql.com-20090126155607-n0j3zbmgbfepnmmo for explanations
2009-02-12 16:27:33 +01:00
Sergei Golubchik
9c96fde120 post-review fixes
include/atomic/generic-msvc.h:
  prevent possible compiler warnings
include/lf.h:
  comments, better definition for LF_HASH_OVERHEAD
include/maria.h:
  define MARIA_CANNOT_ROLLBACK here
include/my_pthread.h:
  avoid possible name clash
include/waiting_threads.h:
  comments, const, move WT_RESOURCE to waiting_threads.c
mysql-test/suite/maria/r/maria_notembedded.result:
  new test
mysql-test/suite/maria/t/maria_notembedded.test:
  new test - 5-way deadlock
mysys/lf_hash.c:
  better definition for LF_HASH_OVERHEAD
mysys/my_static.c:
  comment
mysys/my_thr_init.c:
  casts
mysys/waiting_threads.c:
  comments, asserts, etc
server-tools/instance-manager/parse.cc:
  fix my_init_dynamic_array() to follow new calling conventions
sql/mysqld.cc:
  call wt_init after set_proper_floating_point_mode
sql/sql_class.h:
  comment
storage/maria/ha_maria.cc:
  move MARIA_CANNOT_ROLLBACK to a common header
storage/maria/ma_commit.c:
  comment
storage/maria/ma_write.c:
  comments, check for HA_ERR_FOUND_DUPP_KEY
storage/maria/trnman.c:
  comments, assert
storage/maria/trnman.h:
  comments
storage/maria/unittest/trnman-t.c:
  be paranoid
unittest/mysys/lf-t.c:
  comments
unittest/mysys/waiting_threads-t.c:
  comments, safety, memory leak
2009-01-15 22:27:36 +01:00
Guilhem Bichot
926aaf4635 Merge of 5.1-main into 5.1-maria. There were no changes to storage/myisam, mysys/mf_keycache.c, mysql-test/t/*myisam*
since previous merge. MARIA_PAGECACHE_READS in maria-preload.test are down a little bit (5%), which must be a good
side-effect of some sql/ change.
2008-12-10 10:02:25 +01:00
Vladislav Vaintroub
8f500c522b Bug#38522: 5 seconds delay when closing application using embedded server
The problem here is that embedded server starts handle_thread manager 
thread  on mysql_library_init() does not stop it on mysql_library_end().
At shutdown, my_thread_global_end() waits for thread count to become 0,
but since we did not stop the thread it will give up after 5 seconds.
             
Solution is to move shutdown for handle_manager thread from kill_server()
(mysqld specific) to clean_up() that is used by both embedded and mysqld.
            
This patch also contains some refactorings - to avoid duplicate code,
start_handle_manager() and stop_handle_manager() functions are introduced.
Unused variables are eliminated. handle_manager does not rely on global
variable abort_loop anymore to stop (abort_loop is not set for embedded).
            
Note: Specifically on Windows and when using DBUG version of libmysqld, 
the complete solution requires removing obsolete code my_thread_init() 
from my_thread_var(). This has a side effect that a DBUG statement 
after my_thread_end() can cause thread counter to be incremented, and 
embedded will hang for some seconds. Or worse, my_thread_init() will 
crash if critical sections have been deleted by the global cleanup 
routine that runs in a different thread. 

This patch also fixes and revert prior changes for Bug#38293 
"Libmysqld crash in mysql_library_init if language file missing".

Root cause of the crash observed in Bug#38293  was bug in my_thread_init() 
described above




client/mysql.cc:
  sql_protocol_typelib is not exported from libmysqld
  (does not make sense either)
  thus excluded from embedded client
dbug/dbug.c:
  revert changes for Bug#38293
include/my_dbug.h:
  revert changes for Bug#38293
libmysql/libmysql.c:
  Removed DBUG_POP call, because when called after my_end(), will access
  THR_key_mysys that is already deleted. The result of pthread_get_specific
  is not predictable in this case and hence DBUG_POP can crash.
libmysqld/examples/CMakeLists.txt:
  Revert changes for Bug#38293.
libmysqld/lib_sql.cc:
  code to start handle manager is factored out into 
  start_handle_manager() function
libmysqld/libmysqld.def:
  Revert changes for Bug #38293
  Remove excessive exports from libmysqld, export what API documents.
mysys/my_thr_init.c:
  Remove windows-DLL-specific workaround for something (old code, no documentation for
  what specifically). The problem is that even after my_thread_end() is finished, 
  DBUG statement can initiate my_thread_init(). This does not happen anywhere else and 
  should not happen on  Windows either.
sql/mysql_priv.h:
  - new functions start_handle_manager() and stop_handle_manager()
  - move manager_thread_in_use  variable to sql_manager.cc and made
  it static
  - remove manager_status, as it is unused
sql/mysqld.cc:
  Code to start/stop handle_manager thread is factored out into start_handle_manager()
2008-12-04 19:41:53 +01:00
Michael Widenius
32f81bab7d WL#3262 add mutex lock order checking to safemutex (also called safe_mutex_deadlock_detector)
This writes a warning on stderr if one uses mutex in different order,
like if one in one case would lock mutex in the order A,B and in another case
would lock mutex in the order B,A
This is inspired by and loosely based on the LOCKDEP patch by Jonas
Wrong mutex order is either fixed or mutex are marked with MYF_NO_DEADLOCK_DETECTION
if used inconsistently (need to be fixed by server team)

KNOWN_BUGS.txt:
  Added information that one need to dump and restore Maria tables
include/hash.h:
  Added prototype function for walking over all elements in a hash
include/my_pthread.h:
  Added my_pthread_mutex_init() and my_pthread_mutex_lock(); These should be used if one wants to disable mutex order checking.
  Changed names of the nonposix mutex_init functions to not conflict with my_phread_mutex_init()
  Added and extended structures for mutex deadlock detection.
  New arguments to sage_mutex_init() and safe_mutex_lock() to allow one to disable mutex order checking.
  Added variable 'safe_mutex_deadlock_detector' to enable/disable deadlock detection for all pthread_mutex_init()
mysys/Makefile.am:
  Added cleaning of test files
  Added test_thr_mutex
mysys/hash.c:
  Added hash_iterate() to iterate over all elements in a hash
  More comments
mysys/my_init.c:
  Added calls to destory all mutex uses by mysys()
  Added waiting for threads to end before calling TERMINATE() to list not freed memory
mysys/my_pthread.c:
  Changed names to free my_pthread_mutex_init() for mutex-lock-order-checking
mysys/my_sleep.c:
  Fixed too long wait if using 1000000L as argument
mysys/my_thr_init.c:
  Mark THR_LOCK_threads and THR_LOCK_malloc to not have mutex deadlock detection.
  (We can't have it enabled for this as these are internal mutex used by the detector  
  Call my_thread_init() early as we need thread specific variables enabled for the following pthread_mutex_init()
  Move code to wait for threads to end to my_wait_for_other_threads_to_die()
  Don't destroy mutex and conditions unless all threads have died
  Added my_thread_destroy_mutex() to destroy all mutex used by the mysys thread system
  Name the thread specific mutex as "mysys_var->mutex"
  Added my_thread_var_mutex_in_use() to return pointer to mutex in use or 0 if thread variables are not initialized
mysys/mysys_priv.h:
  Added prototypes for functions used internally with mutex-wrong-usage detection
mysys/thr_mutex.c:
  Added runtime detection of mutex used in conflicting order
  See WL#3262 or test_thr_mutex.c for examples
  The base idea is for each mutex have two hashes:
  - mutex->locked_mutex points to all mutex used after this one
  - mutex->used_mutex points to all mutex which has this mutex in it's mutex->locked_mutex
  There is a wrong mutex order if any mutex currently locked before this mutex is in the mutex->locked_mutex hash
sql/event_queue.cc:
  Mark mutex used inconsistently (need to be fixed by server team)
sql/event_scheduler.cc:
  Declare the right order to take the mutex
sql/events.cc:
  Mark mutex used inconsistently (need to be fixed by server team)
sql/ha_ndbcluster_binlog.cc:
  Mark mutex used inconsistently (need to be fixed by server team)
sql/log.cc:
  Mark mutex used inconsistently (need to be fixed by server team)
sql/mysqld.cc:
  Use pthread_mutex_trylock instead of pthread_mutex_unlock() when sending kill signal to thread
  This is needed to avoid wrong mutex order as normally one takes 'current_mutex' before mysys_var->mutex.
  Added call to free sp cache.
  Add destruction of LOCK_server_started and COND_server_started.
  Added register_mutex_order() function to register in which order mutex should be taken
  (to initiailize mutex_deadlock_detector).
  Added option to turn off safe_mutex_deadlock_detector
sql/protocol.cc:
  Fixed wrong argument to DBUG_PRINT (found by valgrind)
sql/rpl_mi.cc:
  Mark mutex used inconsistently (need to be fixed by server team)
sql/set_var.cc:
  Remove wrong locking of LOCK_global_system_variables when reading and setting log variables
  (would cause inconsistent mutex order).
  Update global variables outside of logger.unlock() as LOCK_global_system_variables has to be taken before logger locks
  Reviewed by gluh
sql/sp_cache.cc:
  Added function to destroy mutex used by sp cache
sql/sp_cache.h:
  Added function to destroy mutex used by sp cache
sql/sql_class.cc:
  Use pthread_mutex_trylock instead of pthread_mutex_unlock() when sending kill signal to thread
  This is needed to avoid wrong mutex order as normally one takes 'current_mutex' before mysys_var->mutex.
  Register order in which LOCK_delete and mysys_var->mutex is taken
sql/sql_insert.cc:
  Give a name for Delayed_insert::mutex
  Mark mutex used inconsistently (need to be fixed by server team)
  Move closing of tables outside of di->mutex (to avoid wrong mutex order)
sql/sql_show.cc:
  Don't keep LOCK_global_system_variables locked over value->show_type() as this leads to wrong mutex order
storage/innobase/handler/ha_innodb.cc:
  Disable safe_muted_deadlock_detector for innobase intern mutex (to speed up page cache initialization)
storage/maria/ha_maria.cc:
  Added flag to ha_maria::info() to signal if we need to lock table share or not.
  This is needed to avoid locking mutex in wrong order
storage/maria/ha_maria.h:
  Added flag to ha_maria::info() to signal if we need to lock table share or not.
storage/maria/ma_close.c:
  Destroy key_del_lock
  Simplify freeing ftparser_param
storage/maria/ma_key.c:
  Better comment
storage/maria/ma_loghandler.c:
  Mark mutex used inconsistently (need to be fixed by sanja)
storage/maria/ma_state.c:
  More comments
storage/maria/ma_test1.c:
  Ensure that safe_mutex_deadlock_detector is always on (should be, this is just for safety)
storage/maria/ma_test2.c:
  Ensure that safe_mutex_deadlock_detector is always on (should be, this is just for safety)
2008-12-03 00:02:52 +02:00
Sergei Golubchik
6ba12f070c WL#3064 - waiting threads - wait-for graph and deadlock detection
client/mysqltest.c:
  compiler warnings
configure.in:
  remove old tests for unused programs
  disable the use of gcc built-ins if smp assembler atomics were selected explictily.
  add waiting_threads.o to THREAD_LOBJECTS
include/lf.h:
  replace the end-of-stack pointer with the pointer to the end-of-stack pointer.
  the latter could be stored in THD (mysys_vars) and updated in pool-of-threads
  scheduler.
  constructor/destructor in lf-alloc
include/my_pthread.h:
  shuffle set_timespec/set_timespec_nsec macros a bit to be able to fill
  several timeout structures with only one my_getsystime() call
include/waiting_threads.h:
  waiting threads - wait-for graph and deadlock detection
mysys/Makefile.am:
  add waiting_threads.c
mysys/lf_alloc-pin.c:
  replace the end-of-stack pointer with the pointer to the end-of-stack pointer.
  the latter could be stored in THD (mysys_vars) and updated in pool-of-threads
  scheduler.
  constructor/destructor in lf-alloc
mysys/lf_hash.c:
  constructor/destructor in lf-alloc
mysys/my_thr_init.c:
  remember end-of-stack pointer in the mysys_var
mysys/waiting_threads.c:
  waiting threads - wait-for graph and deadlock detection
storage/maria/ha_maria.cc:
  replace the end-of-stack pointer with the pointer to the end-of-stack pointer.
  the latter could be stored in THD (mysys_vars) and updated in pool-of-threads
  scheduler.
storage/maria/ma_commit.c:
  replace the end-of-stack pointer with the pointer to the end-of-stack pointer.
  the latter could be stored in THD (mysys_vars) and updated in pool-of-threads
  scheduler.
storage/maria/trnman.c:
  replace the end-of-stack pointer with the pointer to the end-of-stack pointer.
  the latter could be stored in THD (mysys_vars) and updated in pool-of-threads
  scheduler.
storage/maria/trnman_public.h:
  replace the end-of-stack pointer with the pointer to the end-of-stack pointer.
  the latter could be stored in THD (mysys_vars) and updated in pool-of-threads
  scheduler.
storage/maria/unittest/trnman-t.c:
  replace the end-of-stack pointer with the pointer to the end-of-stack pointer.
  the latter could be stored in THD (mysys_vars) and updated in pool-of-threads
  scheduler.
unittest/mysys/Makefile.am:
  add waiting_threads-t
unittest/mysys/lf-t.c:
  factor out the common code for multi-threaded stress unit tests
  move lf tests to a separate file
unittest/mysys/my_atomic-t.c:
  factor out the common code for multi-threaded stress unit tests
  move lf tests to a separate file
unittest/mysys/thr_template.c:
  factor out the common code for multi-threaded stress unit tests
unittest/mysys/waiting_threads-t.c:
  wt tests
2008-07-29 16:10:24 +02:00
unknown
50ceea65cf Merge mysql.com:/home/my/mysql-5.1
into  mysql.com:/home/my/mysql-new


BitKeeper/etc/ignore:
  auto-union
BUILD/SETUP.sh:
  Auto merged
CMakeLists.txt:
  Auto merged
client/get_password.c:
  Auto merged
client/mysqldump.c:
  Auto merged
client/mysqltest.c:
  Auto merged
cmd-line-utils/readline/bind.c:
  Auto merged
cmd-line-utils/readline/display.c:
  Auto merged
cmd-line-utils/readline/histexpand.c:
  Auto merged
cmd-line-utils/readline/history.c:
  Auto merged
cmd-line-utils/readline/readline.c:
  Auto merged
cmd-line-utils/readline/text.c:
  Auto merged
dbug/user.r:
  Auto merged
extra/yassl/src/handshake.cpp:
  Auto merged
include/config-win.h:
  Auto merged
include/m_string.h:
  Auto merged
include/my_global.h:
  Auto merged
include/my_pthread.h:
  Auto merged
include/mysql/plugin.h:
  Auto merged
include/mysql_com.h:
  Auto merged
include/thr_alarm.h:
  Auto merged
libmysql/CMakeLists.txt:
  Auto merged
libmysql/Makefile.shared:
  Auto merged
libmysql/dll.c:
  Auto merged
libmysql/get_password.c:
  Auto merged
libmysql/libmysql.c:
  Auto merged
libmysqld/Makefile.am:
  Auto merged
mysql-test/lib/mtr_cases.pl:
  Auto merged
mysql-test/mysql-test-run.pl:
  Auto merged
mysql-test/r/alter_table.result:
  Auto merged
mysql-test/r/change_user.result:
  Auto merged
mysql-test/r/create.result:
  Auto merged
mysql-test/r/innodb.result:
  Auto merged
mysql-test/r/merge.result:
  Auto merged
mysql-test/r/mix2_myisam.result:
  Auto merged
mysql-test/r/mysqldump.result:
  Auto merged
mysql-test/r/query_cache.result:
  Auto merged
mysql-test/r/subselect.result:
  Auto merged
mysql-test/valgrind.supp:
  Auto merged
mysql-test/r/view.result:
  Auto merged
mysql-test/suite/rpl/r/rpl_events.result:
  Auto merged
mysql-test/suite/rpl/t/rpl_switch_stm_row_mixed.test:
  Auto merged
mysql-test/t/create.test:
  Auto merged
mysql-test/t/mysqldump.test:
  Auto merged
mysql-test/t/query_cache.test:
  Auto merged
mysql-test/t/subselect.test:
  Auto merged
mysql-test/t/variables.test:
  Auto merged
mysql-test/t/view.test:
  Auto merged
mysys/mf_iocache.c:
  Auto merged
mysys/mf_tempfile.c:
  Auto merged
mysys/my_atomic.c:
  Auto merged
mysys/my_bit.c:
  Auto merged
mysys/my_bitmap.c:
  Auto merged
mysys/my_compress.c:
  Auto merged
mysys/my_create.c:
  Auto merged
mysys/my_delete.c:
  Auto merged
mysys/my_error.c:
  Auto merged
mysys/my_init.c:
  Auto merged
mysys/my_open.c:
  Auto merged
mysys/my_realloc.c:
  Auto merged
mysys/my_rename.c:
  Auto merged
mysys/my_symlink.c:
  Auto merged
mysys/my_sync.c:
  Auto merged
mysys/my_thr_init.c:
  Auto merged
mysys/thr_alarm.c:
  Auto merged
mysys/thr_lock.c:
  Auto merged
scripts/make_binary_distribution.sh:
  Auto merged
server-tools/instance-manager/mysql_connection.cc:
  Auto merged
sql/CMakeLists.txt:
  Auto merged
sql/Makefile.am:
  Auto merged
sql/events.cc:
  Auto merged
sql/field.cc:
  Auto merged
sql/field.h:
  Auto merged
sql/filesort.cc:
  Auto merged
sql/gen_lex_hash.cc:
  Auto merged
sql/ha_ndbcluster.cc:
  Auto merged
sql/ha_partition.h:
  Auto merged
sql/handler.h:
  Auto merged
sql/item.cc:
  Auto merged
sql/item.h:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/item_func.h:
  Auto merged
sql/item_strfunc.cc:
  Auto merged
sql/item_strfunc.h:
  Auto merged
sql/item_subselect.cc:
  Auto merged
sql/lock.cc:
  Auto merged
sql/log.cc:
  Auto merged
sql/log_event.cc:
  Auto merged
sql/net_serv.cc:
  Auto merged
sql/opt_range.cc:
  Auto merged
sql/partition_info.cc:
  Auto merged
sql/rpl_injector.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/slave.cc:
  Auto merged
sql/slave.h:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_acl.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_cache.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_delete.cc:
  Auto merged
sql/sql_load.cc:
  Auto merged
sql/sql_plugin.cc:
  Auto merged
sql/sql_prepare.cc:
  Auto merged
sql/sql_repl.cc:
  Auto merged
sql/sql_test.cc:
  Auto merged
sql/sql_union.cc:
  Auto merged
sql/sql_update.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/table.cc:
  Auto merged
sql/table.h:
  Auto merged
sql/unireg.cc:
  Auto merged
sql/share/errmsg.txt:
  Auto merged
storage/csv/ha_tina.cc:
  Auto merged
storage/csv/ha_tina.h:
  Auto merged
storage/myisam/CMakeLists.txt:
  Auto merged
storage/myisam/ft_boolean_search.c:
  Auto merged
storage/myisam/ft_eval.c:
  Auto merged
storage/myisam/ft_nlq_search.c:
  Auto merged
storage/myisam/ft_parser.c:
  Auto merged
storage/myisam/ft_static.c:
  Auto merged
storage/myisam/ft_stopwords.c:
  Auto merged
storage/myisam/ft_test1.c:
  Auto merged
storage/myisam/ft_update.c:
  Auto merged
storage/myisam/ha_myisam.cc:
  Auto merged
storage/myisam/mi_check.c:
  Auto merged
storage/myisam/mi_create.c:
  Auto merged
storage/myisam/mi_delete.c:
  Auto merged
storage/myisam/mi_delete_all.c:
  Auto merged
storage/myisam/mi_dynrec.c:
  Auto merged
storage/myisam/mi_key.c:
  Auto merged
storage/myisam/mi_packrec.c:
  Auto merged
storage/myisam/mi_range.c:
  Auto merged
storage/myisam/mi_search.c:
  Auto merged
storage/myisam/mi_test1.c:
  Auto merged
storage/myisam/mi_test2.c:
  Auto merged
storage/myisam/mi_test3.c:
  Auto merged
storage/myisam/mi_unique.c:
  Auto merged
storage/myisam/mi_write.c:
  Auto merged
storage/myisam/myisamchk.c:
  Auto merged
storage/myisam/myisamdef.h:
  Auto merged
storage/myisam/myisampack.c:
  Auto merged
storage/myisam/sort.c:
  Auto merged
storage/myisam/sp_test.c:
  Auto merged
support-files/mysql.spec.sh:
  Auto merged
tests/mysql_client_test.c:
  Auto merged
configure.in:
  Manual merge
dbug/dbug.c:
  Restore to original state in Maria tree
  The big diff comes from a wrong pull from 5.0 -> 5.1 after backporting dbug to 5.0 from 5.1
include/Makefile.am:
  Manual merge
include/my_atomic.h:
  Ignore changes
include/my_base.h:
  Manual merge
include/my_dbug.h:
  Use orginal my_dbug.h from maria tree
include/my_handler.h:
  Manual merge
include/my_sys.h:
  Manual merge
include/myisam.h:
  Manual merge
mysql-test/lib/mtr_report.pl:
  Manual merge
mysql-test/r/myisam.result:
  Manual merge
mysql-test/suite/binlog/r/binlog_unsafe.result:
  Manual merge
mysql-test/suite/binlog/t/binlog_unsafe.test:
  Manual merge
mysql-test/suite/rpl/r/rpl_row_flsh_tbls.result:
  Manual merge
mysql-test/suite/rpl/r/rpl_switch_stm_row_mixed.result:
  No changes
mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test:
  Manual merge
mysql-test/t/change_user.test:
  Manual merge
mysql-test/t/disabled.def:
  Manual merge
mysql-test/t/merge.test:
  No changes
mysql-test/t/myisam.test:
  Manual merge
mysys/Makefile.am:
  Manual merge
mysys/array.c:
  Manual merge
mysys/mf_keycache.c:
  Manual merge
mysys/my_getsystime.c:
  Manual merge
mysys/my_handler.c:
  Manual merge
mysys/my_pread.c:
  Manual merge
mysys/safemalloc.c:
  Manual merge
sql/ha_partition.cc:
  Manual merge
sql/handler.cc:
  Manual merge
sql/lex.h:
  Manual merge
sql/mysql_priv.h:
  Manual merge
sql/mysqld.cc:
  Manual merge
sql/set_var.h:
  Manual merge
sql/sql_class.cc:
  Manual merge
sql/sql_insert.cc:
  Manual merge
sql/sql_parse.cc:
  Manual merge
sql/sql_select.cc:
  Manual merge
sql/sql_show.cc:
  Manual merge
sql/sql_table.cc:
  Manual merge
storage/myisam/mi_checksum.c:
  No changes
storage/myisam/mi_extra.c:
  Manual merge
storage/myisam/mi_open.c:
  Manual merge
storage/myisammrg/ha_myisammrg.cc:
  Manual merge
strings/strmake.c:
  No changes
2008-04-28 19:24:05 +03:00
unknown
bf9bb656a6 Bug#34424 query_cache_debug.test leads to valgrind warnings
Bug#34678 @@debug variable's incremental mode

The problem is that the per-thread debugging settings stack wasn't
being deallocated before the thread termination, leaking the stack
memory. The chosen solution is to push a new state if the current
is set to the initial settings and pop it (free) once the thread
finishes.


dbug/dbug.c:
  Move dbug parser out of _db_set_ to a separate function and
  make _db_set_ push a new stack if the corrent one is set to
  the initial settings.
dbug/user.r:
  Update DBUG_SET description.
mysql-test/t/disabled.def:
  Re-enable test case which triggered the leak.
mysys/my_thr_init.c:
  Pop a pushed state, nop if stack is empty.
sql/set_var.cc:
  Handle incremental debug settings.
mysql-test/r/variables_debug.result:
  Add new test case result for Bug#34678
mysql-test/t/variables_debug.test:
  Add new test case for Bug#34678
2008-02-26 12:03:59 -03:00