Commit graph

58157 commits

Author SHA1 Message Date
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
Andrei Elkin
d91aa57c38 backporting bug@27808 fixes 2009-10-01 19:44:53 +03:00
Luis Soares
a367c88c9e Partial backport for BUG#41399, more precisely, the changes to
wait_until_disconnected.inc.
2009-10-01 00:32:15 +01:00
Alfranio Correia
5c25d17c4e BUG#43075 rpl.rpl_sync fails sporadically on pushbuild
NOTE: Backporting the patch to next-mr.
      
The slave was crashing while failing to execute the init_slave() function.
      
The issue stems from two different reasons:
      
1 - A failure while allocating the master info structure generated a
    segfault due to a NULL pointer.
      
2 - A failure while recovering generated a segfault due to a non-initialized
    relay log file. In other words, the mi->init and rli->init were both set to true
    before executing the recovery process thus creating an inconsistent state as the
    relay log file was not initialized.
      
To circumvent such problems, we refactored the recovery process which is now executed
while initializing the relay log. It is ensured that the master info structure is
created before accessing it and any error is propagated thus avoiding to set mi->init
and rli->init to true when for instance the relay log is not initialized or the relay
info is not flushed.
      
The changes related to the refactory are described below:
      
1 - Removed call to init_recovery from init_slave.
      
2 - Changed the signature of the function init_recovery.
      
3 - Removed flushes. They are called while initializing the relay log and master
    info.
      
4 - Made sure that if the relay info is not flushed the mi-init and rli-init are not
    set to true.
      
In this patch, we also replaced the exit(1) in the fault injection by DBUG_ABORT()
to make it compliant with the code guidelines.
2009-09-30 22:41:05 +01:00
Luis Soares
8f43e00841 BUG#47749: rpl_slave_skip fails sporadically on PB2 (mysql-5.1-rep+2 tree).
rpl_slave_skip fails randomly on PB2. This patch fixes the failure by
setting explicit wait for SQL thread to stop, instead of the 
wait_for_slave_to_stop mysqltest command, after a start until command 
is executed.
2009-09-30 17:42:25 +01: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
Luis Soares
2f51f75825 Automerge: mysql-5.1-rep+2 (local backports) --> mysql-5.1-rep+2 (local latest) 2009-09-30 12:48:22 +01:00
Alfranio Correia
3ab71376ce BUG#40337 Fsyncing master and relay log to disk after every event is too slow
NOTE: Backporting the patch to next-mr.
      
The fix proposed in BUG#35542 and BUG#31665 introduces a performance issue
when fsyncing the master.info, relay.info and relay-log.bin* after #th events.
Although such solution has been proposed to reduce the probability of corrupted
files due to a slave-crash, the performance penalty introduced by it has
made the approach impractical for highly intensive workloads.
      
In a nutshell, the option --syn-relay-log proposed in BUG#35542 and BUG#31665
simultaneously fsyncs master.info, relay-log.info and relay-log.bin* and
this is the main source of performance issues.
      
This patch introduces new options that give more control to the user on
what should be fsynced and how often:
      
   1) (--sync-master-info, integer) which syncs the master.info after #th event;
   2) (--sync-relay-log, integer) which syncs the relay-log.bin* after #th
   events.
   3) (--sync-relay-log-info, integer) which syncs the relay.info after #th
   transactions.
      
   To provide both performance and increased reliability, we recommend the following
   setup:
      
   1) --sync-master-info = 0 eventually the operating system will fsync it;
   2) --sync-relay-log = 0 eventually the operating system will fsync it;
   3) --sync-relay-log-info = 1 fsyncs it after every transaction;
      
Notice, that the previous setup does not reduce the probability of
corrupted master.info and relay-log.bin*. To overcome the issue, this patch also
introduces a recovery mechanism that right after restart throws away relay-log.bin*
retrieved from a master and updates the master.info based on the relay.info:
      
      
   4) (--relay-log-recovery, boolean) which enables a recovery mechanism that
   throws away relay-log.bin* after a crash.
      
However, it can only recover the incorrect binlog file and position in master.info,
if other informations (host, port password, etc) are corrupted or incorrect,
then this recovery mechanism will fail to work.
2009-09-29 15:40:52 +01:00
Alfranio Correia
0110bd04d2 BUG#35542 Add option to sync master and relay log to disk after every event
BUG#31665 sync_binlog should cause relay logs to be synchronized

NOTE: Backporting the patch to next-mr.
      
Add sync_relay_log option to server, this option works for relay log 
the same as option sync_binlog for binlog. This option also synchronize
master info to disk when set to non-zero value.
            
Original patches from Sinisa and Mark, with some modifications
2009-09-29 15:27:12 +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
Luis Soares
ba98c88272 BUG#42928: binlog-format setting prevents server from start if binary
logging is disabled
      
NOTE: this is the backport to next-mr.
            
If one sets binlog-format but does NOT enable binary log, server
refuses to start up. The following messages appears in the error log:
            
090217 12:47:14 [ERROR] You need to use --log-bin to make
--binlog-format work.  
090217 12:47:14 [ERROR] Aborting
            
This patch addresses this by making the server not to bail out if the
binlog-format is set without the log-bin option. Additionally, the
specified binlog-format is stored, in the global system variable
"binlog_format", and a warning is printed instead of an error.
2009-09-29 15:12:43 +01:00
Luis Soares
b79b335033 BUG#40611: MySQL cannot make a binary log after sequential number
beyond unsigned long.
BUG#44779: binlog.binlog_max_extension may be causing failure on 
next test in PB
      
NOTE1: this is the backport to next-mr.
NOTE2: already includes patch for BUG#44779.
      
Binlog file extensions would turn into negative numbers once the
variable used to hold the value reached maximum for signed
long. Consequently, incrementing value to the next (negative) number
would lead to .000000 extension, causing the server to fail.
                  
This patch addresses this issue by not allowing negative extensions
and by returning an error on find_uniq_filename, when the limit is
reached. Additionally, warnings are printed to the error log when the
limit is approaching. FLUSH LOGS will also report warnings to the
user, if the extension number has reached the limit. The limit has been
set to 0x7FFFFFFF as the maximum.

mysql-test/suite/binlog/t/binlog_max_extension.test:
  Test case added that checks the maximum available number for
  binlog extensions.
sql/log.cc:
  Changes to find_uniq_filename and test_if_number.
sql/log.h:
  Added macros with values for MAX_LOG_UNIQUE_FN_EXT and
  LOG_WARN_UNIQUE_FN_EXT_LEFT, as suggested in review.
2009-09-29 15:12:07 +01:00
Luis Soares
b538536718 Bug #30703 SHOW STATUS LIKE 'Slave_running' is not compatible with `SHOW SLAVE
STATUS'
      
NOTE: this is the backport to next-mr.
            
SHOW SHOW STATUS LIKE 'Slave_running' command believes that
if active_mi->slave_running != 0, then io thread is running normally.
But it isn't so in fact. When some errors happen to make io thread
try to reconnect master, then it will become transitional status
(MYSQL_SLAVE_RUN_NOT_CONNECT == 1), which also doesn't equal 0.
Yet, "SHOW SLAVE STATUS" believes that only if
active_mi->slave_running == MYSQL_SLAVE_RUN_CONNECT, then io thread is running.
So "SHOW SLAVE STATUS" can get the correct result.
            
            
Fixed to make SHOW SHOW STATUS LIKE 'Slave_running' command have the same
check condition with "SHOW SLAVE STATUS". It only believe that the io thread
is running when active_mi->slave_running == MYSQL_SLAVE_RUN_CONNECT.
2009-09-29 15:10:37 +01:00
Luis Soares
b43d30e43a BUG#28796: CHANGE MASTER TO MASTER_HOST="" leads to invalid master.info
NOTE: this is the backport to next-mr.
                
This patch addresses the bug reported by checking wether 
host argument is an empty string or not. If empty, an error is
reported to the client, otherwise continue normally.
                       
This commit is based on the originally proposed patch and adds 
a test case as requested during review as well as refines comments, 
and makes test case result file less verbose (compared to previous patch).
2009-09-29 15:09:46 +01:00
Luis Soares
01cdba58ba BUG#23300: Slow query log on slave does not log slow replicated statements
NOTE: this is the backport to next-mr.
      
When using replication, the slave will not log any slow query logs queries 
replicated from the master, even if the option "--log-slow-slave-statements" 
is set and these take more than "log_query_time" to execute.
              
In order to log slow queries in replicated thread one needs to set the
--log-slow-slave-statements, so that the SQL thread is initialized with the 
correct switch. Although setting this flag correctly configures the slave 
thread option to log slow queries, there is an issue with the condition that 
is used to check whether to log the slow query or not. When replaying binlog 
events the statement contains the SET TIMESTAMP clause which will force the 
slow logging condition check to fail. Consequently, the slow query logging will
not take place.
              
This patch addresses this issue by removing the second condition from the
log_slow_statements as it prevents slow queries to be binlogged and seems 
to be deprecated.
2009-09-29 15:09:01 +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
Alfranio Correia
b7f887652b WL#4828 and BUG#45747
NOTE: Backporting the patch to next-mr.

WL#4828 Augment DBUG_ENTER/DBUG_EXIT to crash MySQL in different functions
-------

The assessment of the replication code in the presence of faults is extremely
import to increase reliability. In particular, one needs to know if servers
will either correctly recovery or print out appropriate error messages thus
avoiding unexpected problems in a production environment.

In order to accomplish this, the current patch refactories the debug macros
already provided in the source code and introduces three new macros that
allows to inject faults, specifically crashes, while entering or exiting a
function or method. For instance, to crash a server while returning from
the init_slave function (see module sql/slave.cc), one needs to do what
follows:

1 - Modify the source replacing DBUG_RETURN by DBUG_CRASH_RETURN;

  DBUG_CRASH_RETURN(0);

2 - Use the debug variable to activate dbug instructions:

  SET SESSION debug="+d,init_slave_crash_return";

The new macros are briefly described below:

DBUG_CRASH_ENTER (function) is equivalent to DBUG_ENTER which registers the
beginning of a function but in addition to it allows for crashing the server
while entering the function if the appropriate dbug instruction is activate.
In this case, the dbug instruction should be "+d,function_crash_enter".

DBUG_CRASH_RETURN (value) is equivalent to DBUG_RETURN which notifies the
end of a function but in addition to it allows for crashing the server
while returning from the function if the appropriate dbug instruction is
activate. In this case, the dbug instruction should be
"+d,function_crash_return". Note that "function" should be the same string
used by either the DBUG_ENTER or DBUG_CRASH_ENTER.

DBUG_CRASH_VOID_RETURN (value) is equivalent to DBUG_VOID_RETURN which
notifies the end of a function but in addition to it allows for crashing
the server while returning from the function if the appropriate dbug
instruction is activate. In this case, the dbug instruction should be
"+d,function_crash_return". Note that "function" should be the same string
used by either the DBUG_ENTER or DBUG_CRASH_ENTER.

To inject other faults, for instance, wrong return values, one should rely
on the macros already available. The current patch also removes a set of
macros that were either not being used or were redundant as other macros
could be used to provide the same feature. In the future, we also consider
dynamic instrumentation of the code.


BUG#45747 DBUG_CRASH_* is not setting the strict option
---------
      
When combining DBUG_CRASH_* with "--debug=d:t:i:A,file" the server crashes
due to a call to the abort function in the DBUG_CRASH_* macro althought the
appropriate keyword has not been set.
2009-09-29 14:55:36 +01:00
Alfranio Correia
569ca8590c BUG#44663 Unused replication options prevent server from starting.
NOTE: Backporting the patch to next-mr.
            
The use of option log_slave_updates without log_bin was preventing the server
from starting. To fix the problem, we replaced the error message and the exit
call by a warning message.
2009-09-29 14:38:32 +01:00
Andrei Elkin
c676cebbea WL#342 heartbeat
Improving an error report generating.
2009-09-29 14:37:52 +03:00
Andrei Elkin
f6a8698a54 WL#342 heartbeat
Backporting the basic tests
2009-09-29 14:18:41 +03: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
d94e279c7c Fixed tree_name: mysql-5.1 --> mysql-5.1-rep+2 2009-09-29 00:13:56 +01: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
Mats Kindahl
fbe6a4a7dd Disabling tests that are not relevant after BUG#40116, these will be enabled
when WL#2867 or associated fixes for 5.1 is added to solve the problem.
2009-09-28 13:44:45 +02:00
Mats Kindahl
5d2f79def9 Bug #47645: Segmentation fault when out of memory during handlerton initialization
There is a missing check for memory allocation failure when allocating
memory for the handlerton structure. If the handlerton init function
tries to de-reference the pointer, it will cause a segmentation fault
and crash the server.

This patch fixes the problem by not calling the init function if memory
allocation failed, and instead prints an informative error message and
reports the error to the caller.

sql/handler.cc:
  Add a check if memory allocation succeeded before calling the init
  function. If it failed, it is not necessary to free the memory,
  but the plugin->data is set to NULL to ensure that it can be checked
  for failure.
2009-09-25 11:47:15 +02:00
Mats Kindahl
d47710c8dc WL#5016: Fix header file include guards
Adding header include file guards to files that are missing such.
2009-09-23 23:32:31 +02: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
Mats Kindahl
8249fd6eef BUG#29288: myisam transactions replicated to a transactional
slave leaves slave unstable

Problem: when replicating from non-transactional to
transactional engine with autocommit off, no BEGIN/COMMIT
is written to the binlog. When the slave replicates, it
will start a transaction that never ends.

Fix: Force autocommit=on on slave by always replicating
autocommit=1 from the master.
2009-09-23 11:43:43 +02:00
Bjorn Munch
0b9bc329b0 merge from 5.1-mtr 2009-09-03 19:07:35 +02:00
Jonathan Perkin
19d0529819 Raise version number after cloning 5.1.39 2009-09-03 18:20:43 +02:00
Bjorn Munch
3948eef1a1 3rd merge from main 2009-09-03 08:44:22 +02:00
Bjorn Munch
863b53e922 merge 2009-09-03 08:39:29 +02:00
Bjorn Munch
b5e3f4a358 A few suppression follow-ups 2009-09-03 08:38:06 +02:00
Bjorn Munch
4d676f314c Bug #47075 Wildcards in experimental test names destroyed when tested first time
Extract substr into local variable
2009-09-03 08:19:54 +02:00
Jonathan Perkin
0644b0acfa Merge from mysql-5.1.38-release 2009-09-03 01:48:06 +02: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
Georgi Kodinov
41427950ed null merge of 5.0 fixes backported from 5.1 2009-09-02 18:45:33 +03:00
Georgi Kodinov
b64e7fb5be fixed a valgrind warning in partition_pruning 2009-09-02 18:42:08 +03:00
Georgi Kodinov
183607b8c8 Backported the --parallel=str option from mtr2 for backward compatibility
with the newer pb2 testing environments
2009-09-02 16:36:52 +03:00
Georgi Kodinov
50d8792b58 merge 2009-09-02 16:07:52 +03:00
Georgi Kodinov
607c399f8b merge 2009-09-02 15:33:18 +03:00
Georgi Kodinov
dedcfe2f3d automerge 2009-09-02 15:22:32 +03:00
Georgi Kodinov
7c9e39f5c5 fixed a valgrind warning in partitioning code 2009-09-02 15:20:47 +03:00
Davi Arnaut
66aa565d78 Manual merge. 2009-09-02 09:12:18 -03:00
Davi Arnaut
e512d69434 Post-merge fix. Observe C declaration placement rules. 2009-09-02 09:02:22 -03:00
Davi Arnaut
3668f8a5be Increase thread stack size on HP-UX when built with debug. 2009-09-02 08:45:48 -03:00
Georgi Kodinov
453a941d50 moved version to 5.0-main 2009-09-02 13:23:37 +03:00
Georgi Kodinov
f0720480dc Fixed win32 compilation warnings 2009-09-02 13:22:47 +03:00