Commit graph

2345 commits

Author SHA1 Message Date
Dmitry Lenev
dfa2acb141 Fix for bug #45143 "All connections hang on concurrent ALTER TABLE".
Concurrent execution of statements which require non-table-level
write locks on several instances of the same table (such as
SELECT ... FOR UPDATE which uses same InnoDB table twice or a DML
statement which invokes trigger which tries to update same InnoDB
table directly and through stored function) and statements which
required table-level locks on this table (e.g. LOCK TABLE ... WRITE,
ALTER TABLE, ...) might have resulted in a deadlock.

The problem occured when a thread tried to acquire write lock
(TL_WRITE_ALLOW_WRITE) on the table but had to wait since there was
a pending write lock (TL_WRITE, TL_WRITE_ALLOW_READ) on this table
and we failed to detect that this thread already had another instance
of write lock on it (so in fact we were trying to acquire recursive
lock) because there was also another thread holding write lock on the
table (also TL_WRITE_ALLOW_WRITE). When the latter thread released
its lock neither the first thread nor the thread trying to acquire
TL_WRITE/TL_WRITE_ALLOW_READ were woken up (as table was still write
locked by the first thread) so we ended up with a deadlock.

This patch solves this problem by ensuring that thread which
already has write lock on the table won't wait when it tries
to acquire second write lock on the same table.
2009-10-26 22:38:03 +03:00
Alexander Barkov
344ddc85fa Merging mysql-next-mr-merge to mysql-next-mr. 2009-10-21 15:48:22 +05:00
Alexander Nozdrin
3fd2f50b6c Merge from mysql-trunk-merge. 2009-10-19 17:36:19 +04:00
Alexander Nozdrin
b930b18ec3 Merge from mysql-5.1. 2009-10-19 17:28:31 +04:00
Alexander Nozdrin
f3457a73d6 Merge from mysql-5.1. 2009-10-19 17:17:08 +04:00
Joerg Bruehe
5c95f2363a Upmerge the Windows compile fix from 5.0 to 5.1 2009-10-16 15:05:52 +02:00
Joerg Bruehe
9ceeabd9b2 Compile fix for Windows:
Use "#ifdef", not plain "#if".
2009-10-16 14:06:33 +02:00
Sergey Glukhov
7741d9b50d WL#751 Error message construction, backport 2009-10-15 17:23:43 +05:00
Alexander Barkov
f8a54c72ff Backporting WL#4164 Two-byte collation IDs 2009-10-15 15:17:32 +05:00
Alexander Nozdrin
ca08f10ccd Manual merge from mysql-trunk-merge. 2009-10-14 12:25:39 +04:00
Alexander Nozdrin
32e51de7f5 Merge from mysql-5.1. 2009-10-14 11:17:49 +04:00
Alexander Nozdrin
0f51423532 Merge from mysql-5.1. 2009-10-13 13:42:38 +04:00
Joerg Bruehe
7a69adf492 Upmerge (automerge) into 5.1 2009-10-09 15:21:45 +02:00
Alexander Nozdrin
84510f0375 Merge from mysql-next-mr. 2009-10-09 17:09:16 +04:00
Joerg Bruehe
5184530308 Fix bug#47923 New "mf_keycache.c" requires thread support
The bug is a compilation issue:
Function "find_key_block()" had thread operations
which were not guarded by "#if THREAD", add that now.
2009-10-08 21:58:17 +02:00
Alexander Nozdrin
f4d27e81bb Merge from mysql-next-mr. 2009-10-08 11:42:38 +04:00
Magnus Blåudd
b64dbeed6e Bug#47857 strip_sp function in mysys/mf_strip.c never used and cause name clash
- Remove mf_strip.c and the declaration of 'strip_sp'
2009-10-06 13:04:51 +02:00
Alexander Barkov
a16a82d4eb Bsckporting WL#3764 Sinhala Collation
modified:
  mysql-test/r/ctype_utf8.result
  mysql-test/t/ctype_utf8.test
  mysys/charset-def.c
  strings/ctype-uca.c
2009-10-06 15:34:49 +05:00
Kristofer Pettersson
499121a080 Automerg 2009-10-06 09:40:30 +02:00
Kristofer Pettersson
dfed28e750 Bug#47768 pthread_cond_timedwait() is broken on windows
The pthread_cond_wait implementations for windows might
dead lock in some rare circumstances.

1) One thread (I) enter a timed wait and at a point in
   time ends up after mutex unlock and before
   WaitForMultipleObjects(...)
2) Another thread (II) enters pthread_cond_broadcast.
   Grabs the mutex and discovers one waiter. It set
   the broadcast event and closes the broadcast gate
   then unlocks the mutex.
3) A third thread (III) issues a pthread_cond_signal.
   It grabs the mutex, discovers one waiter, sets the
   signal event then unlock the mutex.
4) The first threads (I) enters WaitForMultipleObjects
   and finds out that the signal object is in a
   signalled state and exits the wait.
5) Thread (I) grabs the mutex and checks result status.
   The number of waiters is decreased and becomes equal
   to 0. The event returned was a signal event so the
   broadcast gate isn't opened. The mutex is released.
6) Thread (II) issues a new broadcast. The mutex is
   acquired but the number of waiters are 0 hence
   the broadcast gate remains closed.
7) Thread (I) enters the wait again but is blocked by
   the broadcast gate.

      This fix resolves the above issue by always resetting
      broadcast gate when there are no more waiters in th queue.
2009-10-06 09:38:44 +02:00
Georgi Kodinov
db35fb7961 automerge 2009-10-04 12:15:05 +03:00
Alexander Nozdrin
8e0204fb58 Merge from mysq-next-mr-wtf. 2009-10-02 16:14:59 +04:00
Ingo Struewing
0c522f7453 auto-merge 2009-10-01 15:54:11 +02:00
Joerg Bruehe
de0285a2e5 Merge "trunk-build" up into "next-mr". 2009-09-30 22:31:22 +02:00
Vladislav Vaintroub
6e6b84fd02 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
9cf8d12c85 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
2801599323 Backport http://lists.mysql.com/commits/57778
2677 Vladislav Vaintroub	2008-11-04
CMakeLists.txt files cleanup
- remove SAFEMALLOC and SAFE_MUTEX definitions that were 
present in *each* CMakeLists.txt. Instead, put them into top level 
CMakeLists.txt, but disable on Windows, because
a) SAFEMALLOC does not add any functionality that is not already
present in Debug C runtime ( and 2 safe malloc one on top of the other 
only unnecessarily slows down the server) 
      
b)SAFE_MUTEX does not work on Windows  and have been
explicitely  disabled on Windows with #undef previously.  Fortunately,
ntdll does  pretty good  job identifying l problems with 
CRITICAL_SECTIONs.
DebugBreak()s on using uninited critical section, unlocking unowned 
critical section)
      
-Also, remove occationally used -D_DEBUG (added by compiler 
anyway)
2009-09-30 15:35:01 +02:00
Alexander Barkov
482d3bfd80 Backporting WL#3759 Optimize identifier conversion in client-server protocol
This patch provides performance improvements:
- send_fields() when character_set_results = latin1
  is now about twice faster for column/table/database
  names, consisting on ASCII characters.

Changes:

- Protocol doesn't use "convert" temporary buffer anymore,
  and converts strings directly to "packet".

- General conversion optimization: quick conversion
  of ASCII strings was added.

modified files:

include/m_ctype.h
- Adding a new flag.
- Adding a new function prototype

libmysqld/lib_sql.cc
- Adding quick conversion method for embedded library:
  conversion is now done directly to result buffer,
  without using a temporary buffer.

mysys/charset.c
- Mark all dynamic ucs2 character sets as non-ASCII
- Mark some dymamic 7bit and 8bit charsets as non-ASCII
  (for example swe7 is not fully ASCII compatible).

sql/protocol.cc
- Adding quick method to convert a string directly
  into protocol buffer, without using a temporary buffer.

sql/protocol.h
- Adding a new method prototype

sql/sql_string.cc
  Optimization for conversion between two ASCII-compatible charsets:
- quickly convert ASCII strings,
  switch to mc_wc->wc_mb method only when a non-ASCII character is met.
- copy four ASCII characters at once on i386

strings/conf_to_src.c
- Marking non-ASCII character sets with a flag.

strings/ctype-extra.c
- Regenerating ctype-extra.c by running "conf_to_src".

strings/ctype-uca.c
- Marking UCS2 character set as non-ASCII.

strings/ctype-ucs2.c
- Marking UCS2 character set as non-ASCII.

strings/ctype.c
- A new function to detect if a 7bit or 8bit character set
  is ascii compatible.
2009-09-30 10:09:28 +05:00
Vladislav Vaintroub
46d04ebdef Backport of the patch
http://lists.mysql.com/commits/57725

Vladislav Vaintroub	2008-11-03
Cleanup CMakeLists.txt(s) - remove winsock2 (ws2_32) from 
TARGET_LINK_LIBRARIES. 
      
Every exe or dll linked with mysys needs ws2_32, because
mysys uses winsock function WSAStartup in my_init().
However, there is no need to explicitely add ws2_32 to
the list of TARGET_LINK_LIBRARIES multiple times. 
Visual Studio comes with a handy pragma that tells linker
to add library. So patch replaces bunch of ws2_32 in 
CMakeLists with  single pragma comment(lib,"ws2_32")
in my_init.c
      
Additionally, reference to non-existing "debug" library
has been removed from TARGET_LINK_LIBRARIES. The correct
name of the library is "dbug".
2009-09-30 03:39:37 +02:00
Vladislav Vaintroub
e6090f10bb 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
Ingo Struewing
21586dfb08 WL#4259 - Debug Sync Facility
Backport from 6.0 to 5.1.
Only those sync points are included, which are used in debug_sync.test.

  The Debug Sync Facility allows to place synchronization points
  in the code:
  
  open_tables(...)
  
  DEBUG_SYNC(thd, "after_open_tables");
  
  lock_tables(...)
  
  When activated, a sync point can
  
  - Send a signal and/or
  - Wait for a signal
  
  Nomenclature:
  
  - signal:            A value of a global variable that persists
                       until overwritten by a new signal. The global
                       variable can also be seen as a "signal post"
                       or "flag mast". Then the signal is what is
                       attached to the "signal post" or "flag mast".
  
  - send a signal:     Assign the value (the signal) to the global
                       variable ("set a flag") and broadcast a
                       global condition to wake those waiting for
                       a signal.
  
  - wait for a signal: Loop over waiting for the global condition until
                       the global value matches the wait-for signal.
  
  Please find more information in the top comment in debug_sync.cc
  or in the worklog entry.
2009-09-29 17:38:40 +02:00
Magnus Blåudd
0b4b556911 Merge bug#42850 to 5.1 2009-09-28 14:40:45 +02:00
Magnus Blåudd
56b7b74b25 Merge bug#42850 to 5.0 2009-09-28 14:38:06 +02:00
Joerg Bruehe
650e68b7dc Merge 5.1-build up into 5.4-build ("trunk-build"). 2009-09-28 11:39:36 +02:00
Vladislav Vaintroub
281909362c merge mysql-next-mr-alik 2009-09-24 12:35:16 +02:00
Magnus Blåudd
40bd549b9b 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
Vladislav Vaintroub
ff3acc311f merge 2009-09-23 22:19:11 +02:00
Vladislav Vaintroub
47fedb97b4 merge 2009-09-23 22:15:22 +02:00
Marc Alff
66ba77336a Merge mysql-next-mr (revno 2880) --> mysql-trunk-signal 2009-09-20 22:50:05 -06:00
Magnus Blåudd
f66231be11 Merge bug#42850 to 5.0 2009-09-28 14:40:20 +02:00
Alexey Kopytov
ddd00a7771 Automerge. 2009-09-18 11:54:38 +04:00
Alexey Kopytov
d39f0a72ad Bug #43606: 4GB Limit on huge_pages shared memory set-up
Large pages allocator could not allocate more than 4 GB due to
incorrect size alignment.
2009-09-18 11:19:02 +04:00
Alexander Nozdrin
5b3f34f41e Merge 5.1-bugteam -> trunk-alik. 2009-09-17 22:00:49 +04:00
Joerg Bruehe
67bcf54df6 Fix bug#46980
Option "--without-server" still not working in 5.1

The general approach is to make sure that source files
which require thread support are only compiled if the build
really needs thread support,
which means when the server is built or a thread-safe client
library.

This required several changes:
- Make sure the subdirectories "storage/" and "plugin/" are
  only processed if the server is built, not ifclient-only.
- Make the compilation of some modules which inherently
  require threading depend on thread supportin the build.
- Separate the handling of threading in "configure.in" from
  that of server issues, threading is also needed in a
  non-server build of a thread-safe client library.

Also, "libdbug" must get built even in a client-only build,
so "dbug/" must be in the list of client directories.

In addition, calls to thread functions in source files which
can be built without thread support must use the wrapper
functions which handle the non-threaded build.
So the modules "client/mysqlimport.c" and "client/mysqlslap.c"
must call "my_thread_end()" only via "mysql_thread_end()".
2009-09-17 18:34:24 +02:00
Staale Smedseng
5051100a1a Merge from 5.0 2009-09-17 17:25:52 +02:00
Staale Smedseng
38b6d49e82 Bug #43414 Parenthesis (and other) warnings compiling MySQL
with gcc 4.3.2
      
This is the fifth patch cleaning up more GCC warnings about
variables used before initialized using the new macro
UNINIT_VAR().
2009-09-17 17:10:30 +02:00
Marc Alff
08ffe21317 Merge mysql-next-mr --> mysql-trunk-signal 2009-09-17 03:20:11 -06:00
Alexander Nozdrin
df0dcab437 Merge from mysql-5.1-bugteam. 2009-09-16 10:52:43 +04:00
Vladislav Vaintroub
b5f83da900 fix compile error. definition of VOID in trunk still conflicts with windows headers. that was fixed in 6.0 2009-09-13 19:38:06 +02:00
Vladislav Vaintroub
72b91d4134 Downport
WL#1624 -determine MAC addresses on Windows.
Contribution  by Chris Runyan
2009-09-11 22:42:39 +02:00