1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

BUG#37051 Replication rules not evaluated correctly

The problem of this bug is that we need to get the list of tables
to be updated for a multi-table update statement, which requires to
open all the tables referenced by the statement and resolve all
the fields involved in update in order to figure out the list of
tables for update. However if there are replicate filter rules,
some tables might not exist on slave and result in a failure
before we could examine the filter rules.

I think the whole problem can not be solved on slave alone,
the master must record and send the information of tables
involved for update to slave, so that the slave do not need to
open all the tables referenced by the multi-table update statement to
figure out which tables are involved for update.

So a status variable is added to Query_log event to store the
value of table map for update on master. And on slave, it will
try to get the value of this variable and use it to examine
filter rules without opening any tables on slave, if this values
is not available, the old approach is used and thus the bug will
still occur for when replicating from old masters.
This commit is contained in:
He Zhenxing
2008-07-31 14:24:27 +08:00
parent 62ee313293
commit e6ac8830a4
10 changed files with 503 additions and 30 deletions

View File

@ -237,12 +237,15 @@ struct sql_ex_info
packet (i.e. a query) sent from client to master;
First, an auxiliary log_event status vars estimation:
*/
#define MAX_SIZE_LOG_EVENT_STATUS (4 /* flags2 */ + \
8 /* sql mode */ + \
1 + 1 + 255 /* catalog */ + \
4 /* autoinc */ + \
6 /* charset */ + \
MAX_TIME_ZONE_NAME_LENGTH)
#define MAX_SIZE_LOG_EVENT_STATUS (1 + 4 /* type, flags2 */ + \
1 + 8 /* type, sql_mode */ + \
1 + 1 + 255 /* type, length, catalog */ + \
1 + 4 /* type, auto_increment */ + \
1 + 6 /* type, charset */ + \
1 + 1 + 255 /* type, length, time_zone */ + \
1 + 2 /* type, lc_time_names_number */ + \
1 + 2 /* type, charset_database_number */ + \
1 + 8 /* type, table_map_for_update */)
#define MAX_LOG_EVENT_HEADER ( /* in order of Query_log_event::write */ \
LOG_EVENT_HEADER_LEN + /* write_header */ \
QUERY_HEADER_LEN + /* write_data */ \
@ -306,6 +309,8 @@ struct sql_ex_info
#define Q_LC_TIME_NAMES_CODE 7
#define Q_CHARSET_DATABASE_CODE 8
#define Q_TABLE_MAP_FOR_UPDATE_CODE 9
/* Intvar event post-header */
#define I_TYPE_OFFSET 0
@ -1455,6 +1460,22 @@ protected:
This field is written if it is not 0.
</td>
</tr>
<tr>
<td>table_map_for_update</td>
<td>Q_TABLE_MAP_FOR_UPDATE_CODE == 9</td>
<td>8 byte integer</td>
<td>The value of the table map that is to be updated by the
multi-table update query statement. Every bit of this variable
represents a table, and is set to 1 if the corresponding table is
to be updated by this statement.
The value of this variable is set when executing a multi-table update
statement and used by slave to apply filter rules without opening
all the tables on slave. This is required because some tables may
not exist on slave because of the filter rules.
</td>
</tr>
</table>
@subsection Query_log_event_notes_on_previous_versions Notes on Previous Versions
@ -1471,6 +1492,9 @@ protected:
* See Q_CHARSET_DATABASE_CODE in the table above.
* When adding new status vars, please don't forget to update the
MAX_SIZE_LOG_EVENT_STATUS, and update function code_name
*/
class Query_log_event: public Log_event
{
@ -1548,6 +1572,11 @@ public:
const char *time_zone_str;
uint lc_time_names_number; /* 0 means en_US */
uint charset_database_number;
/*
map for tables that will be updated for a multi-table update query
statement, for other query statements, this will be zero.
*/
ulonglong table_map_for_update;
#ifndef MYSQL_CLIENT