Commit graph

66912 commits

Author SHA1 Message Date
Jon Olav Hauglid
a53f61e6e8 Merge from mysql-5.5-bugteam to mysql-5.5-runtime 2010-09-30 12:43:43 +02:00
Georgi Kodinov
c70a6f5c23 merge 2010-09-29 18:22:40 +03:00
Georgi Kodinov
216418e7b2 merge 2010-09-29 17:26:32 +03:00
Dmitry Lenev
49406b97df A better fix for bug #56405 "Deadlock in the MDL deadlock
detector" that doesn't introduce bug #56715 "Concurrent
transactions + FLUSH result in sporadical unwarranted
deadlock errors".

Deadlock could have occurred when workload containing a mix
of DML, DDL and FLUSH TABLES statements affecting the same
set of tables was executed in a heavily concurrent environment.

This deadlock occurred when several connections tried to
perform deadlock detection in the metadata locking subsystem.
The first connection started traversing wait-for graph,
encountered a sub-graph representing a wait for flush, acquired
LOCK_open and dived into sub-graph inspection. Then it
encountered sub-graph corresponding to wait for metadata lock
and blocked while trying to acquire a rd-lock on
MDL_lock::m_rwlock, since some,other thread had a wr-lock on it.
When this wr-lock was released it could have happened (if there
was another pending wr-lock against this rwlock) that the rd-lock
from the first connection was left unsatisfied but at the same
time the new rd-lock request from the second connection sneaked
in and was satisfied (for this to be possible the second
rd-request should come exactly after the wr-lock is released but
before pending the wr-lock manages to grab rwlock, which is
possible both on Linux and in our own rwlock implementation).
If this second connection continued traversing the wait-for graph
and encountered a sub-graph representing a wait for flush it tried
to acquire LOCK_open and thus the deadlock was created.

The previous patch tried to workaround this problem by not
allowing the deadlock detector to lock LOCK_open mutex if
some other thread doing deadlock detection already owns it
and current search depth is greater than 0. Instead deadlock
was reported. As a result it has introduced bug #56715.

This patch solves this problem in a different way.
It introduces a new rw_pr_lock_t implementation to be used
by MDL subsystem instead of one based on Linux rwlocks or
our own rwlock implementation. This new implementation
never allows situation in which an rwlock is rd-locked and
there is a blocked pending rd-lock. Thus the situation which
has caused this bug becomes impossible with this implementation.

Due to fact that this implementation is optimized for
wr-lock/unlock scenario which is most common in the MDL
subsystem it doesn't introduce noticeable performance
regressions in sysbench tests. Moreover it significantly
improves situation for POINT_SELECT test when many
connections are used.

No test case is provided as this bug is very hard to repeat
in MTR environment but is repeatable with the help of RQG
tests.
This patch also doesn't include a test for bug #56715
"Concurrent transactions + FLUSH result in sporadical
unwarranted deadlock errors" as it takes too much time to
be run as part of normal test-suite runs.
2010-09-29 16:09:07 +04:00
Vladislav Vaintroub
bc684baba2 Rename CMAKE_PARSE_ARGUMENTS macro to avoid name collision
with CMake 2.8.3 builtin macro
2010-09-29 11:42:35 +02:00
Jon Olav Hauglid
4228b8bbdd Followup to Bug#46165 server crash in dbug
This patch moves the regression test from variables.test to
variables_debug.test as the debug system variable is not 
available on release builds.
2010-09-29 10:07:56 +02:00
Alexander Nozdrin
76f4cfde66 Empty merge from mysql-5.5. 2010-09-28 19:42:45 +04:00
Alexander Nozdrin
fab555ce76 Auto-merge from mysql-5.5-merge. 2010-09-28 19:34:59 +04:00
Alexander Nozdrin
a79093cd94 Auto-merge from mysql-5.5-merge. 2010-09-28 19:15:58 +04:00
Jon Olav Hauglid
92b247814a Bug #46165 server crash in dbug
This crash occured if the same debug trace file was closed twice,
leading to the same memory being free'd twice. This could occur
if the "debug" server system variable refered to the same trace
file in both global and session scope.

Example of an order of events that would lead to a crash:
1) Enable debug tracing to a trace file (global scope)
2) Enable debug tracing to the same trace file (session scope)
3) Reset debug settings (global scope)
4) Reset debug settings (session scope)

This caused a crash because the trace file was, by mistake, closed
in 3), leading to the same memory being free'd twice when the file
was closed again in 4).

Internally, the debug settings are stored in a stack, with session
settings (if any) on top and the global settings below. Each connection
has its own stack. When a set of settings is changed, it must be 
determined if its debug trace file is to be closed. Before, this was done
by only checking below on the settings stack. So if the global settings
were changed, an existing debug trace file reference in session settings
would be missed. This caused the file to be closed even if it was in use,
leading to a crash later when it was closed again.

This patch fixes the problem by preventing the trace file from being shared
between global and session settings. If session debug settings are set without
specifying a new trace file, stderr is used for output. This is a change
in behaviour and should be reflected in the documentation.

Test case added to variables.test.
2010-09-28 11:07:58 +02:00
Alexey Botchkov
4a2dd398e2 log_tables_debug.test fix.
per-file comments:
  mysql-test/t/log_tables_debug.test
        This test shouldn't be run at the embedded server.
2010-09-27 15:18:10 +05:00
Marc Alff
6a707718b9 Added missing paterns 2010-09-27 18:23:54 -06:00
Davi Arnaut
657f07151a Merge of mysql-5.1-bugteam into mysql-5.5-merge. 2010-09-24 19:19:30 -03:00
Davi Arnaut
d47e8991cb Bug#45288: pb2 returns a lot of compilation warnings on linux
Use UNINIT_VAR workaround instead of LINT_INIT. The former can
also be used to silence false-positives in non-debug builds as
it actually does not cause new code to be generated.
2010-09-24 19:13:51 -03:00
Davi Arnaut
5713e1398c Bug#45288: pb2 returns a lot of compilation warnings on linux
Use UNINIT_VAR workaround instead of LINT_INIT. The former is
also used in non-debug builds as it doesn't cause changes.
2010-09-24 17:04:36 -03:00
Dmitry Lenev
afa568c24b Fix compile warning about passing NULL to non-pointer
argument of inline_mysql_mutex_init in sql_base.cc.

When initializing LOCK_dd_owns_lock_open mutex pass
correct PSI key instead of NULL value.
2010-09-24 20:26:24 +04:00
Konstantin Osipov
5b06699029 Merge 5.5 -> 5.5-merge. 2010-09-24 17:18:45 +04:00
Davi Arnaut
2044c80745 Merge of mysql-5.1-bugteam into mysql-5.5-merge. 2010-09-24 10:03:17 -03:00
Davi Arnaut
77a0ae9a9a Bug#45288: pb2 returns a lot of compilation warnings on linux
Temporarily disable strict aliasing warnings in order to get
wider coverage for optimized builds. Once the violations are
fixed and false-positives silenced, this flag should be removed.
2010-09-24 09:36:31 -03:00
Dmitry Shulga
e1b299ed02 Merged changes from 5.1-bugteam for bug#42503. 2010-09-24 19:12:09 +07:00
Dmitry Shulga
f14d8c2896 Follow-up for Bug#42503: fix a compilation warning. 2010-09-24 19:03:28 +07:00
Jon Olav Hauglid
71affc142d Bug #56678 Valgrind warnings from binlog.binlog_unsafe
After the patch for Bug#54579, multi inserts done with INSERT DELAYED
are binlogged as normal INSERT. During processing of the statement,
a new query string without the DELAYED keyword is made. The problem
was that this new string was incorrectly made when the INSERT DELAYED
was part of a prepared statement - data was read outside the allocated
buffer.

The reason for this bug was that a pointer to the position of the
DELAYED keyword inside the query string was stored when parsing the
statement. This pointer was then later (at runtime) used (via pointer
subtraction) to find the number of characters to skip when making a
new query string without DELAYED. But when the statement was re-executed
as part of a prepared statement, the original pointer would be invalid
and the pointer subtraction would give a wrong/random result.

This patch fixes the problem by instead storing the offsets from the
beginning of the query string to the start and end of the DELAYED 
keyword. These values will not depend on the memory position
of the query string at runtime and therefore not give wrong results
when the statement is executed in a prepared statement.

This bug was a regression introduced by the patch for Bug#54579.

No test case added as this bug is already covered by the existing
binlog.binlog_unsafe test case when running with valgrind.
2010-09-24 10:44:09 +02:00
Jon Olav Hauglid
11c4d8ba1f Bug #54920 Stored functions are allowed in HANDLER statements,
but broken.

Before this patch, it was allowed to use stored functions in
HANDLER ... READ statements. The problem was that this functionality
was not really supported by the code. Proper locking would for example
not be performed, and it was also possible to break replication by
having stored functions that performed updates.

This patch disallows the use of stored functions in HANDLER ... READ.
Any such statement will now give an ER_NOT_SUPPORTED_YET error.
This is an incompatible change and should be reflected in the
documentation.

Test case added to handler_myisam/handler_innodb.test.
2010-09-24 09:18:16 +02:00
Jon Olav Hauglid
4ecf1d32ac Merge from mysql-5.5-bugfixing to mysql-5.5-runtime. 2010-09-24 08:46:43 +02:00
Mats Kindahl
246b7b0b7d Merging into mysql-5.5-bugfixing. 2010-09-23 14:38:24 +02:00
Jon Olav Hauglid
9b9299f8d5 Followup to Bug #56422 CHECK TABLE run when the table is locked
reports corruption along with timeout

This patch updates the result file for the
parts.partition_special_innodb test case which was, by mistake,
not updated in the original patch.
2010-09-23 11:13:21 +02:00
Dmitry Shulga
7cc604561c Auto-merge from mysql-5.1-bugteam for bug#56821. 2010-09-22 20:11:40 +07:00
Dmitry Shulga
c7ccc7265e Fixed bug#56821 - failure to start the MySQL Service. 2010-09-22 19:53:06 +07:00
Jon Olav Hauglid
5d06dddff3 Bug #56494 Segfault in upgrade_shared_lock_to_exclusive() for
REPAIR of merge table
Bug #56422 CHECK TABLE run when the table is locked reports
           corruption along with timeout

The crash happened if a table maintenance statement (ANALYZE TABLE,
REPAIR TABLE, etc.) was executed on a MERGE table and opening and 
locking a child table failed. This could for example happen if a child
table did not exist or if a lock timeout happened while waiting for
a conflicting metadata lock to disappear.

Since opening and locking the MERGE table and its children failed,
the tables would be closed and the metadata locks released.
However, TABLE_LIST::table for the MERGE table would still be set,
with its value invalid since the tables had been closed.
This caused the table maintenance statement to try to continue
and upgrade the metadata lock on the MERGE table. But since the lock
already had been released, this caused a segfault.

This patch fixes the problem by setting TABLE_LIST::table to NULL 
if open_and_lock_tables() fails. This prevents maintenance
statements from continuing and trying to upgrade the metadata lock.

The patch includes a 5.5 version of the fix for
Bug #46339 crash on REPAIR TABLE merge table USE_FRM.
This bug caused REPAIR TABLE ... USE_FRM to give an assert 
when used on merge tables.

The patch also enables the CHECK TABLE statement for log tables.
Before, CHECK TABLE for log tables gave ER_CANT_LOCK_LOG_TABLE,
yet still counted the statement as successfully executed.
With the changes to table maintenance statement error handling
in this patch, CHECK TABLE would no longer be considered as
successful in this case. This would have caused upgrade scripts
to mistakenly think that the general and slow logs are corrupted
and have to be repaired. Enabling CHECK TABLES for log tables
prevents this from happening.

Finally, the patch changes the error message from "Corrupt" to
"Operation failed" for a number of issues not related to table
corruption. For example "Lock wait timeout exceeded" and 
"Deadlock found trying to get lock".

Test cases added to merge.test and check.test.
2010-09-22 10:15:41 +02:00
Mats Kindahl
48ac52a861 Merging into mysql-5.5-bugfixing. 2010-09-21 23:24:29 +02:00
Ingo Struewing
56d205c904 Bug#46339 - crash on REPAIR TABLE merge table USE_FRM
Null-merge from 5.1
2010-09-21 16:47:41 +02:00
Ingo Struewing
386d50478c Bug#46339 - crash on REPAIR TABLE merge table USE_FRM
Merge from saved bundle.
2010-09-21 16:37:18 +02:00
Evgeny Potemkin
cd8710fe8a Auto-merged. 2010-09-21 13:37:31 +04:00
Joerg Bruehe
9141bb5878 Merge 5.5.6-rc to the main tree. 2010-09-19 22:01:12 +02:00
Davi Arnaut
be348787eb Bug#52419: x86 assembly based atomic CAS causes test failures
The problem was that the x86 assembly based atomic CAS
(compare and swap) implementation could copy the wrong
value to the ebx register, where the cmpxchg8b expects
to see part of the "comparand" value. Since the original
value in the ebx register is saved in the stack (that is,
the push instruction causes the stack pointer to change),
a wrong offset could be used if the compiler decides to
put the source of the comparand value in the stack.

The solution is to copy the comparand value directly from
memory. Since the comparand value is 64-bits wide, it is
copied in two steps over to the ebx and ecx registers.
2010-09-17 17:34:15 -03:00
Alfranio Correia
c316b68146 merge mysql-5.1-bugteam --> mysql-5.5-merge 2010-09-17 21:22:34 +01:00
Marc Alff
fa4c505eda Bug#50557 checksum table crashes server when used in performance_schema
CHECKSUM TABLE for performance schema tables could cause uninitialized
memory reads.

The root cause is a design flaw in the implementation of
mysql_checksum_table(), which do not honor null fields.

However, fixing this bug in CHECKSUM TABLE is risky, as it can cause the
checksum value to change.

This fix implements a work around, to systematically reset fields values
even for null fields, so that the field memory representation is always
initialized with a known value.
2010-09-17 13:03:09 -06:00
Marc Alff
ba7dec4a2d local merge 2010-09-17 10:21:53 -06:00
Alfranio Correia
6baf9d5a61 merge mysql-5.1-bugteam (local) --> mysql-5.1-bugteam 2010-09-17 14:55:23 +01:00
Alfranio Correia
77dcf9bec7 merge mysql-5.5-bugfixing (local) --> mysql-5.5-bugfixing 2010-09-17 12:58:27 +01:00
Marc Alff
fd6497b3d8 Bug#56832 perfschema.server_init test output not consistent
Before this fix, the test output for perfschema.server_init would
vary between executions, because some of the objects tested were
not guaranteed to exist in all configurations / code paths.

This fix removes these weak tests.

Also, comments referring to abandonned code have been cleaned up.
2010-09-16 19:04:34 -06:00
Jon Olav Hauglid
1818165cdb Merge from mysql-5.5-bugfixing to mysql-5.5-runtime. 2010-09-16 16:16:29 +02:00
Dmitry Lenev
355b74d2a6 Fix for merge.test failures in mysql-5.5-runtime
tree for embedded server

Test case for bug #56251 "Deadlock with INSERT
DELAYED and MERGE tables" can't be run against
embedded server. Embedded server converts all
DELAYED INSERTs into ordinary INSERTs and this
test can't work properly if such conversion
happens.

Moved this test from merge.test to delayed.test
which is skipped if test suite is run with
--embedded-server option.
2010-09-16 18:06:46 +04:00
Sergey Glukhov
dcad3feb1c 5.1-bugteam->5.5-merge 2010-09-16 16:20:35 +04:00
Sergey Glukhov
86d7cbd450 Bug#50402 Optimizer producing wrong results when using Index Merge on InnoDB
Subselect executes twice, at JOIN::optimize stage
and at JOIN::execute stage. At optimize stage
Innodb prebuilt struct which is used for the
retrieval of column values is initialized in.
ha_innobase::index_read(), prebuilt->sql_stat_start is true.
After QUICK_ROR_INTERSECT_SELECT finished his job it
restores read_set/write_set bitmaps with initial values
and deactivates one of the handlers used by
QUICK_ROR_INTERSECT_SELECT in JOIN::cleanup
(it's the case when we reuse original handler as one of
 handlers required by QUICK_ROR_INTERSECT_SELECT object).
On second subselect execution inactive handler is activated
in  QUICK_RANGE_SELECT::reset, file->ha_index_init().
In ha_index_init Innodb prebuilt struct is reinitialized
with inappropriate read_set/write_set bitmaps. Further
reinitialization in ha_innobase::index_read() does not
happen as prebuilt->sql_stat_start is false.
It leads to partial retrieval of required field values
and we get a mix of field values from different records
in the record buffer.
The fix is to reset
read_set/write_set bitmaps as these values
are required for proper intialization of
internal InnoDB struct which is used for
the retrieval of column values
(see build_template(), ha_innodb.cc)
2010-09-16 16:13:53 +04:00
Magne Mahre
327eb7b680 Merge from 5.1-bugteam 2010-09-16 13:00:53 +02:00
Magne Mahre
f43d6c2b73 Bug #54606 innodb fast alter table + pack_keys=0 prevents
adding new indexes

A fast alter table requires that the existing (old) table
and indices are unchanged (i.e only new indices can be
added).  To verify this, the layout and flags of the old
table/indices are compared for equality with the new.

The PACK_KEYS option is a no-op in InnoDB, but the flag
exists, and is used in the table compare.  We need to
check this (table) option flag before deciding whether an 
index should be packed or not.  If the table has
explicitly set PACK_KEYS to 0, the created indices should
not be marked as packed/packable.
2010-09-16 12:51:08 +02:00
Dmitry Shulga
a684f8df20 Auto-merge from mysql-5.1-bugteam for bug#42503. 2010-09-16 17:38:13 +07:00
Dmitry Shulga
be794bc5eb Fixed bug#42503 - "Lost connection" errors when using
compression protocol.

The loss of connection was caused by a malformed packet
sent by the server in case when query cache was in use.
When storing data in the query cache, the query  cache
memory allocation algorithm had a tendency to reduce
the amount of memory block necessary to store a result
set, up to finally storing the entire result set in a single
block. With a significant result set, this memory block
could turn out to be quite large - 30, 40 MB and on.
When such a result set was sent to the client, the entire
memory block was compressed and written to network as a
single network packet. However, the length of the
network packet is limited by 0xFFFFFF (16MB), since
the packet format only allows 3 bytes for packet length.
As a result, a malformed, overly large packet
with truncated length would be sent to the client
and break the client/server protocol.

The solution is, when sending result sets from the query
cache, to ensure that the data is chopped into
network packets of size <= 16MB, so that there
is no corruption of packet length. This solution,
however, has a shortcoming: since the result set
is still stored in the query cache as a single block,
at the time of sending, we've lost boundaries of individual
logical packets (one logical packet = one row of the result
set) and thus can end up sending a truncated logical
packet in a compressed network packet.

As a result, on the client we may require more memory than 
max_allowed_packet to keep, both, the truncated
last logical packet, and the compressed next packet.
This never (or in practice never) happens without compression,
since without compression it's very unlikely that
a) a truncated logical packet would remain on the client
when it's time to read the next packet
b) a subsequent logical packet that is being read would be
so large that size-of-new-packet + size-of-old-packet-tail >
max_allowed_packet.
To remedy this issue, we send data in 1MB sized packets,
that's below the current client default of 16MB for
max_allowed_packet, but large enough to ensure there is no
unnecessary overhead from too many syscalls per result set.
2010-09-16 17:24:27 +07:00
Jon Olav Hauglid
f14d947c98 Bug #56595 RENAME TABLE causes assert on OS X
The problem was that RENAME TABLE caused an assert if the system variable
lower_case_table_names was 2 (default on Mac OS X) and the old table name
was given in upper case. This caused lowercase_table2.test to fail.

The assert checks that an exclusive metadata lock is held by the connection
trying to do RENAME TABLE - specificially during updates of table triggers.
The assert was triggered since the check is case sensitive and the lock
was held on the normalized (lower case) version of the table name.

This patch fixes the problem by making sure a normalized version of the
table name is used for the metadata lock check, while using a non-normalized
version of the table name for the rename of trigger files. The same is done
for ALTER TABLE ... RENAME.

Regression testing for the bug itself is already covered by
lowercase_table2.test. Additional coverage added to lowercase_fs_off.test.
2010-09-16 11:11:13 +02:00