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, 2006-11-01 09:49:03+01:00, mats@romeo.(none) +7 -0
BUG#18581 (Creation of system tables recorded in binlog causing slave failure):
Not replicating the mysql database *at all* any more. All changes to
mysql tables are replicated by replicating the statements that do
the changes.
mysql-test/r/rpl_do_grant.result@stripped, 2006-11-01 09:48:57+01:00, mats@romeo.(none) +2 -0
Result change
mysql-test/t/rpl_do_grant.test@stripped, 2006-11-01 09:48:57+01:00, mats@romeo.(none) +5 -5
Deleting grants on both master and server since the mysql
database is not replicated any more.
sql/handler.cc@stripped, 2006-11-01 09:48:57+01:00, mats@romeo.(none) +6 -29
Removing code that selectively checks what tables in the mysql
database to ignore. The entire mysql database is not replicated
any more.
sql/log_event.cc@stripped, 2006-11-01 09:48:57+01:00, mats@romeo.(none) +0 -1
Disabling code to reload grants and access when certain tables are
touched.
sql/rpl_rli.h@stripped, 2006-11-01 09:48:58+01:00, mats@romeo.(none) +0 -16
Removing unused code.
sql/slave.cc@stripped, 2006-11-01 09:48:58+01:00, mats@romeo.(none) +3 -79
Removing unused code.
sql/sql_class.cc@stripped, 2006-11-01 09:48:58+01:00, mats@romeo.(none) +6 -6
Mysql queries (i.e., queries that affects tables in the mysql database)
are now replicated by statement instead of replicating the tables in
the mysql database.
# 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/b18581-mysql-5.1-new-rpl
--- 1.273/sql/handler.cc 2006-11-01 09:49:12 +01:00
+++ 1.274/sql/handler.cc 2006-11-01 09:49:12 +01:00
@@ -3456,38 +3456,15 @@
declared static, but it works by putting it into an anonymous
namespace. */
namespace {
- struct st_table_data {
- char const *db;
- char const *name;
- };
-
- static int table_name_compare(void const *a, void const *b)
- {
- st_table_data const *x = (st_table_data const*) a;
- st_table_data const *y = (st_table_data const*) b;
-
- /* Doing lexical compare in order (db,name) */
- int const res= strcmp(x->db, y->db);
- return res != 0 ? res : strcmp(x->name, y->name);
- }
-
bool check_table_binlog_row_based(THD *thd, TABLE *table)
{
- static st_table_data const ignore[] = {
- { "mysql", "event" },
- { "mysql", "general_log" },
- { "mysql", "slow_log" }
- };
-
- my_size_t const ignore_size = sizeof(ignore)/sizeof(*ignore);
- st_table_data const item = { table->s->db.str, table->s->table_name.str };
-
if (table->s->cached_row_logging_check == -1)
- table->s->cached_row_logging_check=
- (table->s->tmp_table == NO_TMP_TABLE) &&
- binlog_filter->db_ok(table->s->db.str) &&
- bsearch(&item, ignore, ignore_size,
- sizeof(st_table_data), table_name_compare) == NULL;
+ {
+ int const check(table->s->tmp_table == NO_TMP_TABLE &&
+ binlog_filter->db_ok(table->s->db.str) &&
+ strcmp("mysql", table->s->db.str) != 0);
+ table->s->cached_row_logging_check= check;
+ }
DBUG_ASSERT(table->s->cached_row_logging_check == 0 ||
table->s->cached_row_logging_check == 1);
--- 1.246/sql/log_event.cc 2006-11-01 09:49:12 +01:00
+++ 1.247/sql/log_event.cc 2006-11-01 09:49:12 +01:00
@@ -5694,7 +5694,6 @@
for (ptr= rli->tables_to_lock ; ptr ; ptr= ptr->next_global)
{
rli->m_table_map.set_table(ptr->table_id, ptr->table);
- rli->touching_table(ptr->db, ptr->table_name, ptr->table_id);
}
#ifdef HAVE_QUERY_CACHE
query_cache.invalidate_locked_for_write(rli->tables_to_lock);
--- 1.288/sql/slave.cc 2006-11-01 09:49:12 +01:00
+++ 1.289/sql/slave.cc 2006-11-01 09:49:12 +01:00
@@ -2373,7 +2373,6 @@
inited(0), abort_slave(0), slave_running(0), until_condition(UNTIL_NONE),
until_log_pos(0), retried_trans(0),
tables_to_lock(0), tables_to_lock_count(0),
- m_reload_flags(RELOAD_NONE_F),
unsafe_to_stop_at(0)
{
DBUG_ENTER("st_relay_log_info::st_relay_log_info");
@@ -4989,87 +4988,12 @@
DBUG_VOID_RETURN;
}
-/*
- Some system tables needed to be re-read by the MySQL server after it has
- updated them; in statement-based replication, the GRANT and other commands
- are sent verbatim to the slave which then reloads; in row-based replication,
- changes to these tables are done through ordinary Rows binlog events, so
- master must add some flag for the slave to know it has to reload the tables.
-*/
-struct st_reload_entry
-{
- char const *table;
- st_relay_log_info::enum_reload_flag flag;
-};
-
-/*
- Sorted array of table names, please keep it sorted since we are
- using bsearch() on it below.
- */
-static st_reload_entry s_mysql_tables[] =
-{
- { "columns_priv", st_relay_log_info::RELOAD_GRANT_F },
- { "db", st_relay_log_info::RELOAD_ACCESS_F },
- { "host", st_relay_log_info::RELOAD_ACCESS_F },
- { "procs_priv", st_relay_log_info::RELOAD_GRANT_F },
- { "tables_priv", st_relay_log_info::RELOAD_GRANT_F },
- { "user", st_relay_log_info::RELOAD_ACCESS_F }
-};
-
-static const my_size_t s_mysql_tables_size =
- sizeof(s_mysql_tables)/sizeof(*s_mysql_tables);
-
-static int reload_entry_compare(const void *lhs, const void *rhs)
-{
- const char *lstr = static_cast<const char *>(lhs);
- const char *rstr = static_cast<const st_reload_entry*>(rhs)->table;
- DBUG_ENTER("reload_entry_compare");
-
- DBUG_RETURN(strcmp(lstr, rstr));
-}
-
-void st_relay_log_info::touching_table(char const* db, char const* table,
- ulong table_id)
-{
- DBUG_ENTER("st_relay_log_info::touching_table");
-
- if (strcmp(db,"mysql") == 0)
- {
-#if defined(HAVE_BSEARCH) && defined(HAVE_SIZE_T)
- void *const ptr= bsearch(table, s_mysql_tables,
- s_mysql_tables_size,
- sizeof(*s_mysql_tables), reload_entry_compare);
- st_reload_entry const *const entry= static_cast<st_reload_entry*>(ptr);
-#else
- /*
- Fall back to full scan, there are few rows anyway and updating the
- "mysql" database is rare.
- */
- st_reload_entry const *entry= s_mysql_tables;
- for ( ; entry < s_mysql_tables + s_mysql_tables_size ; entry++)
- if (reload_entry_compare(table, entry) == 0)
- break;
-#endif
- if (entry)
- m_reload_flags|= entry->flag;
- }
- DBUG_VOID_RETURN;
-}
-
void st_relay_log_info::transaction_end(THD* thd)
{
DBUG_ENTER("st_relay_log_info::transaction_end");
-
- if (m_reload_flags != RELOAD_NONE_F)
- {
- if (m_reload_flags & RELOAD_ACCESS_F)
- acl_reload(thd);
-
- if (m_reload_flags & RELOAD_GRANT_F)
- grant_reload(thd);
-
- m_reload_flags= RELOAD_NONE_F;
- }
+ /*
+ Nothing to do here. Maybe remove the function?
+ */
DBUG_VOID_RETURN;
}
--- 1.293/sql/sql_class.cc 2006-11-01 09:49:12 +01:00
+++ 1.294/sql/sql_class.cc 2006-11-01 09:49:12 +01:00
@@ -2778,6 +2778,12 @@
#endif /*HAVE_ROW_BASED_REPLICATION*/
switch (qtype) {
+ case THD::ROW_QUERY_TYPE:
+#ifdef HAVE_ROW_BASED_REPLICATION
+ if (current_stmt_binlog_row_based)
+ DBUG_RETURN(0);
+#endif
+ /* Otherwise, we fall through */
case THD::MYSQL_QUERY_TYPE:
/*
Using this query type is a conveniece hack, since we have been
@@ -2787,12 +2793,6 @@
Make sure to change in check_table_binlog_row_based() according
to how you treat this.
*/
- case THD::ROW_QUERY_TYPE:
-#ifdef HAVE_ROW_BASED_REPLICATION
- if (current_stmt_binlog_row_based)
- DBUG_RETURN(0);
-#endif
- /* Otherwise, we fall through */
case THD::STMT_QUERY_TYPE:
/*
The MYSQL_LOG::write() function will set the STMT_END_F flag and
--- 1.5/mysql-test/r/rpl_do_grant.result 2006-11-01 09:49:12 +01:00
+++ 1.6/mysql-test/r/rpl_do_grant.result 2006-11-01 09:49:12 +01:00
@@ -23,6 +23,8 @@
delete from mysql.user where user=_binary'rpl_do_grant';
delete from mysql.db where user=_binary'rpl_do_grant';
flush privileges;
+delete from mysql.user where user=_binary'rpl_do_grant';
+delete from mysql.db where user=_binary'rpl_do_grant';
flush privileges;
show grants for rpl_do_grant@localhost;
ERROR 42000: There is no such grant defined for user 'rpl_do_grant' on host 'localhost'
--- 1.6/mysql-test/t/rpl_do_grant.test 2006-11-01 09:49:12 +01:00
+++ 1.7/mysql-test/t/rpl_do_grant.test 2006-11-01 09:49:12 +01:00
@@ -39,11 +39,11 @@
delete from mysql.user where user=_binary'rpl_do_grant';
delete from mysql.db where user=_binary'rpl_do_grant';
flush privileges;
-save_master_pos;
-connection slave;
-sync_with_master;
-# no need to delete manually, as the DELETEs must have done some real job on
-# master (updated binlog)
+sync_slave_with_master;
+# The mysql database is not replicated, so we have to do the deletes
+# manually on the slave as well.
+delete from mysql.user where user=_binary'rpl_do_grant';
+delete from mysql.db where user=_binary'rpl_do_grant';
flush privileges;
# End of 4.1 tests
--- 1.4/sql/rpl_rli.h 2006-11-01 09:49:12 +01:00
+++ 1.5/sql/rpl_rli.h 2006-11-01 09:49:12 +01:00
@@ -289,22 +289,6 @@
void cached_charset_invalidate();
bool cached_charset_compare(char *charset);
- /*
- To reload special tables when they are changes, we introduce a set
- of functions that will mark whenever special functions need to be
- called after modifying tables. Right now, the tables are either
- ACL tables or grants tables.
- */
- enum enum_reload_flag
- {
- RELOAD_NONE_F = 0UL,
- RELOAD_GRANT_F = (1UL << 0),
- RELOAD_ACCESS_F = (1UL << 1)
- };
-
- ulong m_reload_flags;
-
- void touching_table(char const* db, char const* table, ulong table_id);
void transaction_end(THD*);
void cleanup_context(THD *, bool);
| Thread |
|---|
| • bk commit into 5.1 tree (mats:1.2310) BUG#18581 | Mats Kindahl | 1 Nov |