Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
0848f193
Commit
0848f193
authored
Feb 01, 2008
by
jmiller/root@ndbqa01.mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge jmiller@bk-internal.mysql.com:/home/bk/mysql-5.1-new-ndb
into mysql.com:/usr/clones/mysql-5.1-new-ndb2
parents
bbc26ea5
e57f55d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
51 deletions
+29
-51
storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp
storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp
+29
-51
No files found.
storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp
View file @
0848f193
...
@@ -58,14 +58,13 @@ syncSlaveWithMaster()
...
@@ -58,14 +58,13 @@ syncSlaveWithMaster()
know when the slave has caught up
know when the slave has caught up
*/
*/
MYSQL_RES
*
result
;
SqlResultSet
result
;
MYSQL_ROW
row
;
unsigned
int
masterEpoch
=
0
;
unsigned
int
masterEpoch
=
0
;
unsigned
int
slaveEpoch
=
0
;
unsigned
int
slaveEpoch
=
0
;
unsigned
int
slaveEpochOld
=
0
;
unsigned
int
slaveEpochOld
=
0
;
int
maxLoops
=
100
;
int
maxLoops
=
100
;
int
loopCnt
=
0
;
int
loopCnt
=
0
;
//Create a DbUtil object for the master
//Create a DbUtil object for the master
DbUtil
master
(
"mysql"
,
""
);
DbUtil
master
(
"mysql"
,
""
);
...
@@ -75,16 +74,13 @@ syncSlaveWithMaster()
...
@@ -75,16 +74,13 @@ syncSlaveWithMaster()
return
NDBT_FAILED
;
return
NDBT_FAILED
;
}
}
//Get max epoch from master
//Get max epoch from master
if
(
master
.
doQuery
(
"SELECT MAX(epoch) FROM mysql.ndb_binlog_index"
))
if
(
master
.
doQuery
(
"SELECT MAX(epoch) FROM mysql.ndb_binlog_index"
,
result
))
{
{
return
NDBT_FAILED
;
return
NDBT_FAILED
;
}
}
result
=
mysql_use_result
(
master
.
getMysql
());
masterEpoch
=
result
.
columnAsInt
(
"epoch"
);
row
=
mysql_fetch_row
(
result
);
masterEpoch
=
atoi
(
row
[
0
]);
mysql_free_result
(
result
);
/*
/*
Now we will pull current epoch from slave. If not the
Now we will pull current epoch from slave. If not the
same as master, we will continue to retrieve the epoch
same as master, we will continue to retrieve the epoch
...
@@ -103,15 +99,12 @@ syncSlaveWithMaster()
...
@@ -103,15 +99,12 @@ syncSlaveWithMaster()
while
(
slaveEpoch
!=
masterEpoch
&&
loopCnt
<
maxLoops
)
while
(
slaveEpoch
!=
masterEpoch
&&
loopCnt
<
maxLoops
)
{
{
if
(
slave
.
doQuery
(
"SELECT epoch FROM mysql.ndb_apply_status"
))
if
(
slave
.
doQuery
(
"SELECT epoch FROM mysql.ndb_apply_status"
,
result
))
{
{
return
NDBT_FAILED
;
return
NDBT_FAILED
;
}
}
result
=
mysql_use_result
(
slave
.
getMysql
());
slaveEpoch
=
result
.
columnAsInt
(
"epoch"
);
row
=
mysql_fetch_row
(
result
);
slaveEpoch
=
atoi
(
row
[
0
]);
mysql_free_result
(
result
);
if
(
slaveEpoch
!=
slaveEpochOld
)
if
(
slaveEpoch
!=
slaveEpochOld
)
{
{
slaveEpochOld
=
slaveEpoch
;
slaveEpochOld
=
slaveEpoch
;
...
@@ -135,17 +128,15 @@ syncSlaveWithMaster()
...
@@ -135,17 +128,15 @@ syncSlaveWithMaster()
}
}
int
int
verifySlaveLoad
(
BaseString
*
table
)
verifySlaveLoad
(
BaseString
&
table
)
{
{
BaseString
sqlStm
;
//
BaseString sqlStm;
BaseString
db
;
BaseString
db
;
MYSQL_RES
*
result
;
MYSQL_ROW
row
;
unsigned
int
masterCount
=
0
;
unsigned
int
masterCount
=
0
;
unsigned
int
slaveCount
=
0
;
unsigned
int
slaveCount
=
0
;
db
.
assign
(
"TEST_DB"
);
db
.
assign
(
"TEST_DB"
);
sqlStm
.
assfmt
(
"SELECT COUNT(*) FROM %s"
,
table
);
//
sqlStm.assfmt("SELECT COUNT(*) FROM %s", table);
//First thing to do is sync slave
//First thing to do is sync slave
if
(
syncSlaveWithMaster
())
if
(
syncSlaveWithMaster
())
...
@@ -163,15 +154,11 @@ verifySlaveLoad(BaseString *table)
...
@@ -163,15 +154,11 @@ verifySlaveLoad(BaseString *table)
return
NDBT_FAILED
;
return
NDBT_FAILED
;
}
}
if
(
master
.
doQuery
(
sqlStm
.
c_str
())
)
if
(
(
masterCount
=
master
.
selectCountTable
(
table
.
c_str
()))
==
0
)
{
{
return
NDBT_FAILED
;
return
NDBT_FAILED
;
}
}
result
=
mysql_use_result
(
master
.
getMysql
());
row
=
mysql_fetch_row
(
result
);
masterCount
=
atoi
(
row
[
0
]);
mysql_free_result
(
result
);
//Create a DB Object for slave
//Create a DB Object for slave
DbUtil
slave
(
db
.
c_str
(),
".slave"
);
DbUtil
slave
(
db
.
c_str
(),
".slave"
);
...
@@ -181,15 +168,11 @@ verifySlaveLoad(BaseString *table)
...
@@ -181,15 +168,11 @@ verifySlaveLoad(BaseString *table)
return
NDBT_FAILED
;
return
NDBT_FAILED
;
}
}
if
(
slave
.
doQuery
(
sqlStm
.
c_str
())
)
if
(
(
slaveCount
=
slave
.
selectCountTable
(
table
.
c_str
()))
==
0
)
{
{
return
NDBT_FAILED
;
return
NDBT_FAILED
;
}
}
result
=
mysql_use_result
(
slave
.
getMysql
());
row
=
mysql_fetch_row
(
result
);
slaveCount
=
atoi
(
row
[
0
]);
mysql_free_result
(
result
);
if
(
slaveCount
!=
masterCount
)
if
(
slaveCount
!=
masterCount
)
{
{
g_err
<<
"Verify Load -> Slave Count != Master Count "
g_err
<<
"Verify Load -> Slave Count != Master Count "
...
@@ -245,10 +228,9 @@ dropTEST_DB(NDBT_Context* ctx, NDBT_Step* step)
...
@@ -245,10 +228,9 @@ dropTEST_DB(NDBT_Context* ctx, NDBT_Step* step)
}
}
int
int
verifySlave
(
BaseString
&
sqlStm
,
BaseString
&
db
)
verifySlave
(
BaseString
&
sqlStm
,
BaseString
&
db
,
BaseString
&
column
)
{
{
MYSQL_RES
*
resource
;
SqlResultSet
result
;
MYSQL_ROW
row
;
float
masterSum
;
float
masterSum
;
float
slaveSum
;
float
slaveSum
;
...
@@ -269,30 +251,24 @@ verifySlave(BaseString& sqlStm, BaseString& db)
...
@@ -269,30 +251,24 @@ verifySlave(BaseString& sqlStm, BaseString& db)
return
NDBT_FAILED
;
return
NDBT_FAILED
;
}
}
if
(
master
.
doQuery
(
sqlStm
.
c_str
())
!=
NDBT_OK
)
if
(
master
.
doQuery
(
sqlStm
.
c_str
()
,
result
)
!=
NDBT_OK
)
{
{
return
NDBT_FAILED
;
return
NDBT_FAILED
;
}
}
resource
=
mysql_use_result
(
master
.
getMysql
());
masterSum
=
result
.
columnAsInt
(
column
.
c_str
());
row
=
mysql_fetch_row
(
resource
);
masterSum
=
atoi
(
row
[
0
]);
mysql_free_result
(
resource
);
//Login to slave
//Login to slave
if
(
!
slave
.
connect
())
if
(
!
slave
.
connect
())
{
{
return
NDBT_FAILED
;
return
NDBT_FAILED
;
}
}
if
(
slave
.
doQuery
(
sqlStm
.
c_str
())
!=
NDBT_OK
)
if
(
slave
.
doQuery
(
sqlStm
.
c_str
()
,
result
)
!=
NDBT_OK
)
{
{
return
NDBT_FAILED
;
return
NDBT_FAILED
;
}
}
resource
=
mysql_use_result
(
slave
.
getMysql
());
slaveSum
=
result
.
columnAsInt
(
column
.
c_str
());
row
=
mysql_fetch_row
(
resource
);
slaveSum
=
atoi
(
row
[
0
]);
mysql_free_result
(
resource
);
if
(
masterSum
!=
slaveSum
)
if
(
masterSum
!=
slaveSum
)
{
{
g_err
<<
"VerifySlave -> masterSum != slaveSum..."
<<
endl
;
g_err
<<
"VerifySlave -> masterSum != slaveSum..."
<<
endl
;
...
@@ -364,7 +340,7 @@ createTable_rep1(NDBT_Context* ctx, NDBT_Step* step)
...
@@ -364,7 +340,7 @@ createTable_rep1(NDBT_Context* ctx, NDBT_Step* step)
return
NDBT_FAILED
;
return
NDBT_FAILED
;
}
}
if
(
verifySlaveLoad
(
&
table
)
!=
NDBT_OK
)
if
(
verifySlaveLoad
(
table
)
!=
NDBT_OK
)
{
{
g_err
<<
"Create Table -> Failed on verify slave load!"
g_err
<<
"Create Table -> Failed on verify slave load!"
<<
endl
;
<<
endl
;
...
@@ -429,11 +405,13 @@ verifySlave_rep1(NDBT_Context* ctx, NDBT_Step* step)
...
@@ -429,11 +405,13 @@ verifySlave_rep1(NDBT_Context* ctx, NDBT_Step* step)
{
{
BaseString
sql
;
BaseString
sql
;
BaseString
db
;
BaseString
db
;
BaseString
column
;
sql
.
assign
(
"SELECT SUM(c3) FROM rep1"
);
sql
.
assign
(
"SELECT SUM(c3) FROM rep1"
);
db
.
assign
(
"TEST_DB"
);
db
.
assign
(
"TEST_DB"
);
column
.
assign
(
"c3"
);
if
(
verifySlave
(
sql
,
db
)
!=
NDBT_OK
)
if
(
verifySlave
(
sql
,
db
,
column
)
!=
NDBT_OK
)
return
NDBT_FAILED
;
return
NDBT_FAILED
;
return
NDBT_OK
;
return
NDBT_OK
;
}
}
...
@@ -452,7 +430,7 @@ verifySlave_rep1(NDBT_Context* ctx, NDBT_Step* step)
...
@@ -452,7 +430,7 @@ verifySlave_rep1(NDBT_Context* ctx, NDBT_Step* step)
dropTEST_DB()
dropTEST_DB()
{Drops TEST_DB database on master}
{Drops TEST_DB database on master}
verifySlave(BaseString& sql, BaseSting& db)
verifySlave(BaseString& sql, BaseSting& db
, BaseSting& column
)
{The SQL statement must sum a column and will verify
{The SQL statement must sum a column and will verify
that the sum of the column is equal on master & slave}
that the sum of the column is equal on master & slave}
*/
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment