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
93f0819a
Commit
93f0819a
authored
Sep 09, 2005
by
jonas@eel.(none)
Browse files
Options
Browse Files
Download
Plain Diff
Merge joreland@bk-internal.mysql.com:/home/bk/mysql-5.0
into eel.(none):/home/jonas/src/mysql-5.0-push
parents
6415364e
7b0452a1
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
359 additions
and
85 deletions
+359
-85
.bzrignore
.bzrignore
+1
-0
ndb/src/common/portlib/NdbThread.c
ndb/src/common/portlib/NdbThread.c
+10
-0
ndb/test/include/NDBT_Test.hpp
ndb/test/include/NDBT_Test.hpp
+2
-1
ndb/test/ndbapi/Makefile.am
ndb/test/ndbapi/Makefile.am
+4
-1
ndb/test/ndbapi/bank/Bank.cpp
ndb/test/ndbapi/bank/Bank.cpp
+86
-82
ndb/test/ndbapi/bank/Bank.hpp
ndb/test/ndbapi/bank/Bank.hpp
+1
-1
ndb/test/ndbapi/testSRBank.cpp
ndb/test/ndbapi/testSRBank.cpp
+246
-0
ndb/test/src/NDBT_Test.cpp
ndb/test/src/NDBT_Test.cpp
+9
-0
No files found.
.bzrignore
View file @
93f0819a
...
@@ -859,6 +859,7 @@ ndb/test/ndbapi/testNodeRestart
...
@@ -859,6 +859,7 @@ ndb/test/ndbapi/testNodeRestart
ndb/test/ndbapi/testOIBasic
ndb/test/ndbapi/testOIBasic
ndb/test/ndbapi/testOperations
ndb/test/ndbapi/testOperations
ndb/test/ndbapi/testRestartGci
ndb/test/ndbapi/testRestartGci
ndb/test/ndbapi/testSRBank
ndb/test/ndbapi/testScan
ndb/test/ndbapi/testScan
ndb/test/ndbapi/testScan.dsp
ndb/test/ndbapi/testScan.dsp
ndb/test/ndbapi/testScanInterpreter
ndb/test/ndbapi/testScanInterpreter
...
...
ndb/src/common/portlib/NdbThread.c
View file @
93f0819a
...
@@ -52,6 +52,16 @@ ndb_thread_wrapper(void* _ss){
...
@@ -52,6 +52,16 @@ ndb_thread_wrapper(void* _ss){
pthread_sigmask
(
SIG_BLOCK
,
&
mask
,
0
);
pthread_sigmask
(
SIG_BLOCK
,
&
mask
,
0
);
}
}
#endif
#endif
{
/**
* Block all signals to thread by default
* let them go to main process instead
*/
sigset_t
mask
;
sigfillset
(
&
mask
);
pthread_sigmask
(
SIG_BLOCK
,
&
mask
,
0
);
}
{
{
void
*
ret
;
void
*
ret
;
struct
NdbThread
*
ss
=
(
struct
NdbThread
*
)
_ss
;
struct
NdbThread
*
ss
=
(
struct
NdbThread
*
)
_ss
;
...
...
ndb/test/include/NDBT_Test.hpp
View file @
93f0819a
...
@@ -67,7 +67,8 @@ public:
...
@@ -67,7 +67,8 @@ public:
const
char
*
getPropertyWait
(
const
char
*
,
const
char
*
);
const
char
*
getPropertyWait
(
const
char
*
,
const
char
*
);
void
decProperty
(
const
char
*
);
void
decProperty
(
const
char
*
);
void
incProperty
(
const
char
*
);
// Communicate with other tests
// Communicate with other tests
void
stopTest
();
void
stopTest
();
bool
isTestStopped
();
bool
isTestStopped
();
...
...
ndb/test/ndbapi/Makefile.am
View file @
93f0819a
...
@@ -34,7 +34,8 @@ test_event ndbapi_slow_select testReadPerf testLcp \
...
@@ -34,7 +34,8 @@ test_event ndbapi_slow_select testReadPerf testLcp \
testPartitioning
\
testPartitioning
\
testBitfield
\
testBitfield
\
DbCreate DbAsyncGenerator
\
DbCreate DbAsyncGenerator
\
test_event_multi_table
test_event_multi_table
\
testSRBank
#flexTimedAsynch
#flexTimedAsynch
#testBlobs
#testBlobs
...
@@ -78,6 +79,7 @@ testBitfield_SOURCES = testBitfield.cpp
...
@@ -78,6 +79,7 @@ testBitfield_SOURCES = testBitfield.cpp
DbCreate_SOURCES
=
bench/mainPopulate.cpp bench/dbPopulate.cpp bench/userInterface.cpp bench/dbPopulate.h bench/userInterface.h bench/testData.h bench/testDefinitions.h bench/ndb_schema.hpp bench/ndb_error.hpp
DbCreate_SOURCES
=
bench/mainPopulate.cpp bench/dbPopulate.cpp bench/userInterface.cpp bench/dbPopulate.h bench/userInterface.h bench/testData.h bench/testDefinitions.h bench/ndb_schema.hpp bench/ndb_error.hpp
DbAsyncGenerator_SOURCES
=
bench/mainAsyncGenerator.cpp bench/asyncGenerator.cpp bench/ndb_async2.cpp bench/dbGenerator.h bench/macros.h bench/userInterface.h bench/testData.h bench/testDefinitions.h bench/ndb_schema.hpp bench/ndb_error.hpp
DbAsyncGenerator_SOURCES
=
bench/mainAsyncGenerator.cpp bench/asyncGenerator.cpp bench/ndb_async2.cpp bench/dbGenerator.h bench/macros.h bench/userInterface.h bench/testData.h bench/testDefinitions.h bench/ndb_schema.hpp bench/ndb_error.hpp
test_event_multi_table_SOURCES
=
test_event_multi_table.cpp
test_event_multi_table_SOURCES
=
test_event_multi_table.cpp
testSRBank_SOURCES
=
testSRBank.cpp
INCLUDES_LOC
=
-I
$(top_srcdir)
/ndb/include/kernel
INCLUDES_LOC
=
-I
$(top_srcdir)
/ndb/include/kernel
...
@@ -89,6 +91,7 @@ include $(top_srcdir)/ndb/config/type_ndbapitest.mk.am
...
@@ -89,6 +91,7 @@ include $(top_srcdir)/ndb/config/type_ndbapitest.mk.am
##testSystemRestart_INCLUDES = $(INCLUDES) -I$(top_srcdir)/ndb/include/kernel
##testSystemRestart_INCLUDES = $(INCLUDES) -I$(top_srcdir)/ndb/include/kernel
##testTransactions_INCLUDES = $(INCLUDES) -I$(top_srcdir)/ndb/include/kernel
##testTransactions_INCLUDES = $(INCLUDES) -I$(top_srcdir)/ndb/include/kernel
testBackup_LDADD
=
$(LDADD)
bank/libbank.a
testBackup_LDADD
=
$(LDADD)
bank/libbank.a
testSRBank_LDADD
=
bank/libbank.a
$(LDADD)
# Don't update the files from bitkeeper
# Don't update the files from bitkeeper
%
::
SCCS/s.%
%
::
SCCS/s.%
...
...
ndb/test/ndbapi/bank/Bank.cpp
View file @
93f0819a
...
@@ -19,12 +19,13 @@
...
@@ -19,12 +19,13 @@
#include <NdbSleep.h>
#include <NdbSleep.h>
#include <UtilTransactions.hpp>
#include <UtilTransactions.hpp>
Bank
::
Bank
(
Ndb_cluster_connection
&
con
)
:
Bank
::
Bank
(
Ndb_cluster_connection
&
con
,
bool
_init
)
:
m_ndb
(
&
con
,
"BANK"
),
m_ndb
(
&
con
,
"BANK"
),
m_maxAccount
(
-
1
),
m_maxAccount
(
-
1
),
m_initialized
(
false
)
m_initialized
(
false
)
{
{
if
(
_init
)
init
();
}
}
int
Bank
::
init
(){
int
Bank
::
init
(){
...
@@ -34,40 +35,39 @@ int Bank::init(){
...
@@ -34,40 +35,39 @@ int Bank::init(){
myRandom48Init
(
NdbTick_CurrentMillisecond
());
myRandom48Init
(
NdbTick_CurrentMillisecond
());
m_ndb
.
init
();
m_ndb
.
init
();
while
(
m_ndb
.
waitUntilReady
(
10
)
!=
0
)
if
(
m_ndb
.
waitUntilReady
(
30
)
!=
0
)
ndbout
<<
"Waiting for ndb to be ready"
<<
endl
;
{
ndbout
<<
"Ndb not ready"
<<
endl
;
return
NDBT_FAILED
;
}
if
(
getNumAccounts
()
!=
NDBT_OK
)
if
(
getNumAccounts
()
!=
NDBT_OK
)
return
NDBT_FAILED
;
return
NDBT_FAILED
;
m_initialized
=
true
;
return
NDBT_OK
;
return
NDBT_OK
;
}
}
int
Bank
::
performTransactions
(
int
maxSleepBetweenTrans
,
int
yield
){
int
Bank
::
performTransactions
(
int
maxSleepBetweenTrans
,
int
yield
){
if
(
init
()
!=
NDBT_OK
)
return
NDBT_FAILED
;
int
transactions
=
0
;
int
transactions
=
0
;
while
(
1
){
while
(
performTransaction
()
==
NDBT_OK
)
{
while
(
m_ndb
.
waitUntilReady
(
10
)
!=
0
)
transactions
++
;
ndbout
<<
"Waiting for ndb to be ready"
<<
endl
;
if
(
maxSleepBetweenTrans
>
0
){
while
(
performTransaction
()
!=
NDBT_FAILED
){
int
val
=
myRandom48
(
maxSleepBetweenTrans
);
transactions
++
;
NdbSleep_MilliSleep
(
val
);
if
(
maxSleepBetweenTrans
>
0
){
int
val
=
myRandom48
(
maxSleepBetweenTrans
);
NdbSleep_MilliSleep
(
val
);
}
if
((
transactions
%
100
)
==
0
)
g_info
<<
transactions
<<
endl
;
if
(
yield
!=
0
&&
transactions
>=
yield
)
return
NDBT_OK
;
}
}
if
((
transactions
%
100
)
==
0
)
g_info
<<
transactions
<<
endl
;
if
(
yield
!=
0
&&
transactions
>=
yield
)
return
NDBT_OK
;
}
}
return
NDBT_FAILED
;
return
NDBT_FAILED
;
}
}
...
@@ -92,7 +92,7 @@ int Bank::performTransaction(){
...
@@ -92,7 +92,7 @@ int Bank::performTransaction(){
int
amount
=
myRandom48
(
maxAmount
);
int
amount
=
myRandom48
(
maxAmount
);
retry_transaction:
retry_transaction:
int
res
=
performTransaction
(
fromAccount
,
toAccount
,
amount
);
int
res
=
performTransaction
(
fromAccount
,
toAccount
,
amount
);
if
(
res
!=
0
){
if
(
res
!=
0
){
switch
(
res
){
switch
(
res
){
...
@@ -158,8 +158,9 @@ int Bank::performTransactionImpl1(int fromAccountId,
...
@@ -158,8 +158,9 @@ int Bank::performTransactionImpl1(int fromAccountId,
// Ok, all clear to do the transaction
// Ok, all clear to do the transaction
Uint64
transId
;
Uint64
transId
;
if
(
getNextTransactionId
(
transId
)
!=
NDBT_OK
){
int
result
=
NDBT_OK
;
return
NDBT_FAILED
;
if
((
result
=
getNextTransactionId
(
transId
))
!=
NDBT_OK
){
return
result
;
}
}
NdbConnection
*
pTrans
=
m_ndb
.
startTransaction
();
NdbConnection
*
pTrans
=
m_ndb
.
startTransaction
();
...
@@ -500,8 +501,6 @@ int Bank::performTransactionImpl1(int fromAccountId,
...
@@ -500,8 +501,6 @@ int Bank::performTransactionImpl1(int fromAccountId,
int
Bank
::
performMakeGLs
(
int
yield
){
int
Bank
::
performMakeGLs
(
int
yield
){
int
result
;
int
result
;
if
(
init
()
!=
NDBT_OK
)
return
NDBT_FAILED
;
int
counter
,
maxCounter
;
int
counter
,
maxCounter
;
int
yieldCounter
=
0
;
int
yieldCounter
=
0
;
...
@@ -512,9 +511,6 @@ int Bank::performMakeGLs(int yield){
...
@@ -512,9 +511,6 @@ int Bank::performMakeGLs(int yield){
counter
=
0
;
counter
=
0
;
maxCounter
=
50
+
myRandom48
(
100
);
maxCounter
=
50
+
myRandom48
(
100
);
while
(
m_ndb
.
waitUntilReady
(
10
)
!=
0
)
ndbout
<<
"Waiting for ndb to be ready"
<<
endl
;
/**
/**
* Validate GLs and Transactions for previous days
* Validate GLs and Transactions for previous days
*
*
...
@@ -526,6 +522,7 @@ int Bank::performMakeGLs(int yield){
...
@@ -526,6 +522,7 @@ int Bank::performMakeGLs(int yield){
return
NDBT_FAILED
;
return
NDBT_FAILED
;
}
}
g_info
<<
"performValidateGLs failed"
<<
endl
;
g_info
<<
"performValidateGLs failed"
<<
endl
;
return
NDBT_FAILED
;
continue
;
continue
;
}
}
...
@@ -536,7 +533,7 @@ int Bank::performMakeGLs(int yield){
...
@@ -536,7 +533,7 @@ int Bank::performMakeGLs(int yield){
return
NDBT_FAILED
;
return
NDBT_FAILED
;
}
}
g_info
<<
"performValidatePurged failed"
<<
endl
;
g_info
<<
"performValidatePurged failed"
<<
endl
;
continue
;
return
NDBT_FAILED
;
}
}
while
(
1
){
while
(
1
){
...
@@ -607,14 +604,9 @@ int Bank::performMakeGLs(int yield){
...
@@ -607,14 +604,9 @@ int Bank::performMakeGLs(int yield){
int
Bank
::
performValidateAllGLs
(){
int
Bank
::
performValidateAllGLs
(){
int
result
;
int
result
;
if
(
init
()
!=
NDBT_OK
)
return
NDBT_FAILED
;
while
(
1
){
while
(
1
){
while
(
m_ndb
.
waitUntilReady
(
10
)
!=
0
)
ndbout
<<
"Waiting for ndb to be ready"
<<
endl
;
/**
/**
* Validate GLs and Transactions for previous days
* Validate GLs and Transactions for previous days
* Set age so that ALL GL's are validated
* Set age so that ALL GL's are validated
...
@@ -1930,39 +1922,29 @@ int Bank::findTransactionsToPurge(const Uint64 glTime,
...
@@ -1930,39 +1922,29 @@ int Bank::findTransactionsToPurge(const Uint64 glTime,
}
}
int
Bank
::
performIncreaseTime
(
int
maxSleepBetweenDays
,
int
yield
){
int
Bank
::
performIncreaseTime
(
int
maxSleepBetweenDays
,
int
yield
)
if
(
init
()
!=
NDBT_OK
)
{
return
NDBT_FAILED
;
int
yieldCounter
=
0
;
int
yieldCounter
=
0
;
while
(
1
){
while
(
1
){
while
(
m_ndb
.
waitUntilReady
(
10
)
!=
0
)
Uint64
currTime
;
ndbout
<<
"Waiting for ndb to be ready"
<<
endl
;
if
(
incCurrTime
(
currTime
)
!=
NDBT_OK
)
break
;
while
(
1
){
g_info
<<
"Current time is "
<<
currTime
<<
endl
;
Uint64
currTime
;
if
(
maxSleepBetweenDays
>
0
){
if
(
incCurrTime
(
currTime
)
!=
NDBT_OK
)
int
val
=
myRandom48
(
maxSleepBetweenDays
);
break
;
NdbSleep_SecSleep
(
val
);
}
g_info
<<
"Current time is "
<<
currTime
<<
endl
;
if
(
maxSleepBetweenDays
>
0
){
yieldCounter
++
;
int
val
=
myRandom48
(
maxSleepBetweenDays
);
if
(
yield
!=
0
&&
yieldCounter
>=
yield
)
NdbSleep_SecSleep
(
val
);
return
NDBT_OK
;
}
}
yieldCounter
++
;
return
NDBT_FAILED
;
if
(
yield
!=
0
&&
yieldCounter
>=
yield
)
}
return
NDBT_OK
;
}
}
return
NDBT_FAILED
;
}
int
Bank
::
readSystemValue
(
SystemValueId
sysValId
,
Uint64
&
value
){
int
Bank
::
readSystemValue
(
SystemValueId
sysValId
,
Uint64
&
value
){
...
@@ -1971,22 +1953,30 @@ int Bank::readSystemValue(SystemValueId sysValId, Uint64 & value){
...
@@ -1971,22 +1953,30 @@ int Bank::readSystemValue(SystemValueId sysValId, Uint64 & value){
NdbConnection
*
pTrans
=
m_ndb
.
startTransaction
();
NdbConnection
*
pTrans
=
m_ndb
.
startTransaction
();
if
(
pTrans
==
NULL
){
if
(
pTrans
==
NULL
){
ERR
(
m_ndb
.
getNdbError
());
ERR
(
m_ndb
.
getNdbError
());
if
(
m_ndb
.
getNdbError
().
status
==
NdbError
::
TemporaryError
)
return
NDBT_TEMPORARY
;
return
NDBT_FAILED
;
return
NDBT_FAILED
;
}
}
if
(
prepareReadSystemValueOp
(
pTrans
,
sysValId
,
value
)
!=
NDBT_OK
)
{
int
result
;
if
((
result
=
prepareReadSystemValueOp
(
pTrans
,
sysValId
,
value
))
!=
NDBT_OK
)
{
ERR
(
pTrans
->
getNdbError
());
ERR
(
pTrans
->
getNdbError
());
m_ndb
.
closeTransaction
(
pTrans
);
m_ndb
.
closeTransaction
(
pTrans
);
return
NDBT_FAILED
;
return
result
;
}
}
check
=
pTrans
->
execute
(
Commit
);
check
=
pTrans
->
execute
(
Commit
);
if
(
check
==
-
1
)
{
if
(
check
==
-
1
)
{
ERR
(
pTrans
->
getNdbError
());
ERR
(
pTrans
->
getNdbError
());
if
(
pTrans
->
getNdbError
().
status
==
NdbError
::
TemporaryError
)
{
m_ndb
.
closeTransaction
(
pTrans
);
return
NDBT_TEMPORARY
;
}
m_ndb
.
closeTransaction
(
pTrans
);
m_ndb
.
closeTransaction
(
pTrans
);
return
NDBT_FAILED
;
return
NDBT_FAILED
;
}
}
m_ndb
.
closeTransaction
(
pTrans
);
m_ndb
.
closeTransaction
(
pTrans
);
return
NDBT_OK
;
return
NDBT_OK
;
...
@@ -2092,6 +2082,8 @@ int Bank::increaseSystemValue(SystemValueId sysValId, Uint64 &value){
...
@@ -2092,6 +2082,8 @@ int Bank::increaseSystemValue(SystemValueId sysValId, Uint64 &value){
NdbConnection
*
pTrans
=
m_ndb
.
startTransaction
();
NdbConnection
*
pTrans
=
m_ndb
.
startTransaction
();
if
(
pTrans
==
NULL
){
if
(
pTrans
==
NULL
){
ERR
(
m_ndb
.
getNdbError
());
ERR
(
m_ndb
.
getNdbError
());
if
(
m_ndb
.
getNdbError
().
status
==
NdbError
::
TemporaryError
)
DBUG_RETURN
(
NDBT_TEMPORARY
);
DBUG_RETURN
(
NDBT_FAILED
);
DBUG_RETURN
(
NDBT_FAILED
);
}
}
...
@@ -2127,6 +2119,11 @@ int Bank::increaseSystemValue(SystemValueId sysValId, Uint64 &value){
...
@@ -2127,6 +2119,11 @@ int Bank::increaseSystemValue(SystemValueId sysValId, Uint64 &value){
check
=
pTrans
->
execute
(
NoCommit
);
check
=
pTrans
->
execute
(
NoCommit
);
if
(
check
==
-
1
)
{
if
(
check
==
-
1
)
{
ERR
(
pTrans
->
getNdbError
());
ERR
(
pTrans
->
getNdbError
());
if
(
pTrans
->
getNdbError
().
status
==
NdbError
::
TemporaryError
)
{
m_ndb
.
closeTransaction
(
pTrans
);
DBUG_RETURN
(
NDBT_TEMPORARY
);
}
m_ndb
.
closeTransaction
(
pTrans
);
m_ndb
.
closeTransaction
(
pTrans
);
DBUG_RETURN
(
NDBT_FAILED
);
DBUG_RETURN
(
NDBT_FAILED
);
}
}
...
@@ -2201,16 +2198,21 @@ int Bank::increaseSystemValue(SystemValueId sysValId, Uint64 &value){
...
@@ -2201,16 +2198,21 @@ int Bank::increaseSystemValue(SystemValueId sysValId, Uint64 &value){
check
=
pTrans
->
execute
(
Commit
);
check
=
pTrans
->
execute
(
Commit
);
if
(
check
==
-
1
)
{
if
(
check
==
-
1
)
{
ERR
(
pTrans
->
getNdbError
());
ERR
(
pTrans
->
getNdbError
());
if
(
pTrans
->
getNdbError
().
status
==
NdbError
::
TemporaryError
)
{
m_ndb
.
closeTransaction
(
pTrans
);
DBUG_RETURN
(
NDBT_TEMPORARY
);
}
m_ndb
.
closeTransaction
(
pTrans
);
m_ndb
.
closeTransaction
(
pTrans
);
DBUG_RETURN
(
NDBT_FAILED
);
DBUG_RETURN
(
NDBT_FAILED
);
}
}
// Check that value updated equals the value we read after the update
// Check that value updated equals the value we read after the update
if
(
valueNewRec
->
u_64_value
()
!=
value
){
if
(
valueNewRec
->
u_64_value
()
!=
value
){
printf
(
"value actual=%lld
\n
"
,
valueNewRec
->
u_64_value
());
printf
(
"value actual=%lld
\n
"
,
valueNewRec
->
u_64_value
());
printf
(
"value expected=%lld actual=%lld
\n
"
,
value
,
valueNewRec
->
u_64_value
());
printf
(
"value expected=%lld actual=%lld
\n
"
,
value
,
valueNewRec
->
u_64_value
());
DBUG_PRINT
(
"info"
,
(
"value expected=%ld actual=%ld"
,
value
,
valueNewRec
->
u_64_value
()));
DBUG_PRINT
(
"info"
,
(
"value expected=%ld actual=%ld"
,
value
,
valueNewRec
->
u_64_value
()));
g_err
<<
"getNextTransactionId: value was not updated"
<<
endl
;
g_err
<<
"getNextTransactionId: value was not updated"
<<
endl
;
m_ndb
.
closeTransaction
(
pTrans
);
m_ndb
.
closeTransaction
(
pTrans
);
...
@@ -2218,7 +2220,7 @@ int Bank::increaseSystemValue(SystemValueId sysValId, Uint64 &value){
...
@@ -2218,7 +2220,7 @@ int Bank::increaseSystemValue(SystemValueId sysValId, Uint64 &value){
}
}
m_ndb
.
closeTransaction
(
pTrans
);
m_ndb
.
closeTransaction
(
pTrans
);
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
...
@@ -2235,6 +2237,8 @@ int Bank::increaseSystemValue2(SystemValueId sysValId, Uint64 &value){
...
@@ -2235,6 +2237,8 @@ int Bank::increaseSystemValue2(SystemValueId sysValId, Uint64 &value){
NdbConnection
*
pTrans
=
m_ndb
.
startTransaction
();
NdbConnection
*
pTrans
=
m_ndb
.
startTransaction
();
if
(
pTrans
==
NULL
){
if
(
pTrans
==
NULL
){
ERR
(
m_ndb
.
getNdbError
());
ERR
(
m_ndb
.
getNdbError
());
if
(
m_ndb
.
getNdbError
().
status
==
NdbError
::
TemporaryError
)
return
NDBT_TEMPORARY
;
return
NDBT_FAILED
;
return
NDBT_FAILED
;
}
}
...
@@ -2277,6 +2281,11 @@ int Bank::increaseSystemValue2(SystemValueId sysValId, Uint64 &value){
...
@@ -2277,6 +2281,11 @@ int Bank::increaseSystemValue2(SystemValueId sysValId, Uint64 &value){
check
=
pTrans
->
execute
(
Commit
);
check
=
pTrans
->
execute
(
Commit
);
if
(
check
==
-
1
)
{
if
(
check
==
-
1
)
{
ERR
(
pTrans
->
getNdbError
());
ERR
(
pTrans
->
getNdbError
());
if
(
pTrans
->
getNdbError
().
status
==
NdbError
::
TemporaryError
)
{
m_ndb
.
closeTransaction
(
pTrans
);
return
NDBT_TEMPORARY
;
}
m_ndb
.
closeTransaction
(
pTrans
);
m_ndb
.
closeTransaction
(
pTrans
);
return
NDBT_FAILED
;
return
NDBT_FAILED
;
}
}
...
@@ -2301,16 +2310,11 @@ int Bank::prepareGetCurrTimeOp(NdbConnection *pTrans, Uint64 &time){
...
@@ -2301,16 +2310,11 @@ int Bank::prepareGetCurrTimeOp(NdbConnection *pTrans, Uint64 &time){
int
Bank
::
performSumAccounts
(
int
maxSleepBetweenSums
,
int
yield
){
int
Bank
::
performSumAccounts
(
int
maxSleepBetweenSums
,
int
yield
){
if
(
init
()
!=
NDBT_OK
)
return
NDBT_FAILED
;
int
yieldCounter
=
0
;
int
yieldCounter
=
0
;
while
(
1
){
while
(
1
){
while
(
m_ndb
.
waitUntilReady
(
10
)
!=
0
)
ndbout
<<
"Waiting for ndb to be ready"
<<
endl
;
Uint32
sumAccounts
=
0
;
Uint32
sumAccounts
=
0
;
Uint32
numAccounts
=
0
;
Uint32
numAccounts
=
0
;
if
(
getSumAccounts
(
sumAccounts
,
numAccounts
)
!=
NDBT_OK
){
if
(
getSumAccounts
(
sumAccounts
,
numAccounts
)
!=
NDBT_OK
){
...
...
ndb/test/ndbapi/bank/Bank.hpp
View file @
93f0819a
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
class
Bank
{
class
Bank
{
public:
public:
Bank
(
Ndb_cluster_connection
&
);
Bank
(
Ndb_cluster_connection
&
,
bool
init
=
true
);
int
createAndLoadBank
(
bool
overWrite
,
int
num_accounts
=
10
);
int
createAndLoadBank
(
bool
overWrite
,
int
num_accounts
=
10
);
int
dropBank
();
int
dropBank
();
...
...
ndb/test/ndbapi/testSRBank.cpp
0 → 100644
View file @
93f0819a
/* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <NDBT.hpp>
#include <NDBT_Test.hpp>
#include <HugoTransactions.hpp>
#include <UtilTransactions.hpp>
#include <NdbBackup.hpp>
#include "bank/Bank.hpp"
int
runCreateBank
(
NDBT_Context
*
ctx
,
NDBT_Step
*
step
){
Bank
bank
(
ctx
->
m_cluster_connection
);
int
overWriteExisting
=
true
;
if
(
bank
.
createAndLoadBank
(
overWriteExisting
,
10
)
!=
NDBT_OK
)
return
NDBT_FAILED
;
return
NDBT_OK
;
}
/**
*
* SR 0 - normal
* SR 1 - shutdown in progress
* SR 2 - restart in progress
*/
int
runBankTimer
(
NDBT_Context
*
ctx
,
NDBT_Step
*
step
){
int
wait
=
5
;
// Max seconds between each "day"
int
yield
=
1
;
// Loops before bank returns
ctx
->
incProperty
(
"ThreadCount"
);
while
(
!
ctx
->
isTestStopped
())
{
Bank
bank
(
ctx
->
m_cluster_connection
);
while
(
!
ctx
->
isTestStopped
()
&&
ctx
->
getProperty
(
"SR"
)
<=
1
)
if
(
bank
.
performIncreaseTime
(
wait
,
yield
)
==
NDBT_FAILED
)
break
;
ndbout_c
(
"runBankTimer is stopped"
);
ctx
->
incProperty
(
"ThreadStopped"
);
if
(
ctx
->
getPropertyWait
(
"SR"
,
(
Uint32
)
0
))
break
;
}
return
NDBT_OK
;
}
int
runBankTransactions
(
NDBT_Context
*
ctx
,
NDBT_Step
*
step
){
int
wait
=
0
;
// Max ms between each transaction
int
yield
=
1
;
// Loops before bank returns
ctx
->
incProperty
(
"ThreadCount"
);
while
(
!
ctx
->
isTestStopped
())
{
Bank
bank
(
ctx
->
m_cluster_connection
);
while
(
!
ctx
->
isTestStopped
()
&&
ctx
->
getProperty
(
"SR"
)
<=
1
)
if
(
bank
.
performTransactions
(
0
,
1
)
==
NDBT_FAILED
)
break
;
ndbout_c
(
"runBankTransactions is stopped"
);
ctx
->
incProperty
(
"ThreadStopped"
);
if
(
ctx
->
getPropertyWait
(
"SR"
,
(
Uint32
)
0
))
break
;
}
return
NDBT_OK
;
}
int
runBankGL
(
NDBT_Context
*
ctx
,
NDBT_Step
*
step
){
int
yield
=
1
;
// Loops before bank returns
int
result
=
NDBT_OK
;
ctx
->
incProperty
(
"ThreadCount"
);
while
(
ctx
->
isTestStopped
()
==
false
)
{
Bank
bank
(
ctx
->
m_cluster_connection
);
while
(
!
ctx
->
isTestStopped
()
&&
ctx
->
getProperty
(
"SR"
)
<=
1
)
if
(
bank
.
performMakeGLs
(
yield
)
!=
NDBT_OK
)
{
if
(
ctx
->
getProperty
(
"SR"
)
!=
0
)
break
;
ndbout
<<
"bank.performMakeGLs FAILED"
<<
endl
;
return
NDBT_FAILED
;
}
ndbout_c
(
"runBankGL is stopped"
);
ctx
->
incProperty
(
"ThreadStopped"
);
if
(
ctx
->
getPropertyWait
(
"SR"
,
(
Uint32
)
0
))
break
;
}
return
NDBT_OK
;
}
int
runBankSum
(
NDBT_Context
*
ctx
,
NDBT_Step
*
step
){
Bank
bank
(
ctx
->
m_cluster_connection
);
int
wait
=
2000
;
// Max ms between each sum of accounts
int
yield
=
1
;
// Loops before bank returns
int
result
=
NDBT_OK
;
while
(
ctx
->
isTestStopped
()
==
false
)
{
if
(
bank
.
performSumAccounts
(
wait
,
yield
)
!=
NDBT_OK
){
ndbout
<<
"bank.performSumAccounts FAILED"
<<
endl
;
result
=
NDBT_FAILED
;
}
}
return
result
;
}
#define CHECK(b) if (!(b)) { \
g_err << "ERR: "<< step->getName() \
<< " failed on line " << __LINE__ << endl; \
result = NDBT_FAILED; \
continue; }
int
runSR
(
NDBT_Context
*
ctx
,
NDBT_Step
*
step
)
{
int
result
=
NDBT_OK
;
int
runtime
=
ctx
->
getNumLoops
();
int
sleeptime
=
ctx
->
getNumRecords
();
NdbRestarter
restarter
;
bool
abort
=
true
;
int
timeout
=
180
;
Uint32
now
;
const
Uint32
stop
=
time
(
0
)
+
runtime
;
while
(
!
ctx
->
isTestStopped
()
&&
((
now
=
time
(
0
))
<
stop
)
&&
result
==
NDBT_OK
)
{
ndbout
<<
" -- Sleep "
<<
sleeptime
<<
"s "
<<
endl
;
NdbSleep_SecSleep
(
sleeptime
);
ndbout
<<
" -- Shutting down "
<<
endl
;
ctx
->
setProperty
(
"SR"
,
1
);
CHECK
(
restarter
.
restartAll
(
false
,
true
,
abort
)
==
0
);
ctx
->
setProperty
(
"SR"
,
2
);
CHECK
(
restarter
.
waitClusterNoStart
(
timeout
)
==
0
);
Uint32
cnt
=
ctx
->
getProperty
(
"ThreadCount"
);
Uint32
curr
=
ctx
->
getProperty
(
"ThreadStopped"
);
while
(
curr
!=
cnt
)
{
ndbout_c
(
"%d %d"
,
curr
,
cnt
);
NdbSleep_MilliSleep
(
100
);
curr
=
ctx
->
getProperty
(
"ThreadStopped"
);
}
ctx
->
setProperty
(
"ThreadStopped"
,
(
Uint32
)
0
);
CHECK
(
restarter
.
startAll
()
==
0
);
CHECK
(
restarter
.
waitClusterStarted
(
timeout
)
==
0
);
ndbout
<<
" -- Validating starts "
<<
endl
;
{
int
wait
=
0
;
int
yield
=
1
;
Bank
bank
(
ctx
->
m_cluster_connection
);
if
(
bank
.
performSumAccounts
(
wait
,
yield
)
!=
0
)
{
ndbout
<<
"bank.performSumAccounts FAILED"
<<
endl
;
return
NDBT_FAILED
;
}
if
(
bank
.
performValidateAllGLs
()
!=
0
)
{
ndbout
<<
"bank.performValidateAllGLs FAILED"
<<
endl
;
return
NDBT_FAILED
;
}
}
ndbout
<<
" -- Validating complete "
<<
endl
;
ctx
->
setProperty
(
"SR"
,
(
Uint32
)
0
);
ctx
->
broadcast
();
}
ctx
->
stopTest
();
return
NDBT_OK
;
}
int
runDropBank
(
NDBT_Context
*
ctx
,
NDBT_Step
*
step
){
Bank
bank
(
ctx
->
m_cluster_connection
);
if
(
bank
.
dropBank
()
!=
NDBT_OK
)
return
NDBT_FAILED
;
return
NDBT_OK
;
}
NDBT_TESTSUITE
(
testSRBank
);
TESTCASE
(
"Graceful"
,
" Test that a consistent bank is restored after graceful shutdown
\n
"
"1. Create bank
\n
"
"2. Start bank and let it run
\n
"
"3. Restart ndb and verify consistency
\n
"
"4. Drop bank
\n
"
)
{
INITIALIZER
(
runCreateBank
);
STEP
(
runBankTimer
);
STEP
(
runBankTransactions
);
STEP
(
runBankTransactions
);
STEP
(
runBankTransactions
);
STEP
(
runBankTransactions
);
STEP
(
runBankTransactions
);
STEP
(
runBankTransactions
);
STEP
(
runBankTransactions
);
STEP
(
runBankTransactions
);
STEP
(
runBankTransactions
);
STEP
(
runBankTransactions
);
STEP
(
runBankGL
);
STEP
(
runSR
);
}
TESTCASE
(
"Abort"
,
" Test that a consistent bank is restored after graceful shutdown
\n
"
"1. Create bank
\n
"
"2. Start bank and let it run
\n
"
"3. Restart ndb and verify consistency
\n
"
"4. Drop bank
\n
"
)
{
INITIALIZER
(
runCreateBank
);
STEP
(
runBankTimer
);
STEP
(
runBankTransactions
);
STEP
(
runBankTransactions
);
STEP
(
runBankTransactions
);
STEP
(
runBankTransactions
);
STEP
(
runBankTransactions
);
STEP
(
runBankTransactions
);
STEP
(
runBankTransactions
);
STEP
(
runBankTransactions
);
STEP
(
runBankTransactions
);
STEP
(
runBankTransactions
);
STEP
(
runBankGL
);
STEP
(
runSR
);
FINALIZER
(
runDropBank
);
}
NDBT_TESTSUITE_END
(
testSRBank
);
int
main
(
int
argc
,
const
char
**
argv
){
ndb_init
();
return
testSRBank
.
execute
(
argc
,
argv
);
}
ndb/test/src/NDBT_Test.cpp
View file @
93f0819a
...
@@ -148,6 +148,15 @@ NDBT_Context::decProperty(const char * name){
...
@@ -148,6 +148,15 @@ NDBT_Context::decProperty(const char * name){
NdbCondition_Broadcast
(
propertyCondPtr
);
NdbCondition_Broadcast
(
propertyCondPtr
);
NdbMutex_Unlock
(
propertyMutexPtr
);
NdbMutex_Unlock
(
propertyMutexPtr
);
}
}
void
NDBT_Context
::
incProperty
(
const
char
*
name
){
NdbMutex_Lock
(
propertyMutexPtr
);
Uint32
val
=
0
;
props
.
get
(
name
,
&
val
);
props
.
put
(
name
,
(
val
+
1
),
true
);
NdbCondition_Broadcast
(
propertyCondPtr
);
NdbMutex_Unlock
(
propertyMutexPtr
);
}
void
NDBT_Context
::
setProperty
(
const
char
*
_name
,
const
char
*
_val
){
void
NDBT_Context
::
setProperty
(
const
char
*
_name
,
const
char
*
_val
){
NdbMutex_Lock
(
propertyMutexPtr
);
NdbMutex_Lock
(
propertyMutexPtr
);
...
...
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