Commit 5d5b7ac2 authored by tomas@poseidon.mysql.com's avatar tomas@poseidon.mysql.com

Merge poseidon.mysql.com:/home/tomas/mysql-5.1-new-ndb

into  poseidon.mysql.com:/home/tomas/mysql-5.1-new-rpl
parents 644d360b ba5b1f9c
#############################################
#Authors: TU and Jeb
#Date: 2007/04
#Purpose: Generic replication to cluster
# and ensuring that the ndb_apply_status
# table is updated.
#############################################
# Notes:
# include/select_ndb_apply_status.inc
# Selects out the log name, start & end pos
# from the ndb_apply_status table
#
# include/show_binlog_using_logname.inc
# To select out 1 row from offset 1
# from the start position in the binlog whose
# name is = log_name
#
# include/tpcb.inc
# Creates DATABASE tpcb, the tables and
# stored procedures for loading the DB
# and for running transactions against DB.
##############################################
--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
alter table t1 engine ndb;
alter table t2 engine ndb;
--echo
# check binlog position without begin
connection master;
insert into t1 values (1,2);
--echo
--sync_slave_with_master
--source include/select_ndb_apply_status.inc
--echo
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
begin;
insert into t1 values (2,3);
insert into t2 values (3,4);
commit;
--echo
--sync_slave_with_master
--source include/select_ndb_apply_status.inc
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
# Create database/tables and stored procdures
connection master;
--source include/tpcb.inc
# Switch tables on slave to use NDB
--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
# Load DB tpcb and run some transactions
connection master;
--disable_query_log
CALL tpcb.load();
SET AUTOCOMMIT=0;
let $run= 5;
while ($run)
{
START TRANSACTION;
--eval CALL tpcb.trans($rpl_format);
eval SET @my_errno= $mysql_errno;
let $run_good= `SELECT @my_errno = 0`;
let $run_bad= `SELECT @my_errno <> 0`;
if ($run_good)
{
COMMIT;
}
if ($run_bad)
{
ROLLBACK;
}
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_using_logname.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 on master which should force it
# to switch to binlog #2
FLUSH LOGS;
# Run in some transaction to increase end pos in
# binlog
--disable_query_log
SET AUTOCOMMIT=0;
let $run= 5;
while ($run)
{
START TRANSACTION;
--eval CALL tpcb.trans($rpl_format);
eval SET @my_errno= $mysql_errno;
let $run_good= `SELECT @my_errno = 0`;
let $run_bad= `SELECT @my_errno <> 0`;
if ($run_good)
{
COMMIT;
}
if ($run_bad)
{
ROLLBACK;
}
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_using_logname.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
# Reset both slave and master
# This should reset binlog to #1
--source include/master-slave-reset.inc
--echo
# Run in some transactions and check
connection master;
--disable_query_log
SET AUTOCOMMIT=0;
let $run= 5;
while ($run)
{
START TRANSACTION;
--eval CALL tpcb.trans($rpl_format);
eval SET @my_errno= $mysql_errno;
let $run_good= `SELECT @my_errno = 0`;
let $run_bad= `SELECT @my_errno <> 0`;
if ($run_good)
{
COMMIT;
}
if ($run_bad)
{
ROLLBACK;
}
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_using_logname.inc
# Since we are doing replication, it is a good
# idea to check to make sure all data was
# Replicated correctly
--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#27960 ###########
#--source include/select_ndb_apply_status.inc
#connection master;
#--eval SHOW BINLOG EVENTS in '$log_name' from $start_pos
#--source include/show_binlog_using_logname.inc
--echo ****** Do dumps compare ************
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
##################################################
# Author: Jeb
# Date: 2007/04
# Purpose: To select out log name, start and end
# positions from ndb_apply_status table
##################################################
--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`
########################################################
# Author: Jeb
# Date: 2007/04
# Purpose: To select out 1 row from offset 1
# from the start position in the binlog whose
# name is = log_name
########################################################
--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 $off_set,1
##################################################
# Author: Jeb
# Date: 2007/04
# Purpose: To create a tpcb database, tables and
# stored procedures to load the database
# and run transactions against the DB
##################################################
--disable_warnings
DROP DATABASE IF EXISTS tpcb;
--enable_warnings
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(in format varchar(3))
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;
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 (format = '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;
END|
delimiter ;|
--enable_query_log
--echo
--echo *** Stored Procedures Created ***
--echo
##################################################
# Author: Jeb
# Date: 2007/05
# Purpose: To create a tpcb database using Disk Data,
# tables and stored procedures to load the database
# and run transactions against the DB
##################################################
--disable_warnings
DROP DATABASE IF EXISTS tpcb;
--enable_warnings
CREATE DATABASE tpcb;
--echo
eval CREATE TABLE tpcb.account
(id INT, bid INT, balance DECIMAL(10,2),
filler CHAR(255), PRIMARY KEY(id))
TABLESPACE $table_space STORAGE DISK
ENGINE=$engine_type;
--echo
eval CREATE TABLE tpcb.branch
(bid INT, balance DECIMAL(10,2), filler VARCHAR(255),
PRIMARY KEY(bid))TABLESPACE $table_space STORAGE DISK
ENGINE=$engine_type;
--echo
eval CREATE TABLE tpcb.teller
(tid INT, balance DECIMAL(10,2), filler VARCHAR(255),
PRIMARY KEY(tid)) TABLESPACE $table_space STORAGE DISK
ENGINE=$engine_type;
--echo
eval 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))
TABLESPACE $table_space STORAGE DISK
ENGINE=$engine_type;
--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(in format varchar(3))
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;
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 (format = '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;
END|
delimiter ;|
--enable_query_log
--echo
--echo *** Stored Procedures Created ***
--echo
...@@ -56,6 +56,7 @@ undofile.dat UNDO LOG NULL lg1 ...@@ -56,6 +56,7 @@ undofile.dat UNDO LOG NULL lg1
undofile02.dat UNDO LOG NULL lg1 undofile02.dat UNDO LOG NULL lg1
**** Do First Set of ALTERs in the master table **** **** Do First Set of ALTERs in the master table ****
CREATE INDEX t1_i ON t1(c2, c3); CREATE INDEX t1_i ON t1(c2, c3);
CREATE UNIQUE INDEX t1_i2 ON t1(c2);
ALTER TABLE t1 ADD c4 TIMESTAMP; ALTER TABLE t1 ADD c4 TIMESTAMP;
ALTER TABLE t1 ADD c5 DOUBLE; ALTER TABLE t1 ADD c5 DOUBLE;
ALTER TABLE t1 ADD INDEX (c5); ALTER TABLE t1 ADD INDEX (c5);
...@@ -68,6 +69,7 @@ t1 CREATE TABLE `t1` ( ...@@ -68,6 +69,7 @@ t1 CREATE TABLE `t1` (
`c4` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `c4` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`c5` double DEFAULT NULL, `c5` double DEFAULT NULL,
PRIMARY KEY (`c1`), PRIMARY KEY (`c1`),
UNIQUE KEY `t1_i2` (`c2`),
KEY `t1_i` (`c2`,`c3`), KEY `t1_i` (`c2`,`c3`),
KEY `c5` (`c5`) KEY `c5` (`c5`)
) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 ) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
...@@ -81,6 +83,7 @@ t1 CREATE TABLE `t1` ( ...@@ -81,6 +83,7 @@ t1 CREATE TABLE `t1` (
`c4` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `c4` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`c5` double DEFAULT NULL, `c5` double DEFAULT NULL,
PRIMARY KEY (`c1`), PRIMARY KEY (`c1`),
UNIQUE KEY `t1_i2` (`c2`),
KEY `t1_i` (`c2`,`c3`), KEY `t1_i` (`c2`,`c3`),
KEY `c5` (`c5`) KEY `c5` (`c5`)
) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 ) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
...@@ -101,6 +104,7 @@ t1 CREATE TABLE `t1` ( ...@@ -101,6 +104,7 @@ t1 CREATE TABLE `t1` (
`c4` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `c4` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`c5` double DEFAULT NULL, `c5` double DEFAULT NULL,
PRIMARY KEY (`c1`), PRIMARY KEY (`c1`),
UNIQUE KEY `t1_i2` (`c2`),
KEY `t1_i` (`c2`,`c3`) KEY `t1_i` (`c2`,`c3`)
) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 ) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
**** Show second set of ALTERs on SLAVE **** **** Show second set of ALTERs on SLAVE ****
...@@ -113,6 +117,7 @@ t1 CREATE TABLE `t1` ( ...@@ -113,6 +117,7 @@ t1 CREATE TABLE `t1` (
`c4` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `c4` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`c5` double DEFAULT NULL, `c5` double DEFAULT NULL,
PRIMARY KEY (`c1`), PRIMARY KEY (`c1`),
UNIQUE KEY `t1_i2` (`c2`),
KEY `t1_i` (`c2`,`c3`) KEY `t1_i` (`c2`,`c3`)
) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 ) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
**** Third and last set of alters for test1 **** **** Third and last set of alters for test1 ****
...@@ -135,6 +140,7 @@ t1 CREATE TABLE `t1` ( ...@@ -135,6 +140,7 @@ t1 CREATE TABLE `t1` (
`c3` blob, `c3` blob,
`c5` double DEFAULT NULL, `c5` double DEFAULT NULL,
PRIMARY KEY (`c1`), PRIMARY KEY (`c1`),
UNIQUE KEY `t1_i2` (`c2`),
KEY `t1_i` (`c2`) KEY `t1_i` (`c2`)
) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 ) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
SELECT * FROM t1 ORDER BY c1 LIMIT 5; SELECT * FROM t1 ORDER BY c1 LIMIT 5;
...@@ -153,8 +159,16 @@ t1 CREATE TABLE `t1` ( ...@@ -153,8 +159,16 @@ t1 CREATE TABLE `t1` (
`c3` blob, `c3` blob,
`c5` double DEFAULT NULL, `c5` double DEFAULT NULL,
PRIMARY KEY (`c1`), PRIMARY KEY (`c1`),
UNIQUE KEY `t1_i2` (`c2`),
KEY `t1_i` (`c2`) KEY `t1_i` (`c2`)
) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1 ) /*!50100 TABLESPACE ts1 STORAGE DISK */ ENGINE=ndbcluster DEFAULT CHARSET=latin1
SELECT * FROM t1 ORDER BY c1 LIMIT 5;
c1 c2 c3 c5
1 2.00 b1b1b1b1b1b1b1b1b1b1 NULL
2 4.00 b1b1b1b1b1b1b1b1b1b1 NULL
3 6.00 0000-00-00 00:00:00 NULL
4 8.00 0000-00-00 00:00:00 NULL
5 10.00 0000-00-00 00:00:00 NULL
SELECT * FROM t1 where c1 = 1; SELECT * FROM t1 where c1 = 1;
c1 c2 c3 c5 c1 c2 c3 c5
1 2.00 b1b1b1b1b1b1b1b1b1b1 NULL 1 2.00 b1b1b1b1b1b1b1b1b1b1 NULL
...@@ -167,148 +181,44 @@ START SLAVE; ...@@ -167,148 +181,44 @@ START SLAVE;
CREATE TABLESPACE ts2 CREATE TABLESPACE ts2
ADD DATAFILE 'datafile03.dat' ADD DATAFILE 'datafile03.dat'
USE LOGFILE GROUP lg1 USE LOGFILE GROUP lg1
INITIAL_SIZE 12M INITIAL_SIZE 10M
ENGINE=NDB; ENGINE=NDB;
ALTER TABLESPACE ts2 ALTER TABLESPACE ts2
ADD DATAFILE 'datafile04.dat' ADD DATAFILE 'datafile04.dat'
INITIAL_SIZE 12M INITIAL_SIZE 5M
ENGINE=NDB; ENGINE=NDB;
DROP DATABASE IF EXISTS tpcb; DROP DATABASE IF EXISTS tpcb;
Warnings:
Note 1008 Can't drop database 'tpcb'; database doesn't exist
CREATE DATABASE tpcb; CREATE DATABASE tpcb;
*********** Create TPCB Tables *****************
CREATE TABLE tpcb.account CREATE TABLE tpcb.account
(id INT, bid INT, balance DECIMAL(10,2), (id INT, bid INT, balance DECIMAL(10,2),
filler CHAR(255), PRIMARY KEY(id)) filler CHAR(255), PRIMARY KEY(id))
TABLESPACE ts1 STORAGE DISK TABLESPACE ts2 STORAGE DISK
ENGINE=NDB; ENGINE=NDBCLUSTER;
CREATE TABLE tpcb.branch CREATE TABLE tpcb.branch
(bid INT, balance DECIMAL(10,2), filler VARCHAR(255), (bid INT, balance DECIMAL(10,2), filler VARCHAR(255),
PRIMARY KEY(bid)) PRIMARY KEY(bid))TABLESPACE ts2 STORAGE DISK
ENGINE=NDB; ENGINE=NDBCLUSTER;
CREATE TABLE tpcb.teller CREATE TABLE tpcb.teller
(tid INT, balance DECIMAL(10,2), filler VARCHAR(255), (tid INT, balance DECIMAL(10,2), filler VARCHAR(255),
PRIMARY KEY(tid)) PRIMARY KEY(tid)) TABLESPACE ts2 STORAGE DISK
TABLESPACE ts2 STORAGE DISK ENGINE=NDBCLUSTER;
ENGINE=NDB;
CREATE TABLE tpcb.history CREATE TABLE tpcb.history
(id MEDIUMINT NOT NULL AUTO_INCREMENT,aid INT, (id MEDIUMINT NOT NULL AUTO_INCREMENT,aid INT,
tid INT, bid INT, amount DECIMAL(10,2), tid INT, bid INT, amount DECIMAL(10,2),
tdate DATETIME, teller CHAR(20), uuidf LONGBLOB, tdate DATETIME, teller CHAR(20), uuidf LONGBLOB,
filler CHAR(80),PRIMARY KEY (id)) filler CHAR(80),PRIMARY KEY (id))
TABLESPACE ts2 STORAGE DISK TABLESPACE ts2 STORAGE DISK
ENGINE=NDB; ENGINE=NDBCLUSTER;
********* Create Procedures and Functions ************
CREATE PROCEDURE tpcb.load() --- Create stored procedures & functions ---
BEGIN
DECLARE acct INT DEFAULT 1000;
DECLARE brch INT DEFAULT 100; *** Stored Procedures Created ***
DECLARE tell INT DEFAULT 1000;
DECLARE tmp INT DEFAULT 100;
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 < 2)
THEN
SELECT RAND() * 10 INTO num;
ELSEIF (ran < 4)
THEN
SELECT RAND() * 100 INTO num;
ELSE
SELECT RAND() * 1000 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 < 2)
THEN
SELECT RAND() * 10 INTO num;
ELSEIF (ran < 5)
THEN
SELECT RAND() * 100 INTO num;
ELSE
SELECT RAND() * 1000 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;
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;
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');
END|
****** TEST 2 test time ********************************* ****** TEST 2 test time *********************************
USE tpcb; USE tpcb;
*********** Load up the database ****************** *********** Load up the database ******************
...@@ -316,11 +226,11 @@ CALL tpcb.load(); ...@@ -316,11 +226,11 @@ CALL tpcb.load();
********** Check load master and slave ************** ********** Check load master and slave **************
SELECT COUNT(*) FROM account; SELECT COUNT(*) FROM account;
COUNT(*) COUNT(*)
10000 1000
USE tpcb; USE tpcb;
SELECT COUNT(*) FROM account; SELECT COUNT(*) FROM account;
COUNT(*) COUNT(*)
10000 1000
******** Run in some transactions *************** ******** Run in some transactions ***************
***** Time to try slave sync *********** ***** Time to try slave sync ***********
**** Must make sure slave is clean ***** **** Must make sure slave is clean *****
...@@ -351,10 +261,10 @@ DROP LOGFILE GROUP lg1 ENGINE=NDB; ...@@ -351,10 +261,10 @@ DROP LOGFILE GROUP lg1 ENGINE=NDB;
********** Take a backup of the Master ************* ********** Take a backup of the Master *************
SELECT COUNT(*) FROM history; SELECT COUNT(*) FROM history;
COUNT(*) COUNT(*)
1000 100
SELECT COUNT(*) FROM history; SELECT COUNT(*) FROM history;
COUNT(*) COUNT(*)
2000 200
CREATE TEMPORARY TABLE IF NOT EXISTS mysql.backup_info (id INT, backup_id INT) ENGINE = HEAP; CREATE TEMPORARY TABLE IF NOT EXISTS mysql.backup_info (id INT, backup_id INT) ENGINE = HEAP;
DELETE FROM mysql.backup_info; DELETE FROM mysql.backup_info;
LOAD DATA INFILE '../tmp.dat' INTO TABLE mysql.backup_info FIELDS TERMINATED BY ','; LOAD DATA INFILE '../tmp.dat' INTO TABLE mysql.backup_info FIELDS TERMINATED BY ',';
...@@ -368,7 +278,7 @@ CREATE DATABASE tpcb; ...@@ -368,7 +278,7 @@ CREATE DATABASE tpcb;
USE tpcb; USE tpcb;
SELECT COUNT(*) FROM account; SELECT COUNT(*) FROM account;
COUNT(*) COUNT(*)
10000 1000
***** Add some more records to master ********* ***** Add some more records to master *********
***** Finsh the slave sync process ******* ***** Finsh the slave sync process *******
@the_epoch:=MAX(epoch) @the_epoch:=MAX(epoch)
...@@ -384,12 +294,12 @@ START SLAVE; ...@@ -384,12 +294,12 @@ START SLAVE;
USE tpcb; USE tpcb;
SELECT COUNT(*) FROM history; SELECT COUNT(*) FROM history;
COUNT(*) COUNT(*)
4050 400
****** SLAVE ******** ****** SLAVE ********
USE tpcb; USE tpcb;
SELECT COUNT(*) FROM history; SELECT COUNT(*) FROM history;
COUNT(*) COUNT(*)
4050 400
*** DUMP MASTER & SLAVE FOR COMPARE ******** *** DUMP MASTER & SLAVE FOR COMPARE ********
*************** TEST 2 CLEANUP SECTION ******************** *************** TEST 2 CLEANUP SECTION ********************
DROP PROCEDURE IF EXISTS tpcb.load; DROP PROCEDURE IF EXISTS tpcb.load;
......
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;
*** 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 @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 @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 ***
DROP DATABASE IF EXISTS tpcb;
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 9,1;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Xid 1 <end_pos> COMMIT /* XID */
** 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 9,1;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000002 # Xid 1 <end_pos> COMMIT /* XID */
** 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 9,1;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Xid 1 <end_pos> COMMIT /* XID */
*** DUMP MASTER & SLAVE FOR COMPARE ********
DROP DATABASE tpcb;
****** Do dumps compare ************
...@@ -4,34 +4,126 @@ reset master; ...@@ -4,34 +4,126 @@ reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave; start slave;
*** Test 1 ***
create table t1 (a int key, b int) engine innodb; create table t1 (a int key, b int) engine innodb;
create table t2 (a int key, b int) engine innodb; create table t2 (a int key, b int) engine innodb;
alter table t1 engine ndb; alter table t1 engine ndb;
alter table t2 engine ndb; alter table t2 engine ndb;
insert into t1 values (1,2); 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 select @log_name:=log_name, @start_pos:=start_pos, @end_pos:=end_pos
<start_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; show binlog events from <start_pos> limit 1;
Log_name Pos Event_type Server_id End_log_pos Info 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) master-bin.000001 <start_pos> Query 1 # use `test`; insert into t1 values (1,2)
show binlog events from <start_pos> limit 1,1; show binlog events from <start_pos> limit 1,1;
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Xid 1 445 COMMIT /* XID */ master-bin.000001 # Xid 1 445 COMMIT /* XID */
begin; begin;
insert into t1 values (2,3); insert into t1 values (2,3);
insert into t2 values (3,4); insert into t2 values (3,4);
commit; commit;
select @start_pos:=start_pos, @end_pos:=end_pos from mysql.ndb_apply_status;
@start_pos:=start_pos @end_pos:=end_pos select @log_name:=log_name, @start_pos:=start_pos, @end_pos:=end_pos
<start_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; show binlog events from <start_pos> limit 1;
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 <start_pos> Query 1 # use `test`; BEGIN master-bin.000001 <start_pos> Query 1 # use `test`; BEGIN
show binlog events from <start_pos> limit 1,2; show binlog events from <start_pos> limit 1,2;
Log_name Pos Event_type Server_id End_log_pos Info 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 t1 values (2,3)
master-bin.000001 # Query # # use `test`; insert into t2 values (3,4) master-bin.000001 # Query # # use `test`; insert into t2 values (3,4)
show binlog events from <start_pos> limit 3,1; show binlog events from <start_pos> limit 3,1;
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Xid 1 <end_pos> COMMIT /* XID */ master-bin.000001 # Xid 1 <end_pos> COMMIT /* XID */
DROP TABLE test.t1, test.t2;
SHOW TABLES;
Tables_in_test
*** Test 2 ***
DROP DATABASE IF EXISTS tpcb;
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 6,1;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Xid 1 <end_pos> COMMIT /* XID */
** 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 6,1;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000002 # Xid 1 <end_pos> COMMIT /* XID */
** 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 6,1;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Xid 1 <end_pos> COMMIT /* XID */
*** DUMP MASTER & SLAVE FOR COMPARE ********
DROP DATABASE tpcb;
****** Do dumps compare ************
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
--source include/have_binlog_format_row.inc --source include/have_binlog_format_row.inc
--source include/ndb_default_cluster.inc --source include/ndb_default_cluster.inc
--source include/not_embedded.inc --source include/not_embedded.inc
--source include/big_test.inc #--source include/big_test.inc
#--source include/have_ndb_extra.inc #--source include/have_ndb_extra.inc
--source include/ndb_master-slave.inc --source include/ndb_master-slave.inc
...@@ -98,7 +98,7 @@ SELECT DISTINCT FILE_NAME, FILE_TYPE, TABLESPACE_NAME, LOGFILE_GROUP_NAME ...@@ -98,7 +98,7 @@ SELECT DISTINCT FILE_NAME, FILE_TYPE, TABLESPACE_NAME, LOGFILE_GROUP_NAME
connection master; connection master;
CREATE INDEX t1_i ON t1(c2, c3); CREATE INDEX t1_i ON t1(c2, c3);
#Bug 18039 #Bug 18039
#CREATE UNIQUE INDEX t1_i2 ON t1(c2); CREATE UNIQUE INDEX t1_i2 ON t1(c2);
ALTER TABLE t1 ADD c4 TIMESTAMP; ALTER TABLE t1 ADD c4 TIMESTAMP;
ALTER TABLE t1 ADD c5 DOUBLE; ALTER TABLE t1 ADD c5 DOUBLE;
ALTER TABLE t1 ADD INDEX (c5); ALTER TABLE t1 ADD INDEX (c5);
...@@ -170,7 +170,7 @@ SELECT * FROM t1 ORDER BY c1 LIMIT 5; ...@@ -170,7 +170,7 @@ SELECT * FROM t1 ORDER BY c1 LIMIT 5;
connection slave; connection slave;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
# Bug 18094 # Bug 18094
#SELECT * FROM t1 ORDER BY c1 LIMIT 5; SELECT * FROM t1 ORDER BY c1 LIMIT 5;
SELECT * FROM t1 where c1 = 1; SELECT * FROM t1 where c1 = 1;
connection master; connection master;
...@@ -198,163 +198,19 @@ connection master; ...@@ -198,163 +198,19 @@ connection master;
CREATE TABLESPACE ts2 CREATE TABLESPACE ts2
ADD DATAFILE 'datafile03.dat' ADD DATAFILE 'datafile03.dat'
USE LOGFILE GROUP lg1 USE LOGFILE GROUP lg1
INITIAL_SIZE 12M INITIAL_SIZE 10M
ENGINE=NDB; ENGINE=NDB;
ALTER TABLESPACE ts2 ALTER TABLESPACE ts2
ADD DATAFILE 'datafile04.dat' ADD DATAFILE 'datafile04.dat'
INITIAL_SIZE 12M INITIAL_SIZE 5M
ENGINE=NDB; ENGINE=NDB;
###### CLEAN UP SECTION ############## let engine_type=NDBCLUSTER;
DROP DATABASE IF EXISTS tpcb; let table_space=ts2;
CREATE DATABASE tpcb; let format='RBR';
######## Creat Table Section #########
--echo *********** Create TPCB Tables *****************
CREATE TABLE tpcb.account
(id INT, bid INT, balance DECIMAL(10,2),
filler CHAR(255), PRIMARY KEY(id))
TABLESPACE ts1 STORAGE DISK
ENGINE=NDB;
CREATE TABLE tpcb.branch --source include/tpcb_disk_data.inc
(bid INT, balance DECIMAL(10,2), filler VARCHAR(255),
PRIMARY KEY(bid))
ENGINE=NDB;
CREATE TABLE tpcb.teller
(tid INT, balance DECIMAL(10,2), filler VARCHAR(255),
PRIMARY KEY(tid))
TABLESPACE ts2 STORAGE DISK
ENGINE=NDB;
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))
TABLESPACE ts2 STORAGE DISK
ENGINE=NDB;
--echo ********* Create Procedures and Functions ************
delimiter |;
CREATE PROCEDURE tpcb.load()
BEGIN
DECLARE acct INT DEFAULT 1000;
DECLARE brch INT DEFAULT 100;
DECLARE tell INT DEFAULT 1000;
DECLARE tmp INT DEFAULT 100;
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 < 2)
THEN
SELECT RAND() * 10 INTO num;
ELSEIF (ran < 4)
THEN
SELECT RAND() * 100 INTO num;
ELSE
SELECT RAND() * 1000 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 < 2)
THEN
SELECT RAND() * 10 INTO num;
ELSEIF (ran < 5)
THEN
SELECT RAND() * 100 INTO num;
ELSE
SELECT RAND() * 1000 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;
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;
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');
END|
delimiter ;|
--echo ****** TEST 2 test time ********************************* --echo ****** TEST 2 test time *********************************
USE tpcb; USE tpcb;
...@@ -372,15 +228,16 @@ SELECT COUNT(*) FROM account; ...@@ -372,15 +228,16 @@ SELECT COUNT(*) FROM account;
--echo ******** Run in some transactions *************** --echo ******** Run in some transactions ***************
connection master; connection master;
let $j= 1000; let $j= 100;
--disable_query_log --disable_query_log
while ($j) while ($j)
{ {
CALL tpcb.trans(); eval CALL tpcb.trans($format);
dec $j; dec $j;
} }
--enable_query_log --enable_query_log
--echo ***** Time to try slave sync *********** --echo ***** Time to try slave sync ***********
--echo **** Must make sure slave is clean ***** --echo **** Must make sure slave is clean *****
--connection slave --connection slave
...@@ -421,11 +278,11 @@ connection master; ...@@ -421,11 +278,11 @@ connection master;
SELECT COUNT(*) FROM history; SELECT COUNT(*) FROM history;
let $j= 1000; let $j= 100;
--disable_query_log --disable_query_log
while ($j) while ($j)
{ {
CALL tpcb.trans(); eval CALL tpcb.trans($format);
dec $j; dec $j;
} }
--enable_query_log --enable_query_log
...@@ -464,11 +321,11 @@ SELECT COUNT(*) FROM account; ...@@ -464,11 +321,11 @@ SELECT COUNT(*) FROM account;
--echo ***** Add some more records to master ********* --echo ***** Add some more records to master *********
connection master; connection master;
let $j= 1000; let $j= 100;
--disable_query_log --disable_query_log
while ($j) while ($j)
{ {
CALL tpcb.trans(); eval CALL tpcb.trans($format);
dec $j; dec $j;
} }
--enable_query_log --enable_query_log
...@@ -484,17 +341,18 @@ while ($j) ...@@ -484,17 +341,18 @@ while ($j)
--echo ***** Finsh the slave sync process ******* --echo ***** Finsh the slave sync process *******
--disable_query_log --disable_query_log
# 1. 2. 3. # 1. 2. 3.
--sync_slave_with_master
--source include/ndb_setup_slave.inc --source include/ndb_setup_slave.inc
--enable_query_log --enable_query_log
# 4. # 4.
--echo * 4. * --echo * 4. *
connection master; connection master;
let $j= 1000; let $j= 100;
--disable_query_log --disable_query_log
while ($j) while ($j)
{ {
CALL tpcb.trans(); eval CALL tpcb.trans($format);
dec $j; dec $j;
} }
--enable_query_log --enable_query_log
...@@ -507,15 +365,6 @@ START SLAVE; ...@@ -507,15 +365,6 @@ START SLAVE;
--echo **** We should be ready to continue on ************* --echo **** We should be ready to continue on *************
connection master; connection master;
let $j= 50;
--disable_query_log
while ($j)
{
CALL tpcb.trans();
dec $j;
}
--enable_query_log
--echo ****** Let's make sure we match ******* --echo ****** Let's make sure we match *******
--echo ***** MASTER ******* --echo ***** MASTER *******
USE tpcb; USE tpcb;
......
--innodb --default-storage-engine=innodb
#############################################
#Authors: TU and Jeb
#Date: 2007/04
#Purpose: Generic replication to cluster
# and ensuring that the ndb_apply_status
# table is updated.
#############################################
# Notes:
# include/select_ndb_apply_status.inc
# Selects out the log name, start & end pos
# from the ndb_apply_status table
#
# include/show_binlog_using_logname.inc
# To select out 1 row from offset 1
# from the start position in the binlog whose
# name is = log_name
#
# include/tpcb.inc
# Creates DATABASE tpcb, the tables and
# stored procedures for loading the DB
# and for running transactions against DB.
##############################################
## Includes ##
--disable_query_log
--source include/have_ndb.inc
--source include/have_innodb.inc
--source include/have_binlog_format_mixed.inc
--source include/ndb_master-slave.inc
--enable_query_log
let $off_set = 9;
let $rpl_format = 'MIX';
--source extra/rpl_tests/rpl_ndb_apply_status.test
--innodb --innodb --default-storage-engine=innodb
#############################################
#Authors: TU and Jeb
#Date: 2007/04
#Purpose: Generic replication to cluster
# and ensuring that the ndb_apply_status
# table is updated.
#############################################
# Notes:
# include/select_ndb_apply_status.inc
# Selects out the log name, start & end pos
# from the ndb_apply_status table
#
# include/show_binlog_using_logname.inc
# To select out 1 row from offset 1
# from the start position in the binlog whose
# name is = log_name
#
# include/tpcb.inc
# Creates DATABASE tpcb, the tables and
# stored procedures for loading the DB
# and for running transactions against DB.
##############################################
## Includes ##
--disable_query_log
--source include/have_ndb.inc --source include/have_ndb.inc
--source include/have_innodb.inc --source include/have_innodb.inc
--source include/have_binlog_format_mixed_or_statement.inc --source include/have_binlog_format_statement.inc
--source include/ndb_master-slave.inc --source include/ndb_master-slave.inc
--enable_query_log
--connection master let $off_set = 6;
create table t1 (a int key, b int) engine innodb; let $rpl_format = 'SBR';
create table t2 (a int key, b int) engine innodb; --source extra/rpl_tests/rpl_ndb_apply_status.test
--sync_slave_with_master
--connection slave
alter table t1 engine ndb;
alter table t2 engine ndb;
# check binlog position without begin
--connection master
insert into t1 values (1,2);
--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`
--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
--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
# check binlog position with begin
--connection master
begin;
insert into t1 values (2,3);
insert into t2 values (3,4);
commit;
--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`
--connection master
--replace_result $start_pos <start_pos>
--replace_column 5 #
--eval show binlog events from $start_pos limit 1
--replace_result $start_pos <start_pos>
--replace_column 2 # 4 # 5 #
--eval show binlog events from $start_pos limit 1,2
--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
...@@ -4,8 +4,8 @@ Next NDBFS 2000 ...@@ -4,8 +4,8 @@ Next NDBFS 2000
Next DBACC 3002 Next DBACC 3002
Next DBTUP 4029 Next DBTUP 4029
Next DBLQH 5045 Next DBLQH 5045
Next DBDICT 6007 Next DBDICT 6008
Next DBDIH 7184 Next DBDIH 7186
Next DBTC 8040 Next DBTC 8040
Next CMVMI 9000 Next CMVMI 9000
Next BACKUP 10038 Next BACKUP 10038
...@@ -77,6 +77,10 @@ Delay GCP_SAVEREQ by 10 secs ...@@ -77,6 +77,10 @@ Delay GCP_SAVEREQ by 10 secs
7183: Crash when receiving COPY_GCIREQ 7183: Crash when receiving COPY_GCIREQ
7184: Crash before starting next GCP after a node failure
7185: Dont reply to COPY_GCI_REQ where reason == GCP
ERROR CODES FOR TESTING NODE FAILURE, LOCAL CHECKPOINT HANDLING: ERROR CODES FOR TESTING NODE FAILURE, LOCAL CHECKPOINT HANDLING:
----------------------------------------------------------------- -----------------------------------------------------------------
...@@ -503,6 +507,7 @@ Dbdict: ...@@ -503,6 +507,7 @@ Dbdict:
6003 Crash in participant @ CreateTabReq::Prepare 6003 Crash in participant @ CreateTabReq::Prepare
6004 Crash in participant @ CreateTabReq::Commit 6004 Crash in participant @ CreateTabReq::Commit
6005 Crash in participant @ CreateTabReq::CreateDrop 6005 Crash in participant @ CreateTabReq::CreateDrop
6007 Fail on readTableFile for READ_TAB_FILE1 (28770)
Dbtup: Dbtup:
4014 - handleInsert - Out of undo buffer 4014 - handleInsert - Out of undo buffer
......
...@@ -802,6 +802,15 @@ void Dbdict::execFSREADCONF(Signal* signal) ...@@ -802,6 +802,15 @@ void Dbdict::execFSREADCONF(Signal* signal)
readSchemaConf(signal ,fsPtr); readSchemaConf(signal ,fsPtr);
break; break;
case FsConnectRecord::READ_TAB_FILE1: case FsConnectRecord::READ_TAB_FILE1:
if(ERROR_INSERTED(6007)){
jam();
FsRef * const fsRef = (FsRef *)&signal->theData[0];
fsRef->userPointer = fsConf->userPointer;
fsRef->setErrorCode(fsRef->errorCode, NDBD_EXIT_AFS_UNKNOWN);
fsRef->osErrorCode = ~0; // Indicate local error
execFSREADREF(signal);
return;
}//Testing how DICT behave if read of file 1 fails (Bug#28770)
case FsConnectRecord::READ_TAB_FILE2: case FsConnectRecord::READ_TAB_FILE2:
jam(); jam();
readTableConf(signal ,fsPtr); readTableConf(signal ,fsPtr);
......
...@@ -898,7 +898,7 @@ private: ...@@ -898,7 +898,7 @@ private:
void ndbsttorry10Lab(Signal *, Uint32 _line); void ndbsttorry10Lab(Signal *, Uint32 _line);
void createMutexes(Signal* signal, Uint32 no); void createMutexes(Signal* signal, Uint32 no);
void createMutex_done(Signal* signal, Uint32 no, Uint32 retVal); void createMutex_done(Signal* signal, Uint32 no, Uint32 retVal);
void crashSystemAtGcpStop(Signal *); void crashSystemAtGcpStop(Signal *, bool);
void sendFirstDictfragsreq(Signal *, TabRecordPtr regTabPtr); void sendFirstDictfragsreq(Signal *, TabRecordPtr regTabPtr);
void addtabrefuseLab(Signal *, ConnectRecordPtr regConnectPtr, Uint32 errorCode); void addtabrefuseLab(Signal *, ConnectRecordPtr regConnectPtr, Uint32 errorCode);
void GCP_SAVEhandling(Signal *, Uint32 nodeId); void GCP_SAVEhandling(Signal *, Uint32 nodeId);
......
...@@ -749,6 +749,12 @@ done: ...@@ -749,6 +749,12 @@ done:
CRASH_INSERTION(7183); CRASH_INSERTION(7183);
if (ERROR_INSERTED(7185) && reason==CopyGCIReq::GLOBAL_CHECKPOINT)
{
jam();
return;
}
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/* WE START BY TRYING TO OPEN THE FIRST RESTORABLE GCI FILE. */ /* WE START BY TRYING TO OPEN THE FIRST RESTORABLE GCI FILE. */
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
...@@ -4152,6 +4158,11 @@ void Dbdih::execNODE_FAILREP(Signal* signal) ...@@ -4152,6 +4158,11 @@ void Dbdih::execNODE_FAILREP(Signal* signal)
CLEAR_ERROR_INSERT_VALUE; CLEAR_ERROR_INSERT_VALUE;
} }
if (ERROR_INSERTED(7184))
{
SET_ERROR_INSERT_VALUE(7000);
}
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
// The first step is to convert from a bit mask to an array of failed nodes. // The first step is to convert from a bit mask to an array of failed nodes.
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
...@@ -7826,7 +7837,7 @@ void Dbdih::checkGcpStopLab(Signal* signal) ...@@ -7826,7 +7837,7 @@ void Dbdih::checkGcpStopLab(Signal* signal)
g_eventLogger.error("System crash due to GCP Stop in state = %u", g_eventLogger.error("System crash due to GCP Stop in state = %u",
(Uint32) cgcpStatus); (Uint32) cgcpStatus);
#endif #endif
crashSystemAtGcpStop(signal); crashSystemAtGcpStop(signal, false);
return; return;
}//if }//if
} else { } else {
...@@ -7840,7 +7851,7 @@ void Dbdih::checkGcpStopLab(Signal* signal) ...@@ -7840,7 +7851,7 @@ void Dbdih::checkGcpStopLab(Signal* signal)
g_eventLogger.error("System crash due to GCP Stop in state = %u", g_eventLogger.error("System crash due to GCP Stop in state = %u",
(Uint32) cgcpStatus); (Uint32) cgcpStatus);
#endif #endif
crashSystemAtGcpStop(signal); crashSystemAtGcpStop(signal, false);
return; return;
}//if }//if
} else { } else {
...@@ -11196,37 +11207,128 @@ void Dbdih::tableCloseLab(Signal* signal, FileRecordPtr filePtr) ...@@ -11196,37 +11207,128 @@ void Dbdih::tableCloseLab(Signal* signal, FileRecordPtr filePtr)
* GCP stop detected, * GCP stop detected,
* send SYSTEM_ERROR to all other alive nodes * send SYSTEM_ERROR to all other alive nodes
*/ */
void Dbdih::crashSystemAtGcpStop(Signal* signal) void Dbdih::crashSystemAtGcpStop(Signal* signal, bool local)
{ {
if (local)
goto dolocal;
switch(cgcpStatus){ switch(cgcpStatus){
case GCP_PREPARE_SENT:
{
jam();
/**
* We're waiting for a GCP PREPARE CONF
*/
infoEvent("Detected GCP stop(%d)...sending kill to %s",
cgcpStatus, c_GCP_PREPARE_Counter.getText());
ndbout_c("Detected GCP stop(%d)...sending kill to %s",
cgcpStatus, c_GCP_PREPARE_Counter.getText());
{
NodeReceiverGroup rg(DBDIH, c_GCP_PREPARE_Counter);
signal->theData[0] = 7022;
sendSignal(rg, GSN_DUMP_STATE_ORD, signal, 1, JBA);
}
{
NodeReceiverGroup rg(NDBCNTR, c_GCP_PREPARE_Counter);
SystemError * const sysErr = (SystemError*)&signal->theData[0];
sysErr->errorCode = SystemError::GCPStopDetected;
sysErr->errorRef = reference();
sysErr->data1 = cgcpStatus;
sysErr->data2 = cgcpOrderBlocked;
sendSignal(rg, GSN_SYSTEM_ERROR, signal,
SystemError::SignalLength, JBA);
}
ndbrequire(!c_GCP_PREPARE_Counter.done());
return;
}
case GCP_COMMIT_SENT:
{
jam();
/**
* We're waiting for a GCP_NODEFINISH
*/
infoEvent("Detected GCP stop(%d)...sending kill to %s",
cgcpStatus, c_GCP_COMMIT_Counter.getText());
ndbout_c("Detected GCP stop(%d)...sending kill to %s",
cgcpStatus, c_GCP_COMMIT_Counter.getText());
{
NodeReceiverGroup rg(DBDIH, c_GCP_COMMIT_Counter);
signal->theData[0] = 7022;
sendSignal(rg, GSN_DUMP_STATE_ORD, signal, 1, JBA);
}
{
NodeReceiverGroup rg(NDBCNTR, c_GCP_COMMIT_Counter);
SystemError * const sysErr = (SystemError*)&signal->theData[0];
sysErr->errorCode = SystemError::GCPStopDetected;
sysErr->errorRef = reference();
sysErr->data1 = cgcpStatus;
sysErr->data2 = cgcpOrderBlocked;
sendSignal(rg, GSN_SYSTEM_ERROR, signal,
SystemError::SignalLength, JBA);
}
ndbrequire(!c_GCP_COMMIT_Counter.done());
return;
}
case GCP_NODE_FINISHED: case GCP_NODE_FINISHED:
{ {
jam();
/** /**
* We're waiting for a GCP save conf * We're waiting for a GCP save conf
*/ */
ndbrequire(!c_GCP_SAVEREQ_Counter.done());
NodeReceiverGroup rg(DBLQH, c_GCP_SAVEREQ_Counter); NodeReceiverGroup rg(DBLQH, c_GCP_SAVEREQ_Counter);
signal->theData[0] = 2305; signal->theData[0] = 2305;
sendSignal(rg, GSN_DUMP_STATE_ORD, signal, 1, JBB); sendSignal(rg, GSN_DUMP_STATE_ORD, signal, 1, JBB);
infoEvent("Detected GCP stop...sending kill to %s", infoEvent("Detected GCP stop(%d)...sending kill to %s",
c_GCP_SAVEREQ_Counter.getText()); cgcpStatus, c_GCP_SAVEREQ_Counter.getText());
g_eventLogger.error("Detected GCP stop...sending kill to %s", ndbout_c("Detected GCP stop(%d)...sending kill to %s",
c_GCP_SAVEREQ_Counter.getText()); cgcpStatus, c_GCP_SAVEREQ_Counter.getText());
ndbrequire(!c_GCP_SAVEREQ_Counter.done());
return; return;
} }
case GCP_SAVE_LQH_FINISHED: case GCP_SAVE_LQH_FINISHED:
g_eventLogger.error("m_copyReason: %d m_waiting: %d", {
jam();
/**
* We're waiting for a COPY_GCICONF
*/
infoEvent("Detected GCP stop(%d)...sending kill to %s",
cgcpStatus, c_COPY_GCIREQ_Counter.getText());
ndbout_c("Detected GCP stop(%d)...sending kill to %s",
cgcpStatus, c_COPY_GCIREQ_Counter.getText());
{
NodeReceiverGroup rg(DBDIH, c_COPY_GCIREQ_Counter);
signal->theData[0] = 7022;
sendSignal(rg, GSN_DUMP_STATE_ORD, signal, 1, JBA);
}
{
NodeReceiverGroup rg(NDBCNTR, c_COPY_GCIREQ_Counter);
SystemError * const sysErr = (SystemError*)&signal->theData[0];
sysErr->errorCode = SystemError::GCPStopDetected;
sysErr->errorRef = reference();
sysErr->data1 = cgcpStatus;
sysErr->data2 = cgcpOrderBlocked;
sendSignal(rg, GSN_SYSTEM_ERROR, signal,
SystemError::SignalLength, JBA);
}
ndbrequire(!c_COPY_GCIREQ_Counter.done());
return;
}
case GCP_READY: (void)1;
}
dolocal:
ndbout_c("m_copyReason: %d m_waiting: %d",
c_copyGCIMaster.m_copyReason, c_copyGCIMaster.m_copyReason,
c_copyGCIMaster.m_waiting); c_copyGCIMaster.m_waiting);
break;
case GCP_READY: // shut up lint
case GCP_PREPARE_SENT:
case GCP_COMMIT_SENT:
break;
}
g_eventLogger.error("c_copyGCISlave: sender{Data, Ref} %d %x reason: %d nextWord: %d", ndbout_c("c_copyGCISlave: sender{Data, Ref} %d %x reason: %d nextWord: %d",
c_copyGCISlave.m_senderData, c_copyGCISlave.m_senderData,
c_copyGCISlave.m_senderRef, c_copyGCISlave.m_senderRef,
c_copyGCISlave.m_copyReason, c_copyGCISlave.m_copyReason,
...@@ -11281,6 +11383,9 @@ void Dbdih::crashSystemAtGcpStop(Signal* signal) ...@@ -11281,6 +11383,9 @@ void Dbdih::crashSystemAtGcpStop(Signal* signal)
c_TCGETOPSIZEREQ_Counter.getText()); c_TCGETOPSIZEREQ_Counter.getText());
ndbout_c("c_UPDATE_TOREQ_Counter = %s", c_UPDATE_TOREQ_Counter.getText()); ndbout_c("c_UPDATE_TOREQ_Counter = %s", c_UPDATE_TOREQ_Counter.getText());
if (local == false)
{
jam();
NodeRecordPtr nodePtr; NodeRecordPtr nodePtr;
for (nodePtr.i = 1; nodePtr.i < MAX_NDB_NODES; nodePtr.i++) { for (nodePtr.i = 1; nodePtr.i < MAX_NDB_NODES; nodePtr.i++) {
jam(); jam();
...@@ -11298,6 +11403,19 @@ void Dbdih::crashSystemAtGcpStop(Signal* signal) ...@@ -11298,6 +11403,19 @@ void Dbdih::crashSystemAtGcpStop(Signal* signal)
SystemError::SignalLength, JBA); SystemError::SignalLength, JBA);
}//if }//if
}//for }//for
}
else
{
jam();
SystemError * const sysErr = (SystemError*)&signal->theData[0];
sysErr->errorCode = SystemError::GCPStopDetected;
sysErr->errorRef = reference();
sysErr->data1 = cgcpStatus;
sysErr->data2 = cgcpOrderBlocked;
EXECUTE_DIRECT(NDBCNTR, GSN_SYSTEM_ERROR,
signal, SystemError::SignalLength);
ndbrequire(false);
}
return; return;
}//Dbdih::crashSystemAtGcpStop() }//Dbdih::crashSystemAtGcpStop()
...@@ -14392,6 +14510,12 @@ Dbdih::execDUMP_STATE_ORD(Signal* signal) ...@@ -14392,6 +14510,12 @@ Dbdih::execDUMP_STATE_ORD(Signal* signal)
infoEvent(buf); infoEvent(buf);
} }
} }
if (arg == 7022)
{
jam();
crashSystemAtGcpStop(signal, true);
}
}//Dbdih::execDUMP_STATE_ORD() }//Dbdih::execDUMP_STATE_ORD()
void void
......
...@@ -1586,7 +1586,8 @@ public: ...@@ -1586,7 +1586,8 @@ public:
ACTIVE_WRITE_LOG = 17, ///< A write operation during ACTIVE_WRITE_LOG = 17, ///< A write operation during
///< writing of log ///< writing of log
READ_SR_INVALIDATE_PAGES = 18, READ_SR_INVALIDATE_PAGES = 18,
WRITE_SR_INVALIDATE_PAGES = 19 WRITE_SR_INVALIDATE_PAGES = 19,
WRITE_SR_INVALIDATE_PAGES_UPDATE_PAGE0 = 20
}; };
/** /**
* We have to remember the log pages read. * We have to remember the log pages read.
...@@ -2381,7 +2382,7 @@ private: ...@@ -2381,7 +2382,7 @@ private:
void errorReport(Signal* signal, int place); void errorReport(Signal* signal, int place);
void warningReport(Signal* signal, int place); void warningReport(Signal* signal, int place);
void invalidateLogAfterLastGCI(Signal *signal); void invalidateLogAfterLastGCI(Signal *signal);
void readFileInInvalidate(Signal *signal); void readFileInInvalidate(Signal *signal, bool stepNext);
void exitFromInvalidate(Signal* signal); void exitFromInvalidate(Signal* signal);
Uint32 calcPageCheckSum(LogPageRecordPtr logP); Uint32 calcPageCheckSum(LogPageRecordPtr logP);
Uint32 handleLongTupKey(Signal* signal, Uint32* dataPtr, Uint32 len); Uint32 handleLongTupKey(Signal* signal, Uint32* dataPtr, Uint32 len);
......
...@@ -694,7 +694,14 @@ Pgman::lirs_reference(Ptr<Page_entry> ptr) ...@@ -694,7 +694,14 @@ Pgman::lirs_reference(Ptr<Page_entry> ptr)
if (state & Page_entry::ONSTACK) if (state & Page_entry::ONSTACK)
{ {
jam(); jam();
bool at_bottom = ! pl_stack.hasPrev(ptr);
pl_stack.remove(ptr); pl_stack.remove(ptr);
if (at_bottom)
{
jam();
ndbassert(state & Page_entry::HOT);
lirs_stack_prune();
}
} }
pl_stack.add(ptr); pl_stack.add(ptr);
state |= Page_entry::ONSTACK; state |= Page_entry::ONSTACK;
...@@ -1889,9 +1896,10 @@ Pgman::drop_page(Ptr<Page_entry> ptr) ...@@ -1889,9 +1896,10 @@ Pgman::drop_page(Ptr<Page_entry> ptr)
bool at_bottom = ! pl_stack.hasPrev(ptr); bool at_bottom = ! pl_stack.hasPrev(ptr);
pl_stack.remove(ptr); pl_stack.remove(ptr);
state &= ~ Page_entry::ONSTACK; state &= ~ Page_entry::ONSTACK;
if (at_bottom && (state & Page_entry::HOT)) if (at_bottom)
{ {
jam(); jam();
ndbassert(state & Page_entry::HOT);
lirs_stack_prune(); lirs_stack_prune();
} }
} }
...@@ -1903,6 +1911,7 @@ Pgman::drop_page(Ptr<Page_entry> ptr) ...@@ -1903,6 +1911,7 @@ Pgman::drop_page(Ptr<Page_entry> ptr)
state &= ~ Page_entry::ONQUEUE; state &= ~ Page_entry::ONQUEUE;
} }
ndbassert(ptr.p->m_real_page_i != RNIL);
if (ptr.p->m_real_page_i != RNIL) if (ptr.p->m_real_page_i != RNIL)
{ {
jam(); jam();
......
...@@ -1261,6 +1261,39 @@ runBug29167(NDBT_Context* ctx, NDBT_Step* step) ...@@ -1261,6 +1261,39 @@ runBug29167(NDBT_Context* ctx, NDBT_Step* step)
return result; return result;
} }
int
runBug28770(NDBT_Context* ctx, NDBT_Step* step) {
Ndb* pNdb = GETNDB(step);
NdbRestarter restarter;
int result = NDBT_OK;
int count = 0;
Uint32 i = 0;
Uint32 loops = ctx->getNumLoops();
int records = ctx->getNumRecords();
UtilTransactions utilTrans(*ctx->getTab());
HugoTransactions hugoTrans(*ctx->getTab());
g_info << "Loading records..." << endl; hugoTrans.loadTable(pNdb,
records);
while(i<=loops && result != NDBT_FAILED){
g_info << "Loop " << i << "/"<< loops <<" started" << endl;
CHECK(restarter.restartAll(false, true, false) == 0);
NdbSleep_SecSleep(3);
CHECK(restarter.waitClusterNoStart() == 0);
restarter.insertErrorInAllNodes(6007);
CHECK(restarter.startAll()== 0);
CHECK(restarter.waitClusterStarted() == 0);
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
CHECK(count == records);
i++;
}
ndbout << " runBug28770 finished" << endl;
return result;
}
NDBT_TESTSUITE(testSystemRestart); NDBT_TESTSUITE(testSystemRestart);
TESTCASE("SR1", TESTCASE("SR1",
"Basic system restart test. Focus on testing restart from REDO log.\n" "Basic system restart test. Focus on testing restart from REDO log.\n"
...@@ -1446,6 +1479,20 @@ TESTCASE("Bug29167", "") ...@@ -1446,6 +1479,20 @@ TESTCASE("Bug29167", "")
INITIALIZER(runWaitStarted); INITIALIZER(runWaitStarted);
STEP(runBug29167); STEP(runBug29167);
} }
TESTCASE("Bug28770",
"Check readTableFile1 fails, readTableFile2 succeeds\n"
"1. Restart all node -nostart\n"
"2. Insert error 6100 into all nodes\n"
"3. Start all nodes\n"
"4. Ensure cluster start\n"
"5. Read and verify reocrds\n"
"6. Repeat until looping is completed\n"){
INITIALIZER(runWaitStarted);
INITIALIZER(runClearTable);
STEP(runBug28770);
FINALIZER(runClearTable);
}
NDBT_TESTSUITE_END(testSystemRestart); NDBT_TESTSUITE_END(testSystemRestart);
......
...@@ -489,6 +489,10 @@ max-time: 300 ...@@ -489,6 +489,10 @@ max-time: 300
cmd: testSystemRestart cmd: testSystemRestart
args: -n Bug29167 T1 args: -n Bug29167 T1
max-time: 300
cmd: testSystemRestart
args: -l 2 -n Bug28770 T1
max-time: 1000 max-time: 1000
cmd: testNodeRestart cmd: testNodeRestart
args: -n Bug27283 T1 args: -n Bug27283 T1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment