Below is the list of changes that have just been committed into a local
5.1 repository of mats. When mats does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-01-18 09:11:12+01:00, mats@romeo.(none) +1 -0
BUG#23171 (Illegal slave restart group position):
Tail patch: some missing changes that BitKeeper didn't find until
the merge.
sql/log_event.h@stripped, 2007-01-18 09:11:09+01:00, mats@romeo.(none) +165 -50
Adding Doxygen comments.
Implementing the guts of the new logic.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: mats
# Host: romeo.(none)
# Root: /home/bk/b23171-mysql-5.1-new-rpl
--- 1.137/sql/log_event.h 2007-01-18 09:11:20 +01:00
+++ 1.138/sql/log_event.h 2007-01-18 09:11:20 +01:00
@@ -558,6 +558,13 @@
class Log_event
{
public:
+ enum enum_skip_reason {
+ EVENT_NOT_SKIPPED,
+ EVENT_SKIP_SAME_SID,
+ EVENT_SKIP_COUNT
+ };
+
+
/*
The offset in the log where this event originally appeared (it is
preserved in relay logs, making SHOW SLAVE STATUS able to print
@@ -633,26 +640,29 @@
#ifdef HAVE_REPLICATION
int net_send(Protocol *protocol, const char* log_name, my_off_t pos);
-
/**
Execute the event to change the database and update the binary
log coordinates.
- @param rli Pointer to relay log information
+ The event will be executed unless it is supposed to be skipped.
- @retval 0 The event was successfully executed.
- @retval errno Error code when the execution failed
- */
+ @pre The @c rli->data_lock shall be locked.
- int exec_event(RELAY_LOG_INFO *rli)
- {
- // !!! Just chaining the calls in this first patch
- return apply_event_impl(rli);
- }
+ @post The @c rli->data_lock will be unlocked.
+ @note It is assumed that the @c rli->data_lock is locked before
+ calling this routine. This is because the lock has to be released
+ after performing any necessary changes during the skip section of
+ the code. The mutex is locked in exec_relay_log_event() to check
+ some until conditions, so this is why it's needed here.
- /**
- Skip the event by just updating the binary log coordinates.
+ @todo Move the until condition checking into the Log_event class
+ to eliminate the need for pre-locking the mutex.
+
+ @see exec_relay_log_event
+ @see shall_skip
+ @see do_apply_event
+ @see do_update_pos
@param rli Pointer to relay log information
@@ -660,10 +670,29 @@
@retval errno Error code when the execution failed
*/
- int skip_event(RELAY_LOG_INFO *rli)
+ int exec_event(RELAY_LOG_INFO *rli)
{
- // !!! Nothing yet. This is just the reorgainization patch.
- return 0;
+ DBUG_ENTER("exec_event");
+ safe_mutex_assert_owner(&rli->data_lock);
+ int reason= shall_skip(rli);
+ int error= 0;
+ char buf[22];
+ if (reason == EVENT_SKIP_COUNT)
+ --rli->slave_skip_counter;
+ pthread_mutex_unlock(&rli->data_lock);
+ if (reason == EVENT_NOT_SKIPPED)
+ if ((error= do_apply_event(rli)))
+ DBUG_RETURN(error);
+ DBUG_PRINT("info", ("apply_event error = %d", error));
+ error= do_update_pos(rli);
+ DBUG_PRINT("info", ("update_pos error = %d", error));
+ DBUG_PRINT("info", ("group %s %s",
+ llstr(rli->group_relay_log_pos, buf),
+ rli->group_relay_log_name));
+ DBUG_PRINT("info", ("event %s %s",
+ llstr(rli->event_relay_log_pos, buf),
+ rli->event_relay_log_name));
+ DBUG_RETURN(error);
}
@@ -747,19 +776,28 @@
/* returns the human readable name of the event's type */
const char* get_type_str();
-protected: /* !!! Protected in this patch to allow old usage */
+protected:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
/**
Primitive to apply an event to the database.
This is where the change to the database is made.
+ @note The primitive is protected instead of private, since there
+ is a hierarchy of actions to be performed in some cases.
+
+ @see Format_description_log_event::do_apply_event()
+
@param rli Pointer to relay log info structure
@retval 0 Event applied successfully
@retval errno Error code if event application failed
*/
- virtual int apply_event_impl(RELAY_LOG_INFO *rli);
+ virtual int do_apply_event(RELAY_LOG_INFO const *rli)
+ {
+ return 0; /* Default implementation does nothing */
+ }
+
/**
Advance binary log coordinates.
@@ -772,11 +810,54 @@
@retval 0 Coordinates changed successfully
@retval errno Error code if advancing failed
*/
- virtual int advance_coord_impl(RELAY_LOG_INFO *rli)
- {
- // !!! Dummy implementation for this patch only
- return 0;
+ virtual int do_update_pos(RELAY_LOG_INFO *rli);
+
+ /**
+ Skip this event if it should be skipped and update skipping
+ information accordingly.
+
+ The default implementation will skip the event if either:
+
+ - the server id of the event is the same as the server id of the
+ server and <code>replicate_same_server_id</code> is true, or
+
+ - if <code>rli->slave_skip_counter</code> is greater than zero.
+
+ @see do_apply_event
+ @see do_update_pos
+
+ @retval ERR_EVENT_NOT_SKIPPED
+ The event shall not be skipped and should be applied.
+
+ @retval ERR_EVENT_SKIP_SAME_SID
+ The event shall be skipped because the server id of the event is
+ identical to the server id of the server.
+
+ @retval ERR_EVENT_SKIP_COUNT
+ The event shall be skipped because the slave skip counter was
+ non-zero. The caller shall decrease the counter by one.
+ */
+ virtual enum_skip_reason shall_skip(RELAY_LOG_INFO *rli);
+
+ /**
+ Decide if it is allowed to stop after execution of this event.
+
+ In some situations, it is not possible to stop right after an
+ event since it can be in the middle of an execution group. This
+ member function is used to check if this event is in such a
+ situation that stopping here might lead to failures when
+ restarting.
+
+ @param rli Pointer to relay log information
+
+ @retval true We can safely stop after this event
+ @retval false We cannot stop safely after this event
+ */
+ virtual bool can_stop_safely(RELAY_LOG_INFO const *rli) const {
+ /* !!! Not Yet Implemted !!! */
+ return true;
}
+
#endif
};
@@ -818,8 +899,8 @@
uint16 error_code;
ulong thread_id;
/*
- For events created by Query_log_event::apply_event_impl (and
- Load_log_event::apply_event_impl()) we need the *original* thread
+ For events created by Query_log_event::do_apply_event (and
+ Load_log_event::do_apply_event()) we need the *original* thread
id, to be able to log the event with the original (=master's)
thread id (fix for BUG#1686).
*/
@@ -913,8 +994,10 @@
public: /* !!! Public in this patch to allow old usage */
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
- virtual int apply_event_impl(RELAY_LOG_INFO* rli);
- int apply_event_impl(RELAY_LOG_INFO* rli,
+ virtual int do_apply_event(RELAY_LOG_INFO const *rli);
+ virtual int do_update_pos(RELAY_LOG_INFO *rli);
+
+ int do_apply_event(RELAY_LOG_INFO const *rli,
const char *query_arg,
uint32 q_len_arg);
#endif /* HAVE_REPLICATION */
@@ -981,7 +1064,7 @@
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
- virtual int apply_event_impl(RELAY_LOG_INFO* rli);
+ virtual int do_apply_event(RELAY_LOG_INFO const* rli);
#endif
};
@@ -1086,12 +1169,12 @@
public: /* !!! Public in this patch to allow old usage */
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
- virtual int apply_event_impl(RELAY_LOG_INFO* rli)
+ virtual int do_apply_event(RELAY_LOG_INFO const* rli)
{
- return apply_event_impl(thd->slave_net,rli,0);
+ return do_apply_event(thd->slave_net,rli,0);
}
- int apply_event_impl(NET* net, RELAY_LOG_INFO* rli,
+ int do_apply_event(NET *net, RELAY_LOG_INFO const *rli,
bool use_rli_only_for_errors);
#endif
};
@@ -1171,9 +1254,20 @@
}
virtual bool is_artificial_event() { return artificial_event; }
-protected: /* !!! Protected in this patch to allow old usage */
+protected:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
- virtual int apply_event_impl(RELAY_LOG_INFO* rli);
+ virtual int do_apply_event(RELAY_LOG_INFO const *rli);
+ virtual enum_skip_reason shall_skip(RELAY_LOG_INFO*)
+ {
+ /*
+ Events from ourself should be skipped, but they should not
+ decrease the slave skip counter.
+ */
+ if (this->server_id == ::server_id)
+ return Log_event::EVENT_SKIP_SAME_SID;
+ else
+ return Log_event::EVENT_NOT_SKIPPED;
+ }
#endif
};
@@ -1222,9 +1316,11 @@
return FORMAT_DESCRIPTION_HEADER_LEN;
}
-private:
+protected:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
- virtual int apply_event_impl(RELAY_LOG_INFO* rli);
+ virtual int do_apply_event(RELAY_LOG_INFO const *rli);
+ virtual int do_update_pos(RELAY_LOG_INFO *rli);
+ virtual enum_skip_reason shall_skip(RELAY_LOG_INFO *rli);
#endif
};
@@ -1266,7 +1362,9 @@
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
- virtual int apply_event_impl(RELAY_LOG_INFO* rli);
+ virtual int do_apply_event(RELAY_LOG_INFO const *rli);
+ virtual int do_update_pos(RELAY_LOG_INFO *rli);
+ virtual enum_skip_reason shall_skip(RELAY_LOG_INFO *rli);
#endif
};
@@ -1310,7 +1408,9 @@
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
- virtual int apply_event_impl(RELAY_LOG_INFO* rli);
+ virtual int do_apply_event(RELAY_LOG_INFO const *rli);
+ virtual int do_update_pos(RELAY_LOG_INFO *rli);
+ virtual enum_skip_reason shall_skip(RELAY_LOG_INFO *rli);
#endif
};
@@ -1351,7 +1451,7 @@
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
- virtual int apply_event_impl(RELAY_LOG_INFO* rli);
+ virtual int do_apply_event(RELAY_LOG_INFO const *rli);
#endif
};
@@ -1396,7 +1496,9 @@
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
- virtual int apply_event_impl(RELAY_LOG_INFO* rli);
+ virtual int do_apply_event(RELAY_LOG_INFO const *rli);
+ virtual int do_update_pos(RELAY_LOG_INFO *rli);
+ virtual enum_skip_reason shall_skip(RELAY_LOG_INFO *rli);
#endif
};
@@ -1425,7 +1527,18 @@
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
- virtual int apply_event_impl(RELAY_LOG_INFO* rli);
+ virtual int do_update_pos(RELAY_LOG_INFO *rli);
+ virtual enum_skip_reason shall_skip(RELAY_LOG_INFO *rli)
+ {
+ /*
+ Events from ourself should be skipped, but they should not
+ decrease the slave skip counter.
+ */
+ if (this->server_id == ::server_id)
+ return Log_event::EVENT_SKIP_SAME_SID;
+ else
+ return Log_event::EVENT_NOT_SKIPPED;
+ }
#endif
};
@@ -1474,7 +1587,8 @@
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
- virtual int apply_event_impl(RELAY_LOG_INFO* rli);
+ virtual int do_update_pos(RELAY_LOG_INFO *rli);
+ virtual enum_skip_reason shall_skip(RELAY_LOG_INFO *rli);
#endif
};
@@ -1546,7 +1660,7 @@
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
- virtual int apply_event_impl(RELAY_LOG_INFO* rli);
+ virtual int do_apply_event(RELAY_LOG_INFO const *rli);
#endif
};
@@ -1600,7 +1714,7 @@
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
- virtual int apply_event_impl(RELAY_LOG_INFO* rli);
+ virtual int do_apply_event(RELAY_LOG_INFO const *rli);
#endif
};
@@ -1640,7 +1754,7 @@
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
- virtual int apply_event_impl(RELAY_LOG_INFO* rli);
+ virtual int do_apply_event(RELAY_LOG_INFO const *rli);
#endif
};
@@ -1679,7 +1793,7 @@
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
- virtual int apply_event_impl(RELAY_LOG_INFO* rli);
+ virtual int do_apply_event(RELAY_LOG_INFO const *rli);
#endif
};
@@ -1771,7 +1885,7 @@
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
- virtual int apply_event_impl(RELAY_LOG_INFO* rli);
+ virtual int do_apply_event(RELAY_LOG_INFO const *rli);
#endif
};
@@ -1880,7 +1994,8 @@
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
- virtual int apply_event_impl(RELAY_LOG_INFO* rli);
+ virtual int do_apply_event(RELAY_LOG_INFO const *rli);
+ virtual int do_update_pos(RELAY_LOG_INFO *rli);
#endif
#ifndef MYSQL_CLIENT
@@ -2037,7 +2152,7 @@
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
- virtual int apply_event_impl(RELAY_LOG_INFO* rli);
+ virtual int do_apply_event(RELAY_LOG_INFO const *rli);
/*
Primitive to prepare for a sequence of row executions.
@@ -2086,7 +2201,7 @@
RETURN VALUE
Error code, if something went wrong, 0 otherwise.
*/
- virtual int do_prepare_row(THD*, RELAY_LOG_INFO*, TABLE*,
+ virtual int do_prepare_row(THD*, RELAY_LOG_INFO const*, TABLE*,
char const *row_start, char const **row_end) = 0;
/*
@@ -2157,7 +2272,7 @@
virtual int do_before_row_operations(TABLE *table);
virtual int do_after_row_operations(TABLE *table, int error);
- virtual int do_prepare_row(THD*, RELAY_LOG_INFO*, TABLE*,
+ virtual int do_prepare_row(THD*, RELAY_LOG_INFO const*, TABLE*,
char const *row_start, char const **row_end);
virtual int do_exec_row(TABLE *table);
#endif
@@ -2222,7 +2337,7 @@
virtual int do_before_row_operations(TABLE *table);
virtual int do_after_row_operations(TABLE *table, int error);
- virtual int do_prepare_row(THD*, RELAY_LOG_INFO*, TABLE*,
+ virtual int do_prepare_row(THD*, RELAY_LOG_INFO const*, TABLE*,
char const *row_start, char const **row_end);
virtual int do_exec_row(TABLE *table);
#endif /* !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) */
@@ -2293,7 +2408,7 @@
virtual int do_before_row_operations(TABLE *table);
virtual int do_after_row_operations(TABLE *table, int error);
- virtual int do_prepare_row(THD*, RELAY_LOG_INFO*, TABLE*,
+ virtual int do_prepare_row(THD*, RELAY_LOG_INFO const*, TABLE*,
char const *row_start, char const **row_end);
virtual int do_exec_row(TABLE *table);
#endif
| Thread |
|---|
| • bk commit into 5.1 tree (mats:1.2339) BUG#23171 | Mats Kindahl | 18 Jan |