Commit graph

398 commits

Author SHA1 Message Date
Alexander Nozdrin
7cd11f45be Manual merge from mysql-trunk-merge. 2009-11-06 17:20:27 +03:00
unknown
9519c8e597 Manual Merge 2009-11-03 18:20:08 +08:00
Luis Soares
a382917684 BUG#48297: Schema name is ignored when LOAD DATA is written into
binlog, replication aborts

In SBR or MBR, the schema name is not being written to the binlog
when executing a LOAD DATA statement. This becomes a problem when
the current database (lets call it db1) is different from the
table's schema (lets call it db2). For instance, take the
following statements:
  
  use db1;
  load data local infile 'infile.txt' into table db2.t

Should this statement be logged without t's schema (db2), when
replaying it, one can get db1.t populated instead of db2.t (if
db1.t exists). On the other hand, if there is no db1.t at all,
replication will stop.

We fix this by always logging the table (in load file) with fully
qualified name when its schema is different from the current
database or when no default database was selected.
2009-10-27 15:15:53 +00:00
Luis Soares
f1bb8c3c55 manual merge: mysql-5.1-rep+2-delivery1 --> mysql-5.1-rpl-merge
Conflicts
=========

Text conflict in .bzr-mysql/default.conf
Text conflict in libmysqld/CMakeLists.txt
Text conflict in libmysqld/Makefile.am
Text conflict in mysql-test/collections/default.experimental
Text conflict in mysql-test/extra/rpl_tests/rpl_row_sp006.test
Text conflict in mysql-test/suite/binlog/r/binlog_tmp_table.result
Text conflict in mysql-test/suite/rpl/r/rpl_loaddata.result
Text conflict in mysql-test/suite/rpl/r/rpl_loaddata_fatal.result
Text conflict in mysql-test/suite/rpl/r/rpl_row_create_table.result
Text conflict in mysql-test/suite/rpl/r/rpl_row_sp006_InnoDB.result
Text conflict in mysql-test/suite/rpl/r/rpl_stm_log.result
Text conflict in mysql-test/suite/rpl_ndb/r/rpl_ndb_circular_simplex.result
Text conflict in mysql-test/suite/rpl_ndb/r/rpl_ndb_sp006.result
Text conflict in mysql-test/t/mysqlbinlog.test
Text conflict in sql/CMakeLists.txt
Text conflict in sql/Makefile.am
Text conflict in sql/log_event_old.cc
Text conflict in sql/rpl_rli.cc
Text conflict in sql/slave.cc
Text conflict in sql/sql_binlog.cc
Text conflict in sql/sql_lex.h
21 conflicts encountered.

NOTE
====
 mysql-5.1-rpl-merge has been made a mirror of mysql-next-mr:
 - "mysql-5.1-rpl-merge$ bzr pull ../mysql-next-mr"

 This is the first cset (merge/...) committed after pulling 
 from mysql-next-mr.
2009-10-22 23:30:28 +01:00
Tatiana A. Nurnberg
3f0d0d0633 manual merge of 28141 2009-10-20 11:00:07 -07:00
unknown
f9c6730258 Bug#46640: output from mysqlbinlog command in 5.1 breaks replication
The BINLOG statement was sharing too much code with the slave SQL thread, introduced with
the patch for Bug#32407. This caused statements to be logged with the wrong server_id, the
id stored inside the events of the BINLOG statement rather than the id of the running 
server.
      
Fix by rearranging code a bit so that only relevant parts of the code are executed by
the BINLOG statement, and the server_id of the server executing the statements will 
not be overrided by the server_id stored in the 'format description BINLOG statement'.

mysql-test/extra/binlog_tests/binlog.test:
  Added test to verify if the server_id stored in the 'format 
  description BINLOG statement' will override the server_id
  of the server executing the statements.
mysql-test/suite/binlog/r/binlog_row_binlog.result:
  Test result for bug#46640
mysql-test/suite/binlog/r/binlog_stm_binlog.result:
  Test result for bug#46640
sql/log_event.cc:
  Moved rows_event_stmt_clean() call from update_pos() to apply_event(). This in any case
  makes more sense, and is needed as update_pos() is no longer called when executing
  BINLOG statements.
  
  Moved setting of rli->relay_log.description_event_for_exec from 
  Format_description_log_event::do_update_pos() to 
  Format_description_log_event::do_apply_event()
sql/log_event_old.cc:
  Moved rows_event_stmt_clean() call from update_pos() to apply_event(). This in any case
  makes more sense, and is needed as update_pos() is no longer called when executing
  BINLOG statements.
sql/slave.cc:
  The skip flag is no longer needed, as the code path for BINLOG statement has been 
  cleaned up.
sql/sql_binlog.cc:
  Don't invoke the update_pos() code path for the BINLOG statement, as it contains code 
  that is redundant and/or harmful (especially setting thd->server_id).
2009-10-14 09:39:05 +08:00
Luis Soares
9226c847f5 BUG#44661: automerge local 5.1-bt bug branch --> local 5.1-bt up to date 2009-10-07 22:26:36 +01:00
Alfranio Correia
15127bcdf3 mysql-5.1-bugteam (local) --> mysql-5.1-bugteam 2009-10-06 11:25:36 +01:00
Alfranio Correia
7e0da4352c BUG#47678 Changes to n-tables that happen early in a trans. are only flushed upon commit
Let
    - T be a transactional table and N non-transactional table.
    - B be begin, C commit and R rollback.
    - N be a statement that accesses and changes only N-tables.
    - T be a statement that accesses and changes only T-tables.

In RBR, changes to N-tables that happen early in a transaction are not immediately flushed
upon committing a statement. This behavior may, however, break consistency in the presence
of concurrency since changes done to N-tables become immediately visible to other
connections. To fix this problem, we do the following:

  . B N N T C would log - B N C B N C B T C.
  . B N N T R would log - B N C B N C B T R.

Note that we are not preserving history from the master as we are introducing a commit that
never happened. However, this seems to be more acceptable than the possibility of breaking
consistency in the presence of concurrency.
2009-10-06 01:54:00 +01:00
Alfranio Correia
14d1909440 BUG#47287 RBR: replication diff on basic case with txn- and non-txn tables in a statement
Let
  - T be a transactional table and N non-transactional table.
  - B be begin, C commit and R rollback.
  - M be a mixed statement, i.e. a statement that updates both T and N.
  - M* be a mixed statement that fails while updating either T or N.

This patch restore the behavior presented in 5.1.37 for rows either produced in
the RBR or MIXED modes, when a M* statement that happened early in a transaction
had their changes written to the binary log outside the boundaries of the
transaction and wrapped in a BEGIN/ROLLBACK. This was done to keep the slave
consistent with with the master as the rollback would keep the changes on N and
undo them on T. In particular, we do what follows:

  . B M* T C would log - B M* R B T C.

Note that, we are not preserving history from the master as we are introducing a
rollback that never happened. However, this seems to be more acceptable than
making the slave diverge. We do not fix the following case:

  . B T M* C would log B T M* C.

The slave will diverge as the changes on T tables that originated from the M
statement are rolled back on the master but not on the slave. Unfortunately, we
cannot simply rollback the transaction as this would undo any uncommitted
changes on T tables.

SBR is not considered in this patch because a failing statement is written to
the binary along with the error code and a slave executes and then rolls back
the statement when it has an associated error code, thus undoing the effects
on T. In RBR and MBR, a full-fledged fix will be pushed after the WL 2687.
2009-10-06 01:38:58 +01:00
He Zhenxing
54120363ef Backport fixes for the follow tests
binlog_tmp_table
rpl_row_sp006_InnoDB
rpl_slave_status
2009-10-02 17:24:21 +08:00
Andrei Elkin
737910fb11 merge from 5.1-rpl+2 repo to a local branch with HB and bug@27808 fixes 2009-10-01 20:22:44 +03:00
unknown
41e0d0a3ab Bug #45677 Slave stops with Duplicate entry for key PRIMARY when using trigger
The problem is that there is only one autoinc value associated with 
the query when binlogging. If more than one autoinc values are used 
in the query, the autoinc values after the first one can be inserted 
wrongly on slave. So these autoinc values can become inconsistent on 
master and slave.

The problem is resolved by marking all the statements that invoke 
a trigger or call a function that updated autoinc fields as unsafe, 
and will switch to row-format in Mixed mode. Actually, the statement 
is safe if just one autoinc value is used in sub-statement, but it's 
impossible to check how many autoinc values are used in sub-statement.)

mysql-test/suite/rpl/r/rpl_auto_increment_update_failure.result:
  Test result for bug#45677
mysql-test/suite/rpl/t/rpl_auto_increment_update_failure.test:
  Added test to verify the following two properties:
  P1) insert/update in an autoinc column causes statement to 
  be logged in row format if binlog_format=mixed
  P2) if binlog_format=mixed, and a trigger or function contains 
      two or more inserts/updates in a table that has an autoinc 
      column, then the slave should not go out of sync, even if 
      there are concurrent transactions.
sql/sql_base.cc:
  Added function 'has_write_table_with_auto_increment' to check 
  if one (or more) write tables have auto_increment columns.
  
  Removed function 'has_two_write_locked_tables_with_auto_increment', 
  because the function is included in function 
  'has_write_table_with_auto_increment'.
2009-10-01 07:19:36 +08:00
Alfranio Correia
0ebecf7f0a BUG#47741 rpl_ndb_extraCol fails in next-mr (mysql-5.1-rep+2) in RBR
This is a temporary fix.

NOTE: Backporting the patch to next-mr.
2009-09-30 16:25:01 +01:00
Alfranio Correia
9922788d7a Post-fix for BUG#43789
NOTE: Backporting the patch to next-mr.
2009-09-30 15:17:15 +01:00
Alfranio Correia
25162d0166 BUG#43789 different master/slave table defs cause crash: text/varchar null
vs not null

NOTE: Backporting the patch to next-mr.
                        
The replication was generating corrupted data, warning messages on Valgrind
and aborting on debug mode while replicating a "null" to "not null" field.
Specifically the unpack_row routine, was considering the slave's table
definition and trying to retrieve a field value, where there was nothing to be
retrieved, ignoring the fact that the value was defined as "null" by the master.
                        
To fix the problem, we proceed as follows:
                        
1 - If it is not STRICT sql_mode, implicit default values are used, regardless
if it is multi-row or single-row statement.
                        
2 - However, if it is STRICT mode, then a we do what follows:
                        
2.1 If it is a transactional engine, we do a rollback on the first NULL that is
to be set into a NOT NULL column and return an error.
                        
2.2 If it is a non-transactional engine and it is the first row to be inserted
with multi-row, we also return the error. Otherwise, we proceed with the
execution, use implicit default values and print out warning messages.
                  
Unfortunately, the current patch cannot mimic the behavior showed by the master
for updates on multi-tables and multi-row inserts. This happens because such
statements are unfolded in different row events. For instance, considering the
following updates and strict mode:
                  
(master)
create table t1 (a int);
create table t2 (a int not null);
insert into t1 values (1);
insert into t2 values (2);
update t1, t2 SET t1.a=10, t2.a=NULL;
                  
t1 would have (10) and t2 would have (0) as this would be handled as a
multi-row update. On the other hand, if we had the following updates:
                  
(master)
create table t1 (a int);
create table t2 (a int);
                  
(slave)
create table t1 (a int);
create table t2 (a int not null);
                  
(master)
insert into t1 values (1);
insert into t2 values (2);
update t1, t2 SET t1.a=10, t2.a=NULL;
                  
On the master t1 would have (10) and t2 would have (NULL). On
the slave, t1 would have (10) but the update on t1 would fail.
2009-09-29 15:18:44 +01:00
Alfranio Correia
cc9e25af54 BUG#38173 Field doesn't have a default value with row-based replication
NOTE: Backporting the patch to next-mr.
      
The reason of  the bug was incompatibile with the master side behaviour.
INSERT query on the master is allowed to insert into a table without specifying
values of DEFAULT-less fields if sql_mode is not strict.
            
Fixed with checking sql_mode by the sql thread to decide how to react.
Non-strict sql_mode should allow Write_rows event to complete.
            
todo: warnings can be shown via show slave status, still this is a 
separate rather general issue how to show warnings for the slave threads.
2009-09-29 15:04:21 +01:00
Andrei Elkin
5983785ef4 WL#342 heartbeat
backporting from 6.0 code base to 5.1.
2009-09-29 14:16:23 +03:00
Luis Soares
f0886a4d9d BUG#28777, WL#4293: SHOW BINLOG EVENTS does not work on relay log
files

NOTE: this is the backport to next-mr.
            
SHOW BINLOG EVENTS does not work with relay log files. If issuing
"SHOW BINLOG EVENTS IN 'relay-log.000001'" in a non-empty relay
log file (relay-log.000001), mysql reports empty set.
            
This patch addresses this issue by extending the SHOW command
with RELAYLOG. Events in relay log files can now be inspected by
issuing SHOW RELAYLOG EVENTS [IN 'log_name'] [FROM pos] [LIMIT
[offset,] row_count].

mysql-test/extra/rpl_tests/rpl_show_relaylog_events.inc:
  Shared part of the test case.
mysql-test/include/show_binlog_events.inc:
  Added options $binary_log_file, $binary_log_limit_row, 
  $binary_log_limit_offset so that show_binlog_events can take 
  same parameters as SHOW BINLOG EVENTS does.
mysql-test/include/show_relaylog_events.inc:
  Clone of show_binlog_events for relaylog events.
mysql-test/suite/rpl/t/rpl_row_show_relaylog_events.test:
  Test case for row based replication.
mysql-test/suite/rpl/t/rpl_stm_mix_show_relaylog_events.test:
  Test case for statement and mixed mode replication.
sql/lex.h:
  Added RELAYLOG symbol.
sql/mysqld.cc:
  Added "show_relaylog_events" to status_vars.
sql/sp_head.cc:
  Set SQLCOM_SHOW_RELAYLOG_EVENTS to return flags=
  sp_head::MULTI_RESULTS; in sp_get_flags_for_command as
  SQLCOM_SHOW_BINLOG_EVENTS does.
sql/sql_lex.h:
  Added sql_command SQLCOM_SHOW_RELAYLOG_EVENTS to lex enum_sql_command.
sql/sql_parse.cc:
  Added handling of SQLCOM_SHOW_RELAYLOG_EVENTS.
sql/sql_repl.cc:
  mysql_show_binlog_events set to choose the log file to use based on
  the command issued (SHOW BINLOG|RELAYLOG EVENTS).
sql/sql_yacc.yy:
  Added RELAYLOG to the grammar.
2009-09-29 00:04:20 +01:00
unknown
c6186a2500 BUG #46572 DROP TEMPORARY table IF EXISTS does not have a consistent behavior in ROW mode
In RBR, 'DROP TEMPORARY TABLE IF EXISTS...' statement is binlogged when the table
does not exist.
      
In fact, 'DROP TEMPORARY TABLE ...' statement should never be binlogged in RBR
no matter if the table exists or not. 
This patch addresses this by checking whether we are dropping a
temporary table or not, when building the custom drop statement.
2009-09-28 10:23:06 +08:00
Luis Soares
a00bb75783 BUG#44661: rpl_ndb.rpl_ndb_circular_simplex fails because of
failure to cleanup of table

The test case was not dropping a table before exiting (ie, it was
not cleaning itself after execution). In this case, the warning
message stating that the test did not do a proper cleanup was
deterministic (which can be annoying).

I have found other tests cases on which mtr sporadically reports
that they have not cleaned up after execution:

 - rpl_ndb_circular
 - rpl_failed_optimize

In this case, the master was dropping a table but there was no
synchronization between the slave and the master.

This patch addresses the rpl_ndb_circular_simplex case by adding
the missing DROP table. The other cases are fixed by deploying
the missing sync_slave_with_master instruction.
2009-09-27 23:03:05 +01:00
unknown
09efe92a45 Bug #46931 rpl.rpl_get_master_version_and_clock fails on hpux11.31
Network error happened here, but it can be caused by CR_CONNECTION_ERROR, 
CR_CONN_HOST_ERROR, CR_SERVER_GONE_ERROR, CR_SERVER_LOST, ER_CON_COUNT_ERROR, 
and ER_SERVER_SHUTDOWN. We just check CR_SERVER_LOST here, so the test fails.

To fix the problem, check all errors that can be cause by the master shutdown.

mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test:
  Added a 'if' sentence to check all errors that can be cause by the master shutdown.
mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result:
  Test result is updated duo to the patch of bug#46931
2009-09-27 17:00:29 +08:00
Mats Kindahl
124e830125 Bug #37221: SET AUTOCOMMIT=1 does not commit binary log
When setting AUTOCOMMIT=1 after starting a transaction, the binary log
did not commit the outstanding transaction. The reason was that the binary
log commit function saw the values of the new settings, deciding that there
were nothing to commit.

Fixed the problem by moving the implicit commit to before the thread option
flags were changed, so that the binary log sees the old values of the flags
instead of the values they will take after the statement.


mysql-test/extra/binlog_tests/implicit.test:
  New test file to check implicit commits both inside and outside transactions.
mysql-test/suite/binlog/t/binlog_implicit_commit.test:
  Test for implicit commit of SET AUTOCOMMIT and LOCK/UNLOCK TABLES.
sql/set_var.cc:
  Adding code to commit pending transaction before changing option flags.
2009-09-23 13:20:48 +02:00
Georgi Kodinov
4ac694822b automerge 2009-09-18 16:35:40 +03:00
unknown
e436b8866b BUG#45999 Row based replication fails when auto_increment field = 0
In RBR, There is an inconsistency between slaves and master.
When INSERT statement which includes an auto_increment field is executed,
Store engine of master will check the value of the auto_increment field. 
It will generate a sequence number and then replace the value, if its value is NULL or empty.
if the field's value is 0, the store engine will do like encountering the NULL values 
unless NO_AUTO_VALUE_ON_ZERO is set into SQL_MODE.
In contrast, if the field's value is 0, Store engine of slave always generates a new sequence number 
whether or not NO_AUTO_VALUE_ON_ZERO is set into SQL_MODE.

SQL MODE of slave sql thread is always consistency with master's.
Another variable is related to this bug.
If generateing a sequence number is decided by the values of
table->auto_increment_field_not_null and SQL_MODE(if includes MODE_NO_AUTO_VALUE_ON_ZERO)
The table->auto_increment_is_not_null is FALSE, which causes this bug to appear. ..
2009-09-10 18:05:53 +08:00
unknown
1eb40ce319 BUG#45581 Test rpl_row_sp006_InnoDB fails randomly: Unknown database 'mysqltest1'
Essentially, Bug#45574 results in this bug. The 'CREATE DATABASE IF NOT EXISTS' statement was not 
binlogged, when the database has existed.
Sometimes, the master and slaves become inconsistent. The "CREATE DATABASE
IF NOT EXISTS mysqltest1" statement is not binlogged
if the db 'mysqltest1' existed before the test case is executed. 
So the db 'mysqltest1' can't be created on slave.
     
Patch of Bug#45574 has resolved this problem. 
But I think it is better to replace 'mysqltest1' by default db 'test'.
2009-09-04 09:33:45 +08:00
Bjorn Munch
31f9d5fd16 second merge from main, with adaptions 2009-09-02 23:29:11 +02:00
Bjorn Munch
a829604260 first merge from main 2009-09-02 18:58:17 +02:00
Bjorn Munch
fa4f05139d Bug #42408 Faulty regex for detecting [Warning] and [ERROR] in mysqld error log
Some follow-up test fixes after seeing effect in PB2
2009-08-28 16:13:27 +02:00
Alfranio Correia
354f5f7bac BUG#46864 Incorrect update of InnoDB table on slave when using trigger with myisam table
Slave does not correctly handle "expected errors" leading to inconsistencies
between the mater and slave. Specifically, when a statement changes both
transactional and non-transactional tables, the transactional changes are
automatically rolled back on the master but the slave ignores the error and
does not roll them back thus leading to inconsistencies.
      
To fix the problem, we automatically roll back a statement that fails on
the slave but note that the transaction is not rolled back unless a "rollback"
command is in the relay log file.

mysql-test/extra/rpl_tests/rpl_mixing_engines.test:
  Enabled item 13.e which was disabled because of the bug fixed by the
  current and removed item 14 which was introduced by mistake.
2009-08-27 13:46:29 +01:00
Alfranio Correia
6c2b32515e BUG#28976 Mixing trans and non-trans tables in one transaction results in incorrect
binlog

Mixing transactional (T) and non-transactional (N) tables on behalf of a
transaction may lead to inconsistencies among masters and slaves in STATEMENT
mode. The problem stems from the fact that although modifications done to
non-transactional tables on behalf of a transaction become immediately visible
to other connections they do not immediately get to the binary log and therefore
consistency is broken. Although there may be issues in mixing T and M tables in
STATEMENT mode, there are safe combinations that clients find useful.

In this bug, we fix the following issue. Mixing N and T tables in multi-level
(e.g. a statement that fires a trigger) or multi-table table statements (e.g.
update t1, t2...) were not handled correctly. In such cases, it was not possible
to distinguish when a T table was updated if the sequence of changes was N and T.
In a nutshell, just the flag "modified_non_trans_table" was not enough to reflect
that both a N and T tables were changed. To circumvent this issue, we check if an
engine is registered in the handler's list and changed something which means that
a T table was modified.

Check WL 2687 for a full-fledged patch that will make the use of either the MIXED or
ROW modes completely safe.

mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result:
  Truncate statement is wrapped in BEGIN/COMMIT.
mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result:
  Truncate statement is wrapped in BEGIN/COMMIT.
2009-08-27 00:13:03 +01:00
unknown
aa4b8939a0 Bug #45214 get_master_version_and_clock does not report error when queries fail
The "get_master_version_and_clock(...)" function in sql/slave.cc ignores 
error and passes directly when queries fail, or queries succeed 
but the result retrieved is empty.
  
The "get_master_version_and_clock(...)" function should try to reconnect master
if queries fail because of transient network problems, and fail otherwise.
The I/O thread should print a warning if the some system variables do not 
exist on master (very old master)

mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test:
  Added test file for bug #45214
mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result:
  Added test result for bug #45214
mysql-test/suite/rpl/t/rpl_get_master_version_and_clock.test:
  Added test file for bug #45214
sql/slave.cc:
  The 'is_network_error()' function is added for checking if the error is caused by network.
  Added a new return value (2) to 'get_master_version_and_clock()' function result set 
  to indicate transient network errors when queries fail, and the caller should 
  try to reconnect in this case.
2009-07-16 14:56:43 +08:00
Ramil Kalimullin
1e56aea355 Fix for bug#45998: database crashes when running
"create as select" (innodb table)

Problem: code constructing "CREATE TABLE..." statement
doesn't take into account that current database is not set
in some cases. That may lead to a server crash.

Fix: check if current database is set.


mysql-test/extra/binlog_tests/binlog.test:
  Fix for bug#45998: database crashes when running
  "create as select" (innodb table)
    - test case.
mysql-test/suite/binlog/r/binlog_row_binlog.result:
  Fix for bug#45998: database crashes when running
  "create as select" (innodb table)
    - test result.
sql/sql_show.cc:
  Fix for bug#45998: database crashes when running
  "create as select" (innodb table)
    - added check if there's current database set.
2009-07-14 20:07:29 +05:00
Luis Soares
0fdebc8c49 BUG#44270: Post-push fix
The test case added failed sporadically on PB. This is due to the
fact that the user thread in some cases is waiting for slave IO
to stop and then check the error number. Thence, sometimes the
user thread would race for the error number with IO thread.

This post push fix addresses this by replacing the wait for slave
io to stop with a wait for slave io error (as it seems it was
added in 6.0 also after patch on which this is based was
pushed). This implied backporting wait_for_slave_io_error.inc
from 6.0 also.
2009-06-26 12:05:56 +01:00
Luis Soares
11f1ab1069 BUG#44270: RESET SLAVE does not reset Last_IO_Error or Last_IO_Errno
The server was not cleaning the last IO error and error number when
resetting slave.

This patch addresses this issue by backporting into 5.1 part of the
patch in BUG 34654. A fix for this issue had already been pushed into
6.0 as part of the aforementioned bug, however the patch also included
some refactoring. The fix for 5.1 does not take into account the
refactoring part.

mysql-test/extra/rpl_tests/rpl_reset_slave.test:
  Backported the test case and improved with deploying include/start_slave.inc
  in relevant spots.
sql/slave.cc:
  Backported part of patch from 6.0 that includes cleaning 
  mi->clear_error() at:
    1. beginning of handle_slave_io
    2. on successful connection
  
  Also, backported the assertion added in the original patch.
sql/sql_repl.cc:
  Backported the call to mi->clear_error() on reset_slave().
2009-06-03 15:14:18 +01:00
Serge Kozlov
a81e21f8a4 Bug#37716.
1. Test case was rewritten completely.
2. Test covers 3 cases:
 a) do deadlock on slave, wait retries of transaction, unlock slave before lock
timeout;
 b) do deadlock on slave and wait error 'lock timeout exceed' on slave;
 c) same as b) but if of max relay log size = 0;
3. Added comments inline.
4. Updated result file.
2009-04-04 01:33:13 +04:00
Ramil Kalimullin
aca1a83fed Manual merge. 2009-03-25 23:41:16 +04:00
Luis Soares
ed1e9d214c BUG#39701: Mixed binlog format does not switch to row mode on
LOAD_FILE
            
LOAD_FILE is not safe to replicate in STATEMENT mode, because it
depends on a file (which is loaded on master and may not exist in
slave(s)). This leads to scenarios on which the slave replicates the
statement with 'load_file' and it will try to load the file from local
file system. Given that the file may not exist in the slave filesystem
the operation will not succeed (probably returning NULL), causing
master and slave(s) to diverge. However, when using MIXED mode
replication, this can be made to work, if the statement including
LOAD_FILE is marked as unsafe, triggering a switch to ROW mode,
meaning that the contents of the file are written to binlog as row
events. Consequently, the contents from the file in the master will
reach the slave via the binlog.
           
This patch addresses this bug by marking the load_file function as
unsafe. When in mixed mode and when LOAD_FILE is issued, there will be
a switch to row mode. Furthermore, when in statement mode, the
LOAD_FILE will raise a warning that the statement is unsafe in that
mode.


mysql-test/extra/rpl_tests/rpl_loadfile.test:
  Extra file that is "sourced" on both rpl_loadfile and rpl_stm_loadfile
  test files.
mysql-test/suite/rpl/r/rpl_loadfile.result:
  Updated with the results from the test case added to this file.
mysql-test/suite/rpl/r/rpl_stm_loadfile.result:
  Result file for rpl_loadfile test split with the warnings in statement
  mode.
mysql-test/suite/rpl/t/rpl_loadfile.test:
  After splitting the original rpl_loadfile file, this one is only 
  required to be executed in mixed or row format.
  Appended the test for 39701 to this file.
mysql-test/suite/rpl/t/rpl_stm_loadfile.test:
  Split the original rpl_loadfile test because load_file now raises
  a warning when in statement mode. The goal of this split is 
  two-fold: i) make the test case more resilient; ii) assert that 
  warnings are indeed raised when in statement mode.
sql/item_create.cc:
  Added the set_stmt_unsafe call to lex.
2009-03-24 18:27:33 +00:00
Mats Kindahl
8a98664d3b Merging with 5.1-bugteam. 2009-02-09 23:51:59 +01:00
Mats Kindahl
bd53d21417 Bug #36763
TRUNCATE TABLE fails to replicate when stmt-based binlogging is not supported.

There were two separate problems with the code, both of which are fixed with
this patch:

1. An error was printed by InnoDB for TRUNCATE TABLE in statement mode when
   the in isolation levels READ COMMITTED and READ UNCOMMITTED since InnoDB
   does permit statement-based replication for DML statements. However,
   the TRUNCATE TABLE is not transactional, but is a DDL, and should therefore
   be allowed to be replicated as a statement.

2. The statement was not logged in mixed mode because of the error above, but
   the error was not reported to the client.

This patch fixes the problem by treating TRUNCATE TABLE a DDL, that is, it is
always logged as a statement and not reporting an error from InnoDB for TRUNCATE
TABLE.


mysql-test/extra/binlog_tests/binlog_truncate.test:
  Adding new test to check that TRUNCATE TABLE is written correctly
  to the binary log.
mysql-test/extra/rpl_tests/rpl_truncate.test:
  Removing redundant testing by eliminating settings of BINLOG_FORMAT.
mysql-test/extra/rpl_tests/rpl_truncate_helper.test:
  Replacing slave and master reset code with include file.
  Removing settings of BINLOG_FORMAT.
  Replacing printing of table contents to compare master and slave
  with diff_tables.inc.
mysql-test/suite/binlog/t/binlog_truncate_innodb.test:
  Adding test for testing that TRUNCATE TABLE is logged correctly for InnoDB
  in all isolation levels.
mysql-test/suite/binlog/t/binlog_truncate_myisam.test:
  Adding test for testing that TRUNCATE TABLE is logged correctly for MyISAM.
mysql-test/suite/binlog/t/disabled.def:
  Disabling binlog_truncate_innodb since it does not work (yet).
sql/sql_base.cc:
  Correcting setting of capabilities flags to make the comparison with 0
  later in the code work correctly.
sql/sql_delete.cc:
  Re-organizing code to ensure that TRUNCATE TABLE is logged in statement
  format and that row format is not used unless there are rows to log (which
  there are not when delete_all_rows() is called, so this has to be logged
  as a statement).
2009-02-06 17:06:41 +01:00
Gleb Shchepa
b9d02d4669 Bug #39265: fix for the bug 33699 should be reverted
Documented behaviour was broken by the patch for bug 33699
that actually is not a bug.

This fix reverts patch for bug 33699 and reverts the
UPDATE of NOT NULL field with NULL query to old
behavior.


mysql-test/extra/rpl_tests/rpl_extraMaster_Col.test:
  Bug #39265: fix for the bug 33699 should be reverted
mysql-test/include/ps_modify.inc:
  Bug #39265: fix for the bug 33699 should be reverted
mysql-test/r/auto_increment.result:
  Bug #39265: fix for the bug 33699 should be reverted
mysql-test/r/csv_not_null.result:
  Bug #39265: fix for the bug 33699 should be reverted
mysql-test/r/null.result:
  Bug #39265: fix for the bug 33699 should be reverted
mysql-test/r/ps_2myisam.result:
  Bug #39265: fix for the bug 33699 should be reverted
mysql-test/r/ps_3innodb.result:
  Bug #39265: fix for the bug 33699 should be reverted
mysql-test/r/ps_4heap.result:
  Bug #39265: fix for the bug 33699 should be reverted
mysql-test/r/ps_5merge.result:
  Bug #39265: fix for the bug 33699 should be reverted
mysql-test/r/warnings.result:
  Bug #39265: fix for the bug 33699 should be reverted
mysql-test/suite/ndb/r/ps_7ndb.result:
  Bug #39265: fix for the bug 33699 should be reverted
mysql-test/suite/rpl/r/rpl_extraColmaster_innodb.result:
  Bug #39265: fix for the bug 33699 should be reverted
mysql-test/suite/rpl/r/rpl_extraColmaster_myisam.result:
  Bug #39265: fix for the bug 33699 should be reverted
mysql-test/suite/rpl/t/rpl_err_ignoredtable.test:
  Bug #39265: fix for the bug 33699 should be reverted
mysql-test/t/auto_increment.test:
  Bug #39265: fix for the bug 33699 should be reverted
mysql-test/t/csv_not_null.test:
  Bug #39265: fix for the bug 33699 should be reverted
mysql-test/t/null.test:
  Bug #39265: fix for the bug 33699 should be reverted
mysql-test/t/warnings.test:
  Bug #39265: fix for the bug 33699 should be reverted
sql/sql_update.cc:
  Bug #39265: fix for the bug 33699 should be reverted
2009-02-05 13:49:32 +04:00
Serge Kozlov
56fa095907 Post-merge patch for extra/rpl_test/rpl_log.test:
Remove size of binlog file from SHOW BINARY LOGS. 
Changing size of binlog file is an affect of adding or removing events to/from
binlog and it can be checked in next command of test: SHOW BINLOG EVENTS.
For SHOW BINARY LOGS statement enough to show the list of file names.
2009-02-02 14:44:18 +03:00
Luis Soares
df8543868d merge: 5.1 -> 5.1-rpl
conflicts:
  Text conflict in client/mysqltest.cc
  Text conflict in mysql-test/include/wait_until_connected_again.inc
  Text conflict in mysql-test/lib/mtr_report.pm
  Text conflict in mysql-test/mysql-test-run.pl
  Text conflict in mysql-test/r/events_bugs.result
  Text conflict in mysql-test/r/log_state.result
  Text conflict in mysql-test/r/myisam_data_pointer_size_func.result
  Text conflict in mysql-test/r/mysqlcheck.result
  Text conflict in mysql-test/r/query_cache.result
  Text conflict in mysql-test/r/status.result
  Text conflict in mysql-test/suite/binlog/r/binlog_index.result
  Text conflict in mysql-test/suite/binlog/r/binlog_innodb.result
  Text conflict in mysql-test/suite/rpl/r/rpl_packet.result
  Text conflict in mysql-test/suite/rpl/t/rpl_packet.test
  Text conflict in mysql-test/t/disabled.def
  Text conflict in mysql-test/t/events_bugs.test
  Text conflict in mysql-test/t/log_state.test
  Text conflict in mysql-test/t/myisam_data_pointer_size_func.test
  Text conflict in mysql-test/t/mysqlcheck.test
  Text conflict in mysql-test/t/query_cache.test
  Text conflict in mysql-test/t/rpl_init_slave_func.test
  Text conflict in mysql-test/t/status.test
2009-01-23 13:22:05 +01:00
He Zhenxing
45140a8ea3 Auto merge 2009-01-14 17:32:25 +08:00
He Zhenxing
f2c122bf90 BUG#41986 Replication slave does not pick up proper AUTO_INCREMENT value for Innodb tables
The next number (AUTO_INCREMENT) field of the table for write
rows events are not initialized, and cause some engines (innodb)
not correctly update the tables's auto_increment value.

This patch fixed this problem by honor next number fields if present.

mysql-test/extra/rpl_tests/rpl_auto_increment.test:
  Add test code for BUG#41986
mysql-test/suite/rpl/r/rpl_auto_increment.result:
  update test result file for BUG#41986
sql/log_event.cc:
  set next_number_field before writing rows, and reset next_number_field after finished writing rows
2009-01-14 16:27:32 +08:00
Patrick Crews
fed5e97733 Bug#41888: Test binlog.binlog_database causing binlog_innodb to fail on Pushbuild.
Added cleanup of status variables to the end of binlog_database.
Re-recorded .result file to account for cleanup statement.
NOTE:  binlog.binlog_innodb also has had an FLUSH STATUS; statement added to it as well, but
adding this cleanup as a preventative measure.
2009-01-12 18:45:35 -05:00
Sven Sandberg
d20aba9409 BUG#37718: rpl.rpl_stm_mystery22 fails sporadically on pushbuild
Problem 1: The test waits for an error in the slave sql thread,
then resolves the error and issues 'start slave'. However, there
is a gap between when the error is reported and the slave sql
thread stops. If this gap was long, the slave would still be
running when 'start slave' happened, so 'start slave' would fail
and cause a test failure.
Fix 1: Made wait_for_slave_sql_error wait for the slave to stop
instead of wait for error in the IO thread. After stopping, the
error code is verified. If the error code is wrong, debug info
is printed. To print debug info, the debug printing code in
wait_for_slave_param.inc was moved out to a new file,
show_rpl_debug_info.inc.
Problem 2: rpl_stm_mystery22 is a horrible name, the comments in
the file didn't explain anything useful, the test was generally
hard to follow, and the test was essentially duplicated between
rpl_stm_mystery22 and rpl_row_mystery22.
Fix 2: The test is about conflicts in the slave SQL thread,
hence I renamed the tests to rpl_{stm,row}_conflicts. Refactored
the test so that the work is done in
extra/rpl_tests/rpl_conflicts.inc, and
rpl.rpl_{row,stm}_conflicts merely sets some variables and then
sourced extra/rpl_tests/rpl_conflicts.inc.
The tests have been rewritten and comments added.
Problem 3: When calling wait_for_slave_sql_error.inc, you always
want to verify that the sql thread stops because of the expected
error and not because of some other error. Currently,
wait_for_slave_sql_error.inc allows the caller to omit the error
code, in which case all error codes are accepted.
Fix 3: Made wait_for_slave_sql_error.inc fail if no error code
is given. Updated rpl_filter_tables_not_exist accordingly.
Problem 4: rpl_filter_tables_not_exist had a typo, the dollar
sign was missing in a 'let' statement.
Fix 4: Added dollar sign.
Problem 5: When replicating from other servers than the one named
'master', the wait_for_slave_* macros were unable to print debug
info on the master.
Fix 5: Replace parameter $slave_keep_connection by
$master_connection.


mysql-test/extra/rpl_tests/rpl_conflicts.test:
  rpl_stm_mystery22 and rpl_row_mystery22 have now been refactored and renamed:
  The two test cases rpl.rpl_stm_conflicts.test and rpl.rpl_row_conflicts.test
  just set some parameters, and then source include/rpl_tests/rpl_conflicts.test.
  Also, cleaned up the test case a bit, and fixed BUG#37718.
mysql-test/include/show_rpl_debug_info.inc:
  Factored out the debug printing code from wait_for_slave_param.inc to
  a new file, show_rpl_debug_info.inc.
  Also removed the $slave_keep_connection parameter, and replaced it by
  $master_connection. This allows printing debug info on the master, no
  matter what the name of the master connection is.
mysql-test/include/start_slave.inc:
  Replaced $slave_keep_connection by $master_connection.
mysql-test/include/stop_slave.inc:
  Replaced $slave_keep_connection by $master_connection.
mysql-test/include/sync_slave_io_with_master.inc:
  Replaced $slave_keep_connection by $master_connection.
mysql-test/include/wait_for_slave_io_to_start.inc:
  Replaced $slave_keep_connection by $master_connection.
mysql-test/include/wait_for_slave_io_to_stop.inc:
  Replaced $slave_keep_connection by $master_connection.
mysql-test/include/wait_for_slave_param.inc:
  Factored out the debug printing code from wait_for_slave_param.inc to
  a new file, show_rpl_debug_info.inc.
  Also removed the $slave_keep_connection parameter, and replaced it by
  $master_connection. This allows printing debug info on the master, no
  matter what the name of the master connection is.
  Had to move the printing of debug info out of the while loop because
  of BUG number 41913.
mysql-test/include/wait_for_slave_sql_error.inc:
  Made it wait until the slave sql thread has stopped. This
  takes very short time and avoids race condition bugs in
  test cases (e.g., fixes BUG#37718).
  Replaced $slave_keep_connection by $master_connection.
mysql-test/include/wait_for_slave_sql_error_and_skip.inc:
  Since wait_for_slave_sql_error now waits for the slave sql
  thread to stop too, wait_for_slave_sql_error_and_skip does not
  have to wait for the slave sql thread to stop.
  Also, since wait_for_slave_sql_error now requires the parameter
  $slave_sql_errno to be set, wait_for_slave_sql_error_and_skip
  requires that as well: updated the usage instructions.
mysql-test/include/wait_for_slave_sql_to_start.inc:
  Replaced $slave_keep_connection by $master_connection.
mysql-test/include/wait_for_slave_sql_to_stop.inc:
  Replaced $slave_keep_connection by $master_connection.
mysql-test/include/wait_for_slave_to_start.inc:
  Replaced $slave_keep_connection by $master_connection.
mysql-test/include/wait_for_slave_to_stop.inc:
  Replaced $slave_keep_connection by $master_connection.
mysql-test/suite/rpl/r/rpl_row_conflicts.result:
  update result file
mysql-test/suite/rpl/r/rpl_stm_conflicts.result:
  update result file
mysql-test/suite/rpl/t/rpl_dual_pos_advance.test:
  Replaced $slave_keep_connection by $master_connection.
mysql-test/suite/rpl/t/rpl_filter_tables_not_exist.test:
  Set $slave_sql_errno, since it is now required.
  Add dollar sign to $show_sql_error (without dollar sign,
  mtr makes it an environment variable).
mysql-test/suite/rpl/t/rpl_row_conflicts.test:
  rpl_stm_mystery22 and rpl_row_mystery22 have now been refactored and renamed:
  The two test cases rpl.rpl_stm_conflicts.test and rpl.rpl_row_conflicts.test
  just set some parameters, and then source include/rpl_tests/rpl_conflicts.test.
  Also, cleaned up the test case a bit, and fixed BUG#37718.
mysql-test/suite/rpl/t/rpl_row_mystery22.test:
  rpl_stm_mystery22 and rpl_row_mystery22 have now been refactored and renamed:
  The two test cases rpl.rpl_stm_conflicts.test and rpl.rpl_row_conflicts.test
  just set some parameters, and then source include/rpl_tests/rpl_conflicts.test.
  Also, cleaned up the test case a bit, and fixed BUG#37718.
mysql-test/suite/rpl/t/rpl_stm_conflicts.test:
  rpl_stm_mystery22 and rpl_row_mystery22 have now been refactored and renamed:
  The two test cases rpl.rpl_stm_conflicts.test and rpl.rpl_row_conflicts.test
  just set some parameters, and then source include/rpl_tests/rpl_conflicts.test.
  Also, cleaned up the test case a bit, and fixed BUG#37718.
2009-01-09 15:12:31 +01:00
Serge Kozlov
4ae3c11cca Bug#41108: It is a testcase timeout bug so the patch fixes test code in places
where timeout can happen:
1. Added waiting start/stop slave to make sure that slave works properly.
2. Added cleanup for slave.
3. Updated related result files.
2008-12-12 14:34:18 +03:00
Sven Sandberg
ca59e88ce3 BUG#38350: Many tests don't clean up after themselves on exit.
Problem: Many test cases don't clean up after themselves (fail
to drop tables or fail to reset variables). This implies that:
(1) check-testcase in the new mtr that currently lives in
5.1-rpl failed. (2) it may cause unexpected results in
subsequent tests.
Fix: make all tests clean up.
Also: cleaned away unnecessary output in rpl_packet.result
Also: fixed bug where rpl_log called RESET MASTER with a running
slave. This is not supposed to work.
Also: removed unnecessary code from rpl_stm_EE_err2 and made it
verify that an error occurred.
Also: removed unnecessary code from rpl_ndb_ctype_ucs2_def.


mysql-test/extra/rpl_tests/rpl_loaddata.test:
  Made test clean up after itself.
mysql-test/extra/rpl_tests/rpl_stm_EE_err2.test:
  Made test clean up after itself.
  Also removed unnecessary save_master_pos.
  Also made test verify that an error occurred.
mysql-test/extra/rpl_tests/rpl_truncate_helper.test:
  Made test clean up after itself.
mysql-test/include/query_cache.inc:
  Made test clean up after itself.
mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test:
  Made test clean up after itself.
mysql-test/suite/rpl/t/rpl_alter_db.test:
  Made test clean up after itself.
  Easiest to refactor the test a little, to use an auxiliary database instead of mysql:
  Then we don't need to read the collation at the start of the test and reset it at the
  end of the test. We can just drop the database.
mysql-test/suite/rpl/t/rpl_drop_db.test:
  Made test clean up after itself.
mysql-test/suite/rpl/t/rpl_drop_view.test:
  Made test clean up after itself.
mysql-test/suite/rpl/t/rpl_events.test:
  Made test clean up after itself.
mysql-test/suite/rpl/t/rpl_idempotency.test:
  Made test clean up after itself.
mysql-test/suite/rpl/t/rpl_ignore_table.test:
  Made test clean up after itself.
  The existing cleanup code didn't work, because the --replicate-*
  options prevented the "drop table" from being replicated. Moved
  "drop table t4" to a statement of its own.
mysql-test/suite/rpl/t/rpl_packet.test:
  Made test clean up after itself.
  Also replaced SHOW SLAVE STATUS by query_get_value(SHOW SLAVE STATUS...),
  since only one column of the result was interesting.
mysql-test/suite/rpl/t/rpl_row_max_relay_size.test:
  Made test clean up after itself.
  Instead of setting binlog format at the beginning of the test, we just
  do 'source include/have_binlog_format_row.inc' like all other tests.
mysql-test/suite/rpl_ndb/t/rpl_ndb_2other.test:
  Made test clean up after itself.
mysql-test/suite/rpl_ndb/t/rpl_ndb_ctype_ucs2_def.test:
  Made test clean up after itself.
  Also removed unnecessary 'create table; drop table'
  Also removed unnecessary use of --command
mysql-test/suite/rpl_ndb/t/rpl_ndb_multi.test:
  Made test clean up after itself.
mysql-test/t/innodb-autoinc-optimize.test:
  Made test clean up after itself.
mysql-test/t/innodb.test:
  Made test clean up after itself.
mysql-test/t/log_tables.test:
  Made test clean up after itself.
mysql-test/t/mysql_client_test.test:
  Made test clean up after itself.
mysql-test/t/partition.test:
  Made test clean up after itself.
mysql-test/t/status.test:
  Made test clean up after itself.
2008-11-13 20:19:00 +01:00
Andrei Elkin
ca2d184695 merging 5.1 -> 5.1 rpl. 3 of 4 conflicts are resolved similarly to 6.0->6.0-rpl merging.
mysql_upgrade results changed due to the error messesge of mysqlcheck has changed.
2008-11-12 19:51:47 +02:00