summaryrefslogtreecommitdiff
path: root/sql/log_event.h
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2017-04-07 10:19:10 +0300
committerAlexander Barkov <bar@mariadb.org>2017-04-07 15:58:17 +0400
commit546e7aa96f13091dc32f87809e7b6ea19d20e1ad (patch)
tree822451f20dc33fffefbfabd3dd10c441e657e019 /sql/log_event.h
parented305c0fd52d17110e9cc7c2e515d1f881de1102 (diff)
downloadmariadb-git-546e7aa96f13091dc32f87809e7b6ea19d20e1ad.tar.gz
MDEV-8203 Assert in Query_log_event::do_apply_event()
This happens because the master writes a table_map event to the binary log, but no row event. The slave has a check that there should always be a row event if there was a table_map event, which causes a crash. Fixed by remembering in the cache what kind of events are logged and ignore cached statements which is just a table map event.
Diffstat (limited to 'sql/log_event.h')
-rw-r--r--sql/log_event.h32
1 files changed, 29 insertions, 3 deletions
diff --git a/sql/log_event.h b/sql/log_event.h
index 5689d36aea8..2bc0a858542 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -716,6 +716,21 @@ enum Log_event_type
ENUM_END_EVENT /* end marker */
};
+
+/*
+ Bit flags for what has been writting to cache. Used to
+ discard logs with table map events but not row events and
+ nothing else important. This is stored by cache.
+*/
+
+enum enum_logged_status
+{
+ LOGGED_TABLE_MAP= 1,
+ LOGGED_ROW_EVENT= 2,
+ LOGGED_NO_DATA= 4,
+ LOGGED_CRITICAL= 8
+};
+
static inline bool LOG_EVENT_IS_QUERY(enum Log_event_type type)
{
return type == QUERY_EVENT || type == QUERY_COMPRESSED_EVENT;
@@ -785,6 +800,7 @@ class THD;
class Format_description_log_event;
class Relay_log_info;
+class binlog_cache_data;
#ifdef MYSQL_CLIENT
enum enum_base64_output_mode {
@@ -896,6 +912,7 @@ typedef struct st_print_event_info
This class encapsulates writing of Log_event objects to IO_CACHE.
Automatically calculates the checksum and encrypts the data, if necessary.
*/
+
class Log_event_writer
{
public:
@@ -907,13 +924,16 @@ public:
int write_data(const uchar *pos, size_t len);
int write_footer();
my_off_t pos() { return my_b_safe_tell(file); }
+ void add_status(enum_logged_status status);
-Log_event_writer(IO_CACHE *file_arg, Binlog_crypt_data *cr= 0)
+ Log_event_writer(IO_CACHE *file_arg, binlog_cache_data *cache_data_arg,
+ Binlog_crypt_data *cr= 0)
: bytes_written(0), ctx(0),
- file(file_arg), crypto(cr) { }
+ file(file_arg), cache_data(cache_data_arg), crypto(cr) { }
private:
IO_CACHE *file;
+ binlog_cache_data *cache_data;
/**
Placeholder for event checksum while writing to binlog.
*/
@@ -1236,7 +1256,7 @@ public:
bool is_more);
void print_base64(IO_CACHE* file, PRINT_EVENT_INFO* print_event_info,
bool is_more);
-#endif
+#endif /* MYSQL_SERVER */
/* The following code used for Flashback */
#ifdef MYSQL_CLIENT
@@ -1382,6 +1402,7 @@ public:
}
#endif
virtual Log_event_type get_type_code() = 0;
+ virtual enum_logged_status logged_status() { return LOGGED_CRITICAL; }
virtual bool is_valid() const = 0;
virtual my_off_t get_header_len(my_off_t len) { return len; }
void set_artificial_event() { flags |= LOG_EVENT_ARTIFICIAL_F; }
@@ -3361,6 +3382,7 @@ public:
const Format_description_log_event *description_event);
~Gtid_log_event() { }
Log_event_type get_type_code() { return GTID_EVENT; }
+ enum_logged_status logged_status() { return LOGGED_NO_DATA; }
int get_data_size()
{
return GTID_HEADER_LEN + ((flags2 & FL_GROUP_COMMIT_ID) ? 2 : 0);
@@ -3857,6 +3879,7 @@ public:
virtual int get_data_size();
virtual Log_event_type get_type_code();
+ enum_logged_status logged_status() { return LOGGED_NO_DATA; }
virtual bool is_valid() const;
virtual bool is_part_of_group() { return 1; }
@@ -4271,6 +4294,7 @@ public:
const char *get_db_name() const { return m_dbnam; }
virtual Log_event_type get_type_code() { return TABLE_MAP_EVENT; }
+ virtual enum_logged_status logged_status() { return LOGGED_TABLE_MAP; }
virtual bool is_valid() const { return m_memory != NULL; /* we check malloc */ }
virtual bool is_part_of_group() { return 1; }
@@ -4398,6 +4422,7 @@ public:
flag_set get_flags(flag_set flags_arg) const { return m_flags & flags_arg; }
Log_event_type get_type_code() { return m_type; } /* Specific type (_V1 etc) */
+ enum_logged_status logged_status() { return LOGGED_ROW_EVENT; }
virtual Log_event_type get_general_type_code() = 0; /* General rows op type, no version */
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
@@ -5160,6 +5185,7 @@ inline int Log_event_writer::write(Log_event *ev)
ev->writer= this;
int res= ev->write();
IF_DBUG(ev->writer= 0,); // writer must be set before every Log_event::write
+ add_status(ev->logged_status());
return res;
}