summaryrefslogtreecommitdiff
path: root/sql/slave.cc
diff options
context:
space:
mode:
authorunknown <mats@romeo.(none)>2007-04-12 08:58:04 +0200
committerunknown <mats@romeo.(none)>2007-04-12 08:58:04 +0200
commit6ed9fc6b7a64bafe85186eb37db8593b8ef2acbc (patch)
tree751a12cfad714ca627a74b77e5a1ed3ef9a68b5e /sql/slave.cc
parent6d9d64baab8537e465659daab77d2a9fd1a286ff (diff)
downloadmariadb-git-6ed9fc6b7a64bafe85186eb37db8593b8ef2acbc.tar.gz
BUG#25688 (RBR: circular replication may cause STMT_END_F flags to be
skipped): By moving statement end actions from Rows_log_event::do_apply_event() to Rows_log_event::do_update_pos() they will always be executed, even if Rows_log_event::do_apply_event() is skipped because the event originated at the same server. This because Rows_log_event::do_update_pos() is always executed (unless Rows_log_event::do_apply_event() failed with an error, in which case the slave stops with an error anyway). Adding test case. Fixing logic to detect if inside a group. If a rotate event occured when an initial prefix of events for a statement, but for which the table did contain a key, last_event_start_time is set to zero, causing rotate to end the group but without unlocking any tables. This left a lock hanging around, which subsequently triggered an assertion when a second attempt was made to lock the same sequence of tables. In order to solve the above problem, a new flag was added to the relay log info structure that is used to indicate that the replication thread is currently executing a statement. Using this flag, the replication thread is in a group if it is either in a statement or inside a trans- action. The patch also eliminates some gratuitous header file inclusions that were not needed (and caused compile errors) and replaced them with forward definitions. sql/item_func.cc: Including definition of MASTER_INFO. sql/log.cc: Including definition of RELAY_LOG_INFO since it is used in the file. sql/log_event.cc: Moving statement end actions from Rows_log_event::do_apply_event() to Rows_log_event::do_update_pos(). Factoring out code to update group positions and event positions into relay log info structure. --- Adding debugging printouts. Fixing logic to detect if inside a group. sql/log_event.h: Adding Rows_log_event::do_update_pos(). sql/mysqld.cc: Including definition of MASTER_INFO. sql/repl_failsafe.cc: Including definition of MASTER_INFO. sql/rpl_mi.h: Including definition of RELAY_LOG_INFO since it is used in the file. sql/rpl_rli.cc: Adding member function stmt_done() to do after-statement updates of the relay log info structure. sql/rpl_rli.h: Adding member function stmt_done() to do after-statement updates of the relay log info structure. sql/set_var.cc: Including definition of MASTER_INFO. sql/slave.cc: Adding debuging printouts. sql/slave.h: Removing inclusion definitions of MASTER_INFO and RELAY_LOG_INFO and replacing them with forward declarations since the classes are not used in the file. The gratuitous inclusion lead to compile errors in the two classes above in files that used neither. sql/sql_binlog.cc: Including definition of RELAY_LOG_INFO since it is used in the file. sql/sql_class.cc: Including definition of RELAY_LOG_INFO since it is used in the file. sql/sql_class.h: Removing inclusion definitions of RELAY_LOG_INFO and replacing it with forward declaration since the class is not used in the file. The gratuitous inclusion lead to compile errors in the class above in files didn't use the class. sql/sql_insert.cc: Including definition of MASTER_INFO. sql/sql_repl.cc: Including definition of MASTER_INFO. mysql-test/r/rpl_ndb_circular_simplex.result: New BitKeeper file ``mysql-test/r/rpl_ndb_circular_simplex.result'' mysql-test/t/rpl_ndb_circular_simplex.test: New BitKeeper file ``mysql-test/t/rpl_ndb_circular_simplex.test''
Diffstat (limited to 'sql/slave.cc')
-rw-r--r--sql/slave.cc40
1 files changed, 21 insertions, 19 deletions
diff --git a/sql/slave.cc b/sql/slave.cc
index bc6cef95fc6..cd939bd092f 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -17,8 +17,9 @@
#include <mysql.h>
#include <myisam.h>
-#include "rpl_rli.h"
#include "slave.h"
+#include "rpl_mi.h"
+#include "rpl_rli.h"
#include "sql_repl.h"
#include "rpl_filter.h"
#include "repl_failsafe.h"
@@ -1731,11 +1732,12 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
/*
*/
- DBUG_PRINT("info",("type_code=%d (%s), server_id=%d",
- type_code, ev->get_type_str(), ev->server_id));
- DBUG_PRINT("info", ("thd->options={ %s%s}",
+ DBUG_PRINT("exec_event",("%s(type_code: %d; server_id: %d)",
+ ev->get_type_str(), type_code, ev->server_id));
+ DBUG_PRINT("info", ("thd->options: %s%s; rli->last_event_start_time: %lu",
FLAGSTR(thd->options, OPTION_NOT_AUTOCOMMIT),
- FLAGSTR(thd->options, OPTION_BEGIN)));
+ FLAGSTR(thd->options, OPTION_BEGIN),
+ rli->last_event_start_time));
@@ -1777,21 +1779,21 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
if (reason == Log_event::EVENT_SKIP_NOT)
exec_res= ev->apply_event(rli);
#ifndef DBUG_OFF
- else
- {
- /*
- This only prints information to the debug trace.
+ /*
+ This only prints information to the debug trace.
- TODO: Print an informational message to the error log?
- */
- static const char *const explain[] = {
- "event was not skipped", // EVENT_SKIP_NOT,
- "event originated from this server", // EVENT_SKIP_IGNORE,
- "event skip counter was non-zero" // EVENT_SKIP_COUNT
- };
- DBUG_PRINT("info", ("%s was skipped because %s",
- ev->get_type_str(), explain[reason]));
- }
+ TODO: Print an informational message to the error log?
+ */
+ static const char *const explain[] = {
+ // EVENT_SKIP_NOT,
+ "not skipped",
+ // EVENT_SKIP_IGNORE,
+ "skipped because event originated from this server",
+ // EVENT_SKIP_COUNT
+ "skipped because event skip counter was non-zero"
+ };
+ DBUG_PRINT("skip_event", ("%s event was %s",
+ ev->get_type_str(), explain[reason]));
#endif
DBUG_PRINT("info", ("apply_event error = %d", exec_res));