List:Commits« Previous MessageNext Message »
From:Jonathan Miller Date:April 19 2007 9:03pm
Subject:bk commit into 5.1 tree (jmiller:1.2540)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of ndbdev. When ndbdev 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-04-19 23:03:46+02:00, jmiller@stripped +5 -0
  rpl_ndb_stm_innodb.result, rpl_ndb_stm_innodb.test:
    Extended test for generic ndb_apply_status testing
  show_binlog_events2.inc, select_ndb_apply_status.inc, tpcb.inc:
    New include file for rpl_ndb_stm_innodb test

  mysql-test/include/select_ndb_apply_status.inc@stripped, 2007-04-19 23:03:13+02:00, jmiller@stripped +7 -0
    New include file for rpl_ndb_stm_innodb test

  mysql-test/include/select_ndb_apply_status.inc@stripped, 2007-04-19 23:03:13+02:00, jmiller@stripped +0 -0

  mysql-test/include/show_binlog_events2.inc@stripped, 2007-04-19 23:03:23+02:00, jmiller@stripped +5 -0
    New include file for rpl_ndb_stm_innodb test

  mysql-test/include/show_binlog_events2.inc@stripped, 2007-04-19 23:03:23+02:00, jmiller@stripped +0 -0

  mysql-test/include/tpcb.inc@stripped, 2007-04-19 23:03:29+02:00, jmiller@stripped +148 -0
    New include file for rpl_ndb_stm_innodb test

  mysql-test/include/tpcb.inc@stripped, 2007-04-19 23:03:29+02:00, jmiller@stripped +0 -0

  mysql-test/r/rpl_ndb_stm_innodb.result@stripped, 2007-04-19 23:02:31+02:00, jmiller@stripped +97 -6
    Extended test for generic ndb_apply_status testing

  mysql-test/t/rpl_ndb_stm_innodb.test@stripped, 2007-04-19 23:02:04+02:00, jmiller@stripped +190 -16
    Extended test for generic ndb_apply_status testing

# 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:	jmiller
# Host:	ndb08.mysql.com
# Root:	/data1/mysql-5.1-telco2
--- New file ---
+++ mysql-test/include/select_ndb_apply_status.inc	07/04/19 23:03:13
--replace_column 1 <log_name> 2 <start_pos> 3 <end_pos>
select @log_name:=log_name, @start_pos:=start_pos, @end_pos:=end_pos
       from mysql.ndb_apply_status;
--let $start_pos = `select @start_pos`
--let $end_pos = `select @end_pos`
--let $log_name = `select @log_name`


--- New file ---
+++ mysql-test/include/show_binlog_events2.inc	07/04/19 23:03:23
--replace_result $start_pos <start_pos> $end_pos <end_pos>
--replace_column 2 #
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
--eval show binlog events in '$log_name'  from $start_pos limit 1,1


--- New file ---
+++ mysql-test/include/tpcb.inc	07/04/19 23:03:29
CREATE DATABASE tpcb;

--echo
CREATE TABLE tpcb.account (id INT, bid INT, balance DECIMAL(10,2),
                           filler CHAR(255), PRIMARY KEY(id));
--echo
CREATE TABLE tpcb.branch (bid INT, balance DECIMAL(10,2), filler VARCHAR(255),
                          PRIMARY KEY(bid));
--echo
CREATE TABLE tpcb.teller (tid INT, balance DECIMAL(10,2), filler VARCHAR(255),
                          PRIMARY KEY(tid));
--echo
CREATE TABLE tpcb.history (id MEDIUMINT NOT NULL AUTO_INCREMENT,aid INT,
                           tid INT, bid INT,  amount DECIMAL(10,2),
                           tdate DATETIME, teller CHAR(20), uuidf LONGBLOB,
                           filler CHAR(80),PRIMARY KEY (id));

--echo
--echo --- Create stored procedures & functions ---
--echo

--disable_query_log
delimiter |;
CREATE PROCEDURE tpcb.load()
BEGIN
  DECLARE acct INT DEFAULT 100;
  DECLARE brch INT DEFAULT 10;
  DECLARE tell INT DEFAULT 100;
  DECLARE tmp INT DEFAULT 10;
  WHILE brch > 0 DO
    SET tmp = 100;
    WHILE tmp > 0 DO
     INSERT INTO tpcb.account VALUES (acct, brch, 0.0, "FRESH ACCOUNT");
     SET acct = acct - 1;
     SET tmp = tmp -1;
    END WHILE;
    INSERT INTO tpcb.branch VALUES (brch, 0.0, "FRESH BRANCH");
    SET brch = brch - 1;
  END WHILE;
  WHILE tell > 0 DO
   INSERT INTO tpcb.teller VALUES (tell, 0.0, "FRESH TELLER");
   SET tell = tell - 1;
  END WHILE;
END|

CREATE FUNCTION tpcb.account_id () RETURNS INT
BEGIN
  DECLARE num INT;
  DECLARE ran INT;
  SELECT RAND() * 10 INTO ran;
  IF (ran < 5)
   THEN
     SELECT RAND() * 10 INTO num;
   ELSE
     SELECT RAND() * 100 INTO num;
   END IF;
   IF (num < 1)
    THEN
     RETURN 1;
   END IF;
  RETURN  num;
END|

CREATE FUNCTION tpcb.teller_id () RETURNS INT
BEGIN
  DECLARE num INT;
  DECLARE ran INT;
  SELECT RAND() * 10 INTO ran;
  IF (ran < 5)
   THEN
     SELECT RAND() * 10 INTO num;
   ELSE
     SELECT RAND() * 100 INTO num;
   END IF;
   IF (num < 1)
    THEN
      RETURN 1;
   END IF;
   RETURN  num;
END|

CREATE PROCEDURE tpcb.trans()
BEGIN
  DECLARE acct INT DEFAULT 0;
  DECLARE brch INT DEFAULT 0;
  DECLARE tell INT DEFAULT 0;
  DECLARE bal  DECIMAL(10,2) DEFAULT 0.0;
  DECLARE amount DECIMAL(10,2) DEFAULT 1.00;
  DECLARE test INT DEFAULT 0;
  DECLARE bbal DECIMAL(10,2) DEFAULT 0.0;
  DECLARE tbal DECIMAL(10,2) DEFAULT 0.0;
  DECLARE local_uuid VARCHAR(255);
  DECLARE local_user VARCHAR(255);
  DECLARE local_time TIMESTAMP;

  SELECT RAND() * 10 INTO test;
  SELECT tpcb.account_id() INTO acct;
  SELECT tpcb.teller_id() INTO tell;

  SELECT account.balance INTO bal FROM tpcb.account WHERE id = acct;
  SELECT account.bid INTO brch FROM tpcb.account WHERE id = acct;
  SELECT teller.balance INTO tbal FROM tpcb.teller WHERE tid = tell;
  SELECT branch.balance INTO bbal FROM tpcb.branch WHERE bid = brch;

  START TRANSACTION;
  IF (test < 5)
   THEN
     SET bal = bal + amount;
     SET bbal = bbal + amount;
     SET tbal = tbal + amount;
     UPDATE tpcb.account SET balance = bal, filler = 'account updated'
     WHERE id = acct;
     UPDATE tpcb.branch SET balance = bbal, filler = 'branch updated'
     WHERE bid = brch;
     UPDATE tpcb.teller SET balance = tbal, filler = 'teller updated'
     WHERE tid = tell;
   ELSE
     SET bal = bal - amount;
     SET bbal = bbal - amount;
     SET tbal = tbal - amount;
     UPDATE tpcb.account SET balance = bal, filler = 'account updated'
     WHERE id = acct;
     UPDATE tpcb.branch SET balance = bbal, filler = 'branch updated'
     WHERE bid = brch;
     UPDATE tpcb.teller SET balance = tbal, filler = 'teller updated'
     WHERE tid = tell;
  END IF;

  IF (@RPL_SYS_MODE = 'SBR')
  THEN
    SET local_uuid=UUID();
    SET local_user=USER();
    SET local_time= NOW();
    INSERT INTO tpcb.history VALUES(NULL,acct,tell,brch,amount, local_time,local_user,
                             local_uuid,'completed trans');
  ELSE
    INSERT INTO tpcb.history VALUES(NULL,acct,tell,brch,amount, NOW(), USER(),
                             UUID(),'completed trans');
  END IF;
  COMMIT;

END|
delimiter ;|
--enable_query_log
--echo
--echo *** Stored Procedures Created ***
--echo



--- 1.1/mysql-test/r/rpl_ndb_stm_innodb.result	2007-04-19 23:03:57 +02:00
+++ 1.2/mysql-test/r/rpl_ndb_stm_innodb.result	2007-04-19 23:03:57 +02:00
@@ -4,34 +4,125 @@
 reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
+
+*** Test 1 ***
+
 create table t1 (a int key, b int) engine innodb;
 create table t2 (a int key, b int) engine innodb;
+
 alter table t1 engine ndb;
 alter table t2 engine ndb;
+
 insert into t1 values (1,2);
-select @start_pos:=start_pos, @end_pos:=end_pos from mysql.ndb_apply_status;
-@start_pos:=start_pos	@end_pos:=end_pos
-<start_pos>	<end_pos>
+
+select @log_name:=log_name, @start_pos:=start_pos, @end_pos:=end_pos
+from mysql.ndb_apply_status;
+@log_name:=log_name	@start_pos:=start_pos	@end_pos:=end_pos
+<log_name>	<start_pos>	<end_pos>
+
 show binlog events from <start_pos> limit 1;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	<start_pos>	Query	1	#	use `test`; insert into t1 values (1,2)
+
 show binlog events from <start_pos> limit 1,1;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Xid	1	445	COMMIT /* XID */
+
 begin;
 insert into t1 values (2,3);
 insert into t2 values (3,4);
 commit;
-select @start_pos:=start_pos, @end_pos:=end_pos from mysql.ndb_apply_status;
-@start_pos:=start_pos	@end_pos:=end_pos
-<start_pos>	<end_pos>
+
+select @log_name:=log_name, @start_pos:=start_pos, @end_pos:=end_pos
+from mysql.ndb_apply_status;
+@log_name:=log_name	@start_pos:=start_pos	@end_pos:=end_pos
+<log_name>	<start_pos>	<end_pos>
 show binlog events from <start_pos> limit 1;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	<start_pos>	Query	1	#	use `test`; BEGIN
+
 show binlog events from <start_pos> limit 1,2;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	#	#	use `test`; insert into t1 values (2,3)
 master-bin.000001	#	Query	#	#	use `test`; insert into t2 values (3,4)
+
 show binlog events from <start_pos> limit 3,1;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Xid	1	<end_pos>	COMMIT /* XID */
+
+DROP TABLE test.t1, test.t2;
+SHOW TABLES;
+Tables_in_test
+
+*** Test 2 ***
+
+CREATE DATABASE tpcb;
+
+CREATE TABLE tpcb.account (id INT, bid INT, balance DECIMAL(10,2),
+filler CHAR(255), PRIMARY KEY(id));
+
+CREATE TABLE tpcb.branch (bid INT, balance DECIMAL(10,2), filler VARCHAR(255),
+PRIMARY KEY(bid));
+
+CREATE TABLE tpcb.teller (tid INT, balance DECIMAL(10,2), filler VARCHAR(255),
+PRIMARY KEY(tid));
+
+CREATE TABLE tpcb.history (id MEDIUMINT NOT NULL AUTO_INCREMENT,aid INT,
+tid INT, bid INT,  amount DECIMAL(10,2),
+tdate DATETIME, teller CHAR(20), uuidf LONGBLOB,
+filler CHAR(80),PRIMARY KEY (id));
+
+--- Create stored procedures & functions ---
+
+
+*** Stored Procedures Created ***
+
+USE tpcb;
+ALTER TABLE account ENGINE NDB;
+ALTER TABLE branch ENGINE NDB;
+ALTER TABLE teller ENGINE NDB;
+ALTER TABLE history ENGINE NDB;
+
+select @log_name:=log_name, @start_pos:=start_pos, @end_pos:=end_pos
+from mysql.ndb_apply_status;
+@log_name:=log_name	@start_pos:=start_pos	@end_pos:=end_pos
+<log_name>	<start_pos>	<end_pos>
+
+show binlog events in 'master-bin.000001'  from <start_pos> limit 1,1;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Write_rows	1	<end_pos>	table_id: # flags: STMT_END_F
+
+** Test 3 **
+
+FLUSH LOGS;
+
+select @log_name:=log_name, @start_pos:=start_pos, @end_pos:=end_pos
+from mysql.ndb_apply_status;
+@log_name:=log_name	@start_pos:=start_pos	@end_pos:=end_pos
+<log_name>	<start_pos>	<end_pos>
+
+show binlog events in 'master-bin.000002'  from <start_pos> limit 1,1;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000002	#	Write_rows	1	<end_pos>	table_id: # flags: STMT_END_F
+
+** Test 4 **
+
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+
+select @log_name:=log_name, @start_pos:=start_pos, @end_pos:=end_pos
+from mysql.ndb_apply_status;
+@log_name:=log_name	@start_pos:=start_pos	@end_pos:=end_pos
+<log_name>	<start_pos>	<end_pos>
+
+show binlog events in 'master-bin.000001'  from <start_pos> limit 1,1;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Write_rows	1	<end_pos>	table_id: # flags: STMT_END_F
+
+*** DUMP MASTER & SLAVE FOR COMPARE ********
+DROP DATABASE tpcb;
+****** Do dumps compare ************

--- 1.1/mysql-test/t/rpl_ndb_stm_innodb.test	2007-04-19 23:03:57 +02:00
+++ 1.2/mysql-test/t/rpl_ndb_stm_innodb.test	2007-04-19 23:03:57 +02:00
@@ -1,62 +1,236 @@
+#############################################
+#Authors:    TU and Jeb
+#Date:       2007/04
+#Purpose:    Generic replication to cluster
+#            and ensuring that the ndb_apply_status
+#            table is updated.
+#############################################
+
+## Includes ##
+
+--disable_query_log
 --source include/have_ndb.inc
 --source include/have_innodb.inc
 --source include/have_binlog_format_mixed_or_statement.inc
 --source include/master-slave.inc
+--enable_query_log
 
---connection master
+--echo
+--echo *** Test 1 ***
+--echo
+
+connection master;
 create table t1 (a int key, b int) engine innodb;
 create table t2 (a int key, b int) engine innodb;
 
+--echo
+
 --sync_slave_with_master
---connection slave
 alter table t1 engine ndb;
 alter table t2 engine ndb;
 
+--echo
+
 # check binlog position without begin
---connection master
+connection master;
 insert into t1 values (1,2);
 
+--echo
+
 --sync_slave_with_master
---connection slave
---replace_column 1 <start_pos> 2 <end_pos>
-select @start_pos:=start_pos, @end_pos:=end_pos from mysql.ndb_apply_status;
---let $start_pos = `select @start_pos`
---let $end_pos = `select @end_pos`
+--source include/select_ndb_apply_status.inc
+
+--echo
 
---connection master
+connection master;
 # here is actually a bug, since there is no begin statement, the
 # query is autocommitted, and end_pos shows end of the insert and not
 # end of the commit
 --replace_result $start_pos <start_pos>
 --replace_column 5 #
 --eval show binlog events from $start_pos limit 1
+--echo
 --replace_result $start_pos <start_pos> $end_pos <end_pos>
 --replace_column 2 #
 --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
 --eval show binlog events from $start_pos limit 1,1
 
+--echo
+
 # check binlog position with begin
---connection master
 begin;
 insert into t1 values (2,3);
 insert into t2 values (3,4);
 commit;
 
+--echo
+
 --sync_slave_with_master
---connection slave
---replace_column 1 <start_pos> 2 <end_pos>
-select @start_pos:=start_pos, @end_pos:=end_pos from mysql.ndb_apply_status;
---let $start_pos = `select @start_pos`
---let $end_pos = `select @end_pos`
+--source include/select_ndb_apply_status.inc
 
---connection master
+connection master;
 --replace_result $start_pos <start_pos>
 --replace_column 5 #
 --eval show binlog events from $start_pos limit 1
+--echo
 --replace_result $start_pos <start_pos>
 --replace_column 2 # 4 # 5 #
 --eval show binlog events from $start_pos limit 1,2
+--echo
 --replace_result $start_pos <start_pos> $end_pos <end_pos>
 --replace_column 2 #
 --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
 --eval show binlog events from $start_pos limit 3,1
+
+--echo
+
+connection master;
+DROP TABLE test.t1, test.t2;
+--sync_slave_with_master
+SHOW TABLES;
+
+# Run in some transactions using stored procedures
+# and ensure that the ndb_apply_status table is 
+# updated to show the transactions
+
+
+--echo
+--echo *** Test 2 ***
+--echo
+
+connection master;
+--source include/tpcb.inc
+
+--sync_slave_with_master
+USE tpcb;
+ALTER TABLE account ENGINE NDB;
+ALTER TABLE branch ENGINE NDB;
+ALTER TABLE teller ENGINE NDB;
+ALTER TABLE history ENGINE NDB;
+
+--echo
+
+connection master;
+--disable_query_log
+CALL tpcb.load();
+SET AUTOCOMMIT=0;
+let $run= 5;
+while ($run)
+{
+ CALL tpcb.trans();
+ dec $run;
+}
+SET AUTOCOMMIT=1;
+--enable_query_log
+
+--sync_slave_with_master
+--source include/select_ndb_apply_status.inc
+
+--echo
+
+connection master;
+--source include/show_binlog_events2.inc
+
+# Flush the logs on the master moving all
+# Transaction to a new binlog and ensure
+# that the ndb_apply_status table is updated
+# to show the use of the new binlog.
+
+--echo
+--echo ** Test 3 **
+--echo
+
+FLUSH LOGS;
+
+--disable_query_log
+SET AUTOCOMMIT=0;
+let $run= 5;
+while ($run)
+{
+ CALL tpcb.trans();
+ dec $run;
+}
+SET AUTOCOMMIT=1;
+--enable_query_log
+
+--echo
+
+--sync_slave_with_master
+--source include/select_ndb_apply_status.inc
+
+--echo
+
+connection master;
+--source include/show_binlog_events2.inc
+
+# Now we reset both the master and the slave
+# Run some more transaction and ensure
+# that the ndb_apply_status is updated
+# correctly
+
+--echo
+--echo ** Test 4 **
+--echo
+
+--source include/master-slave-reset.inc
+
+--echo
+
+connection master;
+--disable_query_log
+SET AUTOCOMMIT=0;
+let $run= 5;
+while ($run)
+{
+ CALL tpcb.trans();
+ dec $run;
+}
+SET AUTOCOMMIT=1;
+--enable_query_log
+
+--sync_slave_with_master
+--source include/select_ndb_apply_status.inc
+
+--echo
+
+connection master;
+--source include/show_binlog_events2.inc
+
+--echo
+--echo *** DUMP MASTER & SLAVE FOR COMPARE ********
+
+--exec $MYSQL_DUMP -n -t --compact --order-by-primary --skip-extended-insert tpcb account teller branch history > $MYSQLTEST_VARDIR/tmp/master_apply_status.sql
+
+--exec $MYSQL_DUMP_SLAVE -n -t --compact --order-by-primary --skip-extended-insert tpcb account teller branch history > $MYSQLTEST_VARDIR/tmp/slave_apply_status.sql
+
+connection master;
+DROP DATABASE tpcb;
+
+--sync_slave_with_master
+
+# Commenting out until decision on Bug#2796
+
+#--source include/select_ndb_apply_status.inc
+
+#connection master;
+#--eval SHOW BINLOG EVENTS in '$log_name' from $start_pos
+#--source include/show_binlog_events2.inc
+
+--echo ****** Do dumps compare ************
+
+--exec diff $MYSQLTEST_VARDIR/tmp/master_apply_status.sql $MYSQLTEST_VARDIR/tmp/slave_apply_status.sql;
+
+#Note: other tests are using diff_files, but I could not get the test framework to 
+#      work using it, so I went back to using 11exec diff. In the future
+#      once all clones work with diff_files, this test should be altered to
+#      use it.
+
+#diff_files $MYSQLTEST_VARDIR/tmp/master_apply_status.sql $MYSQLTEST_VARDIR/tmp/slave_apply_status.sql;
+
+## Note: Ths files should only get removed, if the above diff succeeds.
+
+--exec rm $MYSQLTEST_VARDIR/tmp/master_apply_status.sql
+--exec rm $MYSQLTEST_VARDIR/tmp/slave_apply_status.sql
+
+
+# End of 5.1 Test
Thread
bk commit into 5.1 tree (jmiller:1.2540)Jonathan Miller19 Apr