List:Commits« Previous MessageNext Message »
From:Magnus Blåudd Date:March 30 2011 3:02pm
Subject:bzr commit into mysql-5.1-telco-7.0 branch (magnus.blaudd:4279)
View as plain text  
#At file:///home/msvensson/mysql/7.0-dist-priv/ based on revid:magnus.blaudd@strippedw9wg5

 4279 Magnus Blåudd	2011-03-30
      ndb dist priv
       - dont't set up event or event operations on the distributed grant tables
       - add tests to check that all CREATE/DROP USER and GRANTs are written as
       statements to binlog(s)
       - temporarily disable REVOKE UPDATE after filing bug

    modified:
      mysql-test/suite/rpl_ndb/r/rpl_ndb_dist_priv.result
      mysql-test/suite/rpl_ndb/t/rpl_ndb_dist_priv.test
      sql/ha_ndbcluster.cc
      sql/ha_ndbcluster_binlog.cc
=== modified file 'mysql-test/suite/rpl_ndb/r/rpl_ndb_dist_priv.result'
--- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_dist_priv.result	2011-03-23 13:32:08 +0000
+++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_dist_priv.result	2011-03-30 15:02:52 +0000
@@ -47,13 +47,60 @@ User	Table_priv
 newuser	Update
 user2	Select
 FLUSH PRIVILEGES;
-REVOKE UPDATE ON t1 FROM 'newuser'@'localhost';
 REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user2'@'localhost';
 select User,Table_priv from mysql.tables_priv ORDER BY User;
 User	Table_priv
+newuser	Update
+DROP USER 'newuser'@'localhost';
+== Showing binlog server1 ==
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; CREATE USER 'user'@'localhost' IDENTIFIED by 'mypass'
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; GRANT UPDATE ON t1 TO 'user'@'localhost'
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; SET PASSWORD FOR 'user'@'localhost'='*D8DECEC305209EEFEC43008E1D420E1AA06B19E0'
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; RENAME USER 'user'@'localhost' TO 'newuser'@'localhost'
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; GRANT SELECT ON test.* TO 'newuser'@'localhost' IDENTIFIED by 'mypass2'
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; CREATE USER 'user2'@'localhost' IDENTIFIED by 'mypass'
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; GRANT SELECT ON test.t1 TO 'user2'@'localhost'
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	use `mysql`; CREATE USER 'user3'@'localhost' IDENTIFIED by 'mypass'
+master-bin.000001	#	Query	#	#	use `mysql`; REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user2'@'localhost'
+master-bin.000001	#	Query	#	#	use `mysql`; DROP USER 'newuser'@'localhost'
+== Showing binlog server2 ==
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Query	#	#	use `mysql`; CREATE USER 'user'@'localhost' IDENTIFIED by 'mypass'
+master-bin.000001	#	Query	#	#	use `mysql`; GRANT UPDATE ON t1 TO 'user'@'localhost'
+master-bin.000001	#	Query	#	#	use `mysql`; SET PASSWORD FOR 'user'@'localhost'='*D8DECEC305209EEFEC43008E1D420E1AA06B19E0'
+master-bin.000001	#	Query	#	#	use `mysql`; RENAME USER 'user'@'localhost' TO 'newuser'@'localhost'
+master-bin.000001	#	Query	#	#	use `mysql`; GRANT SELECT ON test.* TO 'newuser'@'localhost' IDENTIFIED by 'mypass2'
+master-bin.000001	#	Query	#	#	use `mysql`; CREATE USER 'user2'@'localhost' IDENTIFIED by 'mypass'
+master-bin.000001	#	Query	#	#	use `mysql`; GRANT SELECT ON test.t1 TO 'user2'@'localhost'
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; CREATE USER 'user3'@'localhost' IDENTIFIED by 'mypass'
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	use `test`; FLUSH PRIVILEGES
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user2'@'localhost'
+master-bin.000001	#	Query	#	#	COMMIT
+master-bin.000001	#	Query	#	#	BEGIN
+master-bin.000001	#	Query	#	#	use `test`; DROP USER 'newuser'@'localhost'
+master-bin.000001	#	Query	#	#	COMMIT
 select distinct User,Password from mysql.user order by User;
 User	Password
-newuser	*1E9649BB3F345563008E37641B407AFF50E5835C
 root	
 user2	*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4
 user3	*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4
@@ -61,7 +108,6 @@ select User,Table_priv from mysql.tables
 User	Table_priv
 select distinct User,Password from mysql.user order by User;
 User	Password
-newuser	*1E9649BB3F345563008E37641B407AFF50E5835C
 root	
 user2	*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4
 user3	*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4
@@ -70,7 +116,6 @@ User	Table_priv
 === making backup of new users ===
 call mysql.mysql_cluster_backup_privileges();
 ==== clean up ====
-DROP USER 'newuser'@'localhost';
 DROP USER 'user2'@'localhost';
 DROP USER 'user3'@'localhost';
 DROP TABLE t1;

=== modified file 'mysql-test/suite/rpl_ndb/t/rpl_ndb_dist_priv.test'
--- a/mysql-test/suite/rpl_ndb/t/rpl_ndb_dist_priv.test	2011-03-30 14:28:06 +0000
+++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_dist_priv.test	2011-03-30 15:02:52 +0000
@@ -30,6 +30,16 @@ call mysql.mysql_cluster_move_privileges
 select mysql.mysql_cluster_privileges_are_distributed();
 
 CREATE TABLE t1 (pk INT PRIMARY KEY) engine = ndb;
+
+# Save the current binlog position to use as start when
+# showing CREATE/DROP USER and GRANTs are written as statements
+# in binlog
+connection server1;
+let $binlog_start_server1= query_get_value(SHOW MASTER STATUS, Position, 1);
+connection server2;
+let $binlog_start_server2= query_get_value(SHOW MASTER STATUS, Position, 1);
+connection server1;
+
 CREATE USER 'user'@'localhost' IDENTIFIED by 'mypass';
 GRANT UPDATE ON t1 TO 'user'@'localhost';
 SET PASSWORD FOR 'user'@'localhost'= PASSWORD('newpass');
@@ -53,9 +63,28 @@ select User,Table_priv from mysql.tables
 
 connection server2;
 FLUSH PRIVILEGES;
-REVOKE UPDATE ON t1 FROM 'newuser'@'localhost';
+#
+# Temporary workaround for BUG#11938564
+# - Disable REVOKE UPDATE temporarily, the record exists in
+#   NDB but is not found in "acl cache" on the slave causing
+#   replication to stop.
+#
+#REVOKE UPDATE ON t1 FROM 'newuser'@'localhost';
 REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user2'@'localhost';
 select User,Table_priv from mysql.tables_priv ORDER BY User;
+DROP USER 'newuser'@'localhost';
+
+# Show that all the above CREATE/DROP USER and GRANT's
+# have been written as statements to binlog
+# on both server1 and server2
+connection server1;
+echo == Showing binlog server1 ==;
+let $binlog_start= $binlog_start_server1;
+--source include/show_binlog_events.inc
+connection server2;
+echo == Showing binlog server2 ==;
+let $binlog_start= $binlog_start_server2;
+--source include/show_binlog_events.inc
 
 connection server1;
 select distinct User,Password from mysql.user order by User;
@@ -74,7 +103,6 @@ call mysql.mysql_cluster_backup_privileg
 
 --echo ==== clean up ====
 connection server1;
-DROP USER 'newuser'@'localhost';
 DROP USER 'user2'@'localhost';
 DROP USER 'user3'@'localhost';
 

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2011-03-23 10:02:55 +0000
+++ b/sql/ha_ndbcluster.cc	2011-03-30 15:02:52 +0000
@@ -9084,7 +9084,9 @@ int ha_ndbcluster::rename_table(const ch
     ndb_rep_event_name(&event_name, new_dbname, new_tabname, 
                        get_binlog_full(share));
 
-    if (!ndbcluster_create_event(thd, ndb, ndbtab, event_name.c_ptr(), share,
+    if (!Ndb_dist_priv_util::is_distributed_priv_table(new_dbname,
+                                                       new_tabname) &&
+        !ndbcluster_create_event(thd, ndb, ndbtab, event_name.c_ptr(), share,
                                  share && ndb_binlog_running ? 2 : 1/* push warning */))
     {
       if (opt_ndb_extra_logging)

=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc	2011-03-29 10:10:03 +0000
+++ b/sql/ha_ndbcluster_binlog.cc	2011-03-30 15:02:52 +0000
@@ -496,6 +496,12 @@ int ndbcluster_binlog_init_share(THD *th
            strcmp(share->table_name, NDB_APPLY_TABLE) == 0)
     do_event_op= 1;
 
+  if (Ndb_dist_priv_util::is_distributed_priv_table(share->db,
+                                                    share->table_name))
+  {
+    do_event_op= 0;
+  }
+
   {
     int i, no_nodes= g_ndb_cluster_connection->no_db_nodes();
     share->subscriber_bitmap= (MY_BITMAP*)
@@ -4610,6 +4616,12 @@ int ndbcluster_create_binlog_setup(THD *
            strcmp(share->table_name, NDB_APPLY_TABLE) == 0)
     do_event_op= 1;
 
+  if (Ndb_dist_priv_util::is_distributed_priv_table(share->db,
+                                                    share->table_name))
+  {
+    do_event_op= 0;
+  }
+
   if (!do_event_op)
   {
     set_binlog_nologging(share);
@@ -4907,6 +4919,11 @@ ndbcluster_create_event_ops(THD *thd, ND
     DBUG_RETURN(0);
   }
 
+  // Don't allow event ops to be created on distributed priv tables
+  // they are distributed via ndb_schema
+  assert(!Ndb_dist_priv_util::is_distributed_priv_table(share->db,
+                                                        share->table_name));
+
   Ndb_event_data *event_data= share->event_data;
   int do_ndb_schema_share= 0, do_ndb_apply_status_share= 0;
 #ifdef HAVE_NDB_BINLOG

Attachment: [text/bzr-bundle] bzr/magnus.blaudd@oracle.com-20110330150252-uwpq5trlub9tkc6c.bundle
Thread
bzr commit into mysql-5.1-telco-7.0 branch (magnus.blaudd:4279) Magnus Blåudd30 Mar