mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Added new testcase for Bug #4479
testBasic -n MassiveTransaction Inserts as many records as defined in one transaction using loadTable
This commit is contained in:
@ -34,7 +34,8 @@ public:
|
|||||||
int records,
|
int records,
|
||||||
int batch = 512,
|
int batch = 512,
|
||||||
bool allowConstraintViolation = true,
|
bool allowConstraintViolation = true,
|
||||||
int doSleep = 0);
|
int doSleep = 0,
|
||||||
|
bool oneTrans = false);
|
||||||
int scanReadRecords(Ndb*,
|
int scanReadRecords(Ndb*,
|
||||||
int records,
|
int records,
|
||||||
int abort = 0,
|
int abort = 0,
|
||||||
|
@ -29,9 +29,18 @@
|
|||||||
* delete should be visible to same transaction
|
* delete should be visible to same transaction
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
int runLoadTable2(NDBT_Context* ctx, NDBT_Step* step)
|
||||||
|
{
|
||||||
|
int records = ctx->getNumRecords();
|
||||||
|
HugoTransactions hugoTrans(*ctx->getTab());
|
||||||
|
if (hugoTrans.loadTable(GETNDB(step), records, 512, false, 0, true) != 0){
|
||||||
|
return NDBT_FAILED;
|
||||||
|
}
|
||||||
|
return NDBT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
int runLoadTable(NDBT_Context* ctx, NDBT_Step* step){
|
int runLoadTable(NDBT_Context* ctx, NDBT_Step* step)
|
||||||
|
{
|
||||||
int records = ctx->getNumRecords();
|
int records = ctx->getNumRecords();
|
||||||
HugoTransactions hugoTrans(*ctx->getTab());
|
HugoTransactions hugoTrans(*ctx->getTab());
|
||||||
if (hugoTrans.loadTable(GETNDB(step), records) != 0){
|
if (hugoTrans.loadTable(GETNDB(step), records) != 0){
|
||||||
@ -1255,6 +1264,11 @@ TESTCASE("MassiveRollback2",
|
|||||||
INITIALIZER(runMassiveRollback2);
|
INITIALIZER(runMassiveRollback2);
|
||||||
FINALIZER(runClearTable2);
|
FINALIZER(runClearTable2);
|
||||||
}
|
}
|
||||||
|
TESTCASE("MassiveTransaction",
|
||||||
|
"Test very large insert transaction"){
|
||||||
|
INITIALIZER(runLoadTable2);
|
||||||
|
FINALIZER(runClearTable2);
|
||||||
|
}
|
||||||
NDBT_TESTSUITE_END(testBasic);
|
NDBT_TESTSUITE_END(testBasic);
|
||||||
|
|
||||||
int main(int argc, const char** argv){
|
int main(int argc, const char** argv){
|
||||||
|
@ -819,12 +819,14 @@ HugoTransactions::loadTable(Ndb* pNdb,
|
|||||||
int records,
|
int records,
|
||||||
int batch,
|
int batch,
|
||||||
bool allowConstraintViolation,
|
bool allowConstraintViolation,
|
||||||
int doSleep){
|
int doSleep,
|
||||||
|
bool oneTrans){
|
||||||
int check;
|
int check;
|
||||||
int retryAttempt = 0;
|
int retryAttempt = 0;
|
||||||
int retryMax = 5;
|
int retryMax = 5;
|
||||||
NdbConnection *pTrans;
|
NdbConnection *pTrans;
|
||||||
NdbOperation *pOp;
|
NdbOperation *pOp;
|
||||||
|
bool first_batch = true;
|
||||||
|
|
||||||
const int org = batch;
|
const int org = batch;
|
||||||
const int cols = tab.getNoOfColumns();
|
const int cols = tab.getNoOfColumns();
|
||||||
@ -841,7 +843,7 @@ HugoTransactions::loadTable(Ndb* pNdb,
|
|||||||
|
|
||||||
g_info << "|- Inserting records..." << endl;
|
g_info << "|- Inserting records..." << endl;
|
||||||
for (int c=0 ; c<records ; ){
|
for (int c=0 ; c<records ; ){
|
||||||
|
bool closeTrans;
|
||||||
if (retryAttempt >= retryMax){
|
if (retryAttempt >= retryMax){
|
||||||
g_info << "Record " << c << " could not be inserted, has retried "
|
g_info << "Record " << c << " could not be inserted, has retried "
|
||||||
<< retryAttempt << " times " << endl;
|
<< retryAttempt << " times " << endl;
|
||||||
@ -852,19 +854,22 @@ HugoTransactions::loadTable(Ndb* pNdb,
|
|||||||
if (doSleep > 0)
|
if (doSleep > 0)
|
||||||
NdbSleep_MilliSleep(doSleep);
|
NdbSleep_MilliSleep(doSleep);
|
||||||
|
|
||||||
pTrans = pNdb->startTransaction();
|
if (first_batch || !oneTrans) {
|
||||||
|
first_batch = false;
|
||||||
|
pTrans = pNdb->startTransaction();
|
||||||
|
|
||||||
if (pTrans == NULL) {
|
if (pTrans == NULL) {
|
||||||
const NdbError err = pNdb->getNdbError();
|
const NdbError err = pNdb->getNdbError();
|
||||||
|
|
||||||
if (err.status == NdbError::TemporaryError){
|
if (err.status == NdbError::TemporaryError){
|
||||||
ERR(err);
|
ERR(err);
|
||||||
NdbSleep_MilliSleep(50);
|
NdbSleep_MilliSleep(50);
|
||||||
retryAttempt++;
|
retryAttempt++;
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
ERR(err);
|
||||||
|
return NDBT_FAILED;
|
||||||
}
|
}
|
||||||
ERR(err);
|
|
||||||
return NDBT_FAILED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int b = 0; b < batch && c+b<records; b++){
|
for(int b = 0; b < batch && c+b<records; b++){
|
||||||
@ -894,7 +899,13 @@ HugoTransactions::loadTable(Ndb* pNdb,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Execute the transaction and insert the record
|
// Execute the transaction and insert the record
|
||||||
check = pTrans->execute( Commit );
|
if (!oneTrans || (c + batch) >= records) {
|
||||||
|
closeTrans = true;
|
||||||
|
check = pTrans->execute( Commit );
|
||||||
|
} else {
|
||||||
|
closeTrans = false;
|
||||||
|
check = pTrans->execute( NoCommit );
|
||||||
|
}
|
||||||
if(check == -1 ) {
|
if(check == -1 ) {
|
||||||
const NdbError err = pTrans->getNdbError();
|
const NdbError err = pTrans->getNdbError();
|
||||||
pNdb->closeTransaction(pTrans);
|
pNdb->closeTransaction(pTrans);
|
||||||
@ -938,7 +949,9 @@ HugoTransactions::loadTable(Ndb* pNdb,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
pNdb->closeTransaction(pTrans);
|
if (closeTrans) {
|
||||||
|
pNdb->closeTransaction(pTrans);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step to next record
|
// Step to next record
|
||||||
|
Reference in New Issue
Block a user