Commit graph

60593 commits

Author SHA1 Message Date
7e2078c995 Bug #49137 Replication failure on SBR/MBR + multi-table DROP TEMPORARY TABLE
Fixed valgrind failure on PB2.
2010-01-06 10:44:14 +08:00
cae9c79772 Bug #49137 Replication failure on SBR/MBR + multi-table DROP TEMPORARY TABLE
Fixed valgrind failure on PB2.
2010-01-06 10:36:29 +08:00
Luis Soares
4923b4157c BUG#50018: binlog corruption when table has many columns
For tables with metadata sizes ranging from 251 to 255 the size
of the event data (m_data_size) was being improperly calculated
in the Table_map_log_event constructor. This was due to the fact
that when writing the Table_map_log_event body (in
Table_map_log_event::write_data_body) a call to net_store_length
is made for packing the m_field_metadata_size. It happens that
net_store_length uses *one* byte for storing
m_field_metadata_size when it is smaller than 251 but *three*
bytes when it exceeds that value. BUG 42749 had already
pinpointed and fix this fact, but the fix was incomplete, as the
calculation in the Table_map_log_event constructor considers 255
instead of 251 as the threshold to increment m_data_size by
three. Thence, the window for having a mismatch between the
number of bytes written and the number of bytes accounted in the
event length (m_data_size) was left open for
m_field_metadata_size values between 251 and 255.

We fix this by changing the condition in the Table_map_log_event
constructor to match the one in the net_store_length, ie,
increment one byte if m_field_metadata_size < 251 and three if it
exceeds this value.
2010-01-06 00:44:31 +00:00
Alfranio Correia
2e35289e32 merge 5.1-rep+3 --> 5.1-rep+2-delivery1 2010-01-05 17:35:33 +00:00
Alfranio Correia
a0946fa3d1 BUG#50038 Deadlock on flush logs with concurrent DML and RBR
In auto-commit mode, updating both trx and non-trx tables (i.e. issuing a mixed
statement) causes the following sequence of events:

1 - "Flush trx changes" (MYSQL_BIN_LOG::write) - T1:
  1.1 - mutex_lock (&LOCK_log)
  1.2 - mutex_lock (&LOCK_prep_xids)
  1.3 - increase prepared_xids
  1.4 - mutex_unlock (&LOCK_prep_xids)
  1.5 - mutex_unlock (&LOCK_log)

2 - "Flush non-trx changes" (MYSQL_BIN_LOG::write) - T1:
  2.1 - mutex_lock (&LOCK_log)
  2.2 - mutex_unlock (&LOCK_log)

3. "unlog" - T1
  3.1 - mutex_lock (&LOCK_prep_xids)
  3.2 - decrease prepared xids
  3.3 - pthread_cond_signal(&COND_prep_xids);
  3.4 - mutex_unlock (&LOCK_prep_xids)

The "FLUSH logs" command produces the following sequence of events:

1 - "FLUSH logs" command (MYSQL_BIN_LOG::new_file_impl) - user thread:
  1.1 - mutex_lock (&LOCK_log)
  1.2 - mutex_lock (&LOCK_prep_xids)
  1.3 - while (prepared_xids)  pthread_cond_wait(..., &LOCK_prep_xids);
  1.4 - mutex_unlock (&LOCK_prep_xids)
  1.5 - mutex_unlock (&LOCK_log)

A deadlock will arise if T1 flushes the trx changes and thus increases
prepared_xids but before it is able to continue the execution and flush the
non-trx changes, an user thread calls the "FLUSH logs" command and wait that
the prepared_xids is decreased and gets to zero. However, T1 cannot proceed
with the call to "Flush non-trx changes" because it will block in the mutex
"LOCK_log" and by consequence cannot complete the execution and call the
unlog to decrease the prepared_xids.

To fix the problem, we ensure that the non-trx changes are always flushed
before the trx changes.

Note that if you call "Flush non-trx changes" and a concurrent "FLUSH logs" is
issued, the "Flush non-trx changes" may block, but a deadlock will never happen
because the prepared_xids will eventually get to zero. Bottom line, there will
not be any transaction able to increase the prepared_xids because they will
block in the mutex "LOCK_log" (MYSQL_BIN_LOG::write) and those that increased
the prepared_xids will eventually commit and decrease the prepared_xids.
2010-01-05 16:55:23 +00:00
He Zhenxing
28fbf9c549 Bug#48776 row based replication breaks with spatial / geometry types, cause crashes!
This bug is the same problem as Bug 49836 for 5.1 versions.
2010-01-05 14:25:29 +08:00
Joerg Bruehe
4b727bd7f0 Ensure that the variable "MYSQL_U_SCORE_VERSION" is expanded
whereever it is used (currently, only RPM spec files).
2010-01-04 15:03:09 +01:00
Jorgen Loland
76f135966c local merge 2010-01-04 10:51:05 +01:00
Jorgen Loland
3dab08f157 Bug#48920: COUNT DISTINCT returns 1 for NULL values when in a
subquery in the select list
      
When a dependent subquery with count(distinct <col>) was 
evaluated multiple times, the Distinct_Aggregator was reused. 
However, the Aggregator was not reset, so when the subquery was
evaluated for the next record in the outer select, old dependent
info was used.
      
The fix is to clear() the existing aggregator in 
Item_sum::set_aggregator(). This ensures that the aggregator is
reevaluated with the new dependent information.
2010-01-04 10:39:42 +01:00
Alexander Nozdrin
c5151a6e9b Auto-merge from mysql-next-mr. 2010-01-04 12:39:33 +03:00
Alexander Nozdrin
f37f38006b Auto-merge from mysql-next-mr-serg. 2010-01-04 12:34:59 +03:00
Sergei Golubchik
4949ee3a75 possible fix for sporadic sys_vars.delayed_insert_limit_func failures 2009-12-31 14:05:33 +01:00
dbe02e6d4a Bug #49137 Replication failure on SBR/MBR + multi-table DROP TEMPORARY TABLE
In statement-based or mixed-mode replication, use DROP TEMPORARY TABLE
to drop multiple tables causes different errors on master and slave, 
when one or more of these tables do not exist. Because when executed
on slave, it would automatically add IF EXISTS to the query to ignore
all ER_BAD_TABLE_ERROR errors.

To fix the problem, do not add IF EXISTS when executing DROP TEMPORARY
TABLE on the slave, and clear the ER_BAD_TABLE_ERROR error after
execution if the query does not expect any errors.
2009-12-31 12:04:19 +08:00
ccc3a46856 Bug #49137 Replication failure on SBR/MBR + multi-table DROP TEMPORARY TABLE
In statement-based or mixed-mode replication, use DROP TEMPORARY TABLE
to drop multiple tables causes different errors on master and slave, 
when one or more of these tables do not exist. Because when executed
on slave, it would automatically add IF EXISTS to the query to ignore
all ER_BAD_TABLE_ERROR errors.

To fix the problem, do not add IF EXISTS when executing DROP TEMPORARY
TABLE on the slave, and clear the ER_BAD_TABLE_ERROR error after
execution if the query does not expect any errors.
2009-12-31 11:33:10 +08:00
Kent Boortz
5f60e1ef7b Merge 2009-12-30 23:26:49 +01:00
Kent Boortz
d64f049351 Removed unwanted Perl DBI dependency 2009-12-30 23:06:14 +01:00
Dmitry Lenev
236539b471 Implementation of simple deadlock detection for metadata locks.
This change is supposed to reduce number of ER_LOCK_DEADLOCK
errors which occur when multi-statement transaction encounters
conflicting metadata lock in cases when waiting is possible.

The idea is not to fail ER_LOCK_DEADLOCK error immediately when
we encounter conflicting metadata lock. Instead we release all
metadata locks acquired by current statement and start to wait
until conflicting lock go away. To avoid deadlocks we use simple
empiric which aborts waiting with ER_LOCK_DEADLOCK error if it
turns out that somebody is waiting for metadata locks owned by
this transaction.

This patch also fixes bug #46273 "MySQL 5.4.4 new MDL: Bug#989
is not fully fixed in case of ALTER".

The bug was that concurrent execution of UPDATE or MULTI-UPDATE
statement as a part of multi-statement transaction that already
has used table being updated and ALTER TABLE statement might have
resulted of loss of isolation between this transaction and ALTER
TABLE statement, which manifested itself as changes performed by
ALTER TABLE becoming visible in transaction and wrong binary log
order as a consequence.

This problem occurred when UPDATE or MULTI-UPDATE's wait in
mysql_lock_tables() call was aborted due to metadata lock
upgrade performed by concurrent ALTER TABLE. After such abort all
metadata locks held by transaction were released but transaction
silently continued to be executed as if nothing has happened.

We solve this problem by changing our code not to release all
locks in such case. Instead we release only locks which were
acquired by current statement and then try to reacquire them
by restarting open/lock tables process. We piggyback on simple
deadlock detector implementation since this change has to be
done anyway for it.
2009-12-30 20:53:30 +03:00
Alexander Nozdrin
cd6fbffc38 Disable test case for Bug#49972. 2009-12-29 21:12:06 +03:00
Alexander Nozdrin
93613d4e07 A test case for Bug#49972 (Crash in prepared statements). 2009-12-29 18:50:01 +03:00
Konstantin Osipov
3b311f399d Apply and review:
3655 Jon Olav Hauglid   2009-10-19
Bug #30977 Concurrent statement using stored function and DROP FUNCTION 
           breaks SBR
Bug #48246 assert in close_thread_table

Implement a fix for:
Bug #41804 purge stored procedure cache causes mysterious hang for many
           minutes
Bug #49972 Crash in prepared statements

The problem was that concurrent execution of DML statements that
use stored functions and DDL statements that drop/modify the same
function might result in incorrect binary log in statement (and
mixed) mode and therefore break replication.

This patch fixes the problem by introducing metadata locking for
stored procedures and functions. This is similar to what is done
in Bug#25144 for views. Procedures and functions now are
locked using metadata locks until the transaction is either
committed or rolled back. This prevents other statements from
modifying the procedure/function while it is being executed. This
provides commit ordering - guaranteeing serializability across
multiple transactions and thus fixes the reported binlog problem.

Note that we do not take locks for top-level CALLs. This means
that procedures called directly are not protected from changes by
simultaneous DDL operations so they are executed at the state they
had at the time of the CALL. By not taking locks for top-level
CALLs, we still allow transactions to be started inside
procedures.

This patch also changes stored procedure cache invalidation.
Upon a change of cache version, we no longer invalidate the entire
cache, but only those routines which we use, only when a statement
is executed that uses them.

This patch also changes the logic of prepared statement validation.
A stored procedure used by a prepared statement is now validated
only once a metadata lock has been acquired. A version mismatch
causes a flush of the obsolete routine from the cache and
statement reprepare.
Incompatible changes:
1) ER_LOCK_DEADLOCK is reported for a transaction trying to access
   a procedure/function that is locked by a DDL operation in
   another connection.

2) Procedure/function DDL operations are now prohibited in LOCK
   TABLES mode as exclusive locks must be taken all at once and
   LOCK TABLES provides no way to specifiy procedures/functions to
   be locked.

Test cases have been added to sp-lock.test and rpl_sp.test.

Work on this bug has very much been a team effort and this patch
includes and is based on contributions from Davi Arnaut, Dmitry
Lenev, Magne Mæhre and Konstantin Osipov.
2009-12-29 15:19:05 +03:00
Alexander Nozdrin
8050affe24 Auto-merge from mysql-next-mr. 2009-12-29 13:02:43 +03:00
Alexey Kopytov
0807a23775 Fixed a build failure in mysql-trunk-merge caused by a bad
merge from mysql-5.1-bugteam.
2009-12-28 16:59:12 +03:00
Alexey Kopytov
85d5a08b51 Manual merge of WL#4738 from mysql-next-mr:
- backported code that handles %f/%g arguments in 
my_vsnprintf.c from 6.0 
- backported %f/%g tests in unittest/mysys/my_vsnprintf-t.c 
from 6.0 
- replaced snprintf("%g") in sql/set_var.cc with my_gcvt() 
- removed unnecessary "--replace-result"s for Windows in 
mysql-test/suite/sys_vars/t/long_query_time_basic.test 
- some test results adjustments
2009-12-28 15:54:16 +03:00
Alfranio Correia
7ff2dcea09 merge mysql-5.1-rep+2 --> mysql-5.1-rep+2-delivery1 2009-12-28 00:06:12 +00:00
Alfranio Correia
d08385fe23 merging from 5.1 to rep+2 starting at gca(5.1, next-mr) == ramil@mysql.com-20091215170821-eexh9rqrnw1ruzh2 2009-12-27 23:47:04 +00:00
Sergei Golubchik
31cd0643ae my_once.c: clarify the comment 2009-12-26 21:55:32 +01:00
Ramil Kalimullin
176a4172e7 Auto-merge. 2009-12-26 15:25:56 +04:00
Ramil Kalimullin
6c16fb6d4e Auto-merge. 2009-12-26 14:59:56 +04:00
Sergei Golubchik
825ba2ec8b don't show the value of open_files_limit 2009-12-26 09:35:42 +01:00
Sergei Golubchik
28056ba204 don't show --ssl* option if ssl is not compiled in 2009-12-25 22:36:59 +01:00
Joerg Bruehe
4b430b897a Backport into the 5.5.1-m2 release build:
| Bug#49898 - Fix for bug#37408 introduces a linker error
|
| the declaration of THR_LOCK_myisam_mmap in mi_static 
| is redundant as it accessible via the extern declaration 
| in include/myisam.h
2009-12-25 17:02:08 +01:00
Alexander Nozdrin
ece5ad57e9 Auto-merge from mysql-next-mr. 2009-12-25 16:22:25 +03:00
Alexey Kopytov
24fc798fc7 Manual merge of mysql-5.1-bugteam into mysql-trunk-merge.
Conflicts:

mysql-test/collections/default.experimental
2009-12-25 13:56:50 +03:00
Alexey Kopytov
1d13320d9a Null merge. 2009-12-25 12:15:16 +03:00
0c4e5f784b Backport Bug #43913 rpl_cross_version can't pass on conflicts complainig clash with --slave-load-tm
The 'rpl_cross_version' fails on mysql-next-mr-bugfixing as following:
mysqltest: In included file "./include/setup_fake_relay_log.inc": At line 80: query
'select './$_fake_filename-fake.000001\n' into dumpfile '$_fake_relay_index'' failed:
1290: The MySQL server is running with the --secure-file-priv option so it cannot execute
this statement.

To fix the problem by removeing the --secure-file-priv option
for adapting the update of the 'setup_fake_relay_log.inc'.
2009-12-25 14:12:49 +08:00
Alexey Kopytov
ca409d5756 Automerge. 2009-12-25 00:09:18 +03:00
Alexey Kopytov
064ebe5769 Addendum to the backport patch for WL#2934:
Unlike other platforms --mfpmath=sse is the default 
gcc mode on Mac OS X Intel. So it is unnecessary
to switch FPU to double precision mode (in fact,
it even breaks some math library functions).
2009-12-25 00:06:53 +03:00
Sergei Golubchik
50f9dc6a1d merged 2009-12-24 21:18:53 +01:00
Luis Soares
9b0e91044e Valgrind warnings that have poped up ever since WL#5151 was pushed.
This fixes two more warnings for tests: 
  - rpl_row_colSize
  - rpl_typeconv
2009-12-24 15:55:46 +00:00
Luis Soares
b367b03bcb BUG#48738: null merge mysql-5.0-bugteam into mysql-5.1-bugteam latest. 2009-12-24 15:26:15 +00:00
Luis Soares
6d96d334fa BUG#48738: post-push fix. Multi-platform test improvements, mainly
to make the test run gracefully on windows.

There was also a syntax error in windows part of the test.
2009-12-24 15:20:58 +00:00
Alfranio Correia
b79df3bc19 merge mysql-next-mr --> mysql-5.1-rpl-merge 2009-12-24 11:51:30 +00:00
Sergei Golubchik
b4a39aeb5d slightly more complete mysqld--help test 2009-12-24 12:30:23 +01:00
Alexander Nozdrin
7917f0852f Auto-merge from mysql-trunk-merge. 2009-12-24 10:56:13 +03:00
Alexander Nozdrin
e446a244e0 Auto-merge from mysql-next-mr. 2009-12-24 10:34:13 +03:00
Alexander Nozdrin
6bb8cd8429 Auto-merge from mysql-trunk. 2009-12-24 10:34:04 +03:00
Alexander Nozdrin
fa64b359ab Auto-merge (empty) from mysql-trunk-bugfixing. 2009-12-24 10:31:09 +03:00
Alexander Nozdrin
27e7547bc6 Auto-merge from mysql-next-mr. 2009-12-24 10:30:13 +03:00
Alexander Nozdrin
2af3baceaf Auto-merge from mysql-trunk. 2009-12-24 10:30:04 +03:00
Alexander Nozdrin
9f335d9e91 Manual merge from mysql-trunk.
Conflicts:
  - storage/myisam/mi_static.c
2009-12-24 10:12:07 +03:00