ndb - bug#18780

  Fix various abort cases (mainly MM but also 1 DD)
    that has been found running dbt2
parent 34f4301c
...@@ -118,7 +118,8 @@ void Dbtup::execTUP_ABORTREQ(Signal* signal) ...@@ -118,7 +118,8 @@ void Dbtup::execTUP_ABORTREQ(Signal* signal)
PagePtr page; PagePtr page;
Tuple_header *tuple_ptr= (Tuple_header*) Tuple_header *tuple_ptr= (Tuple_header*)
get_ptr(&page, &regOperPtr.p->m_tuple_location, regTabPtr.p); get_ptr(&page, &regOperPtr.p->m_tuple_location, regTabPtr.p);
Uint32 bits= tuple_ptr->m_header_bits;
if(regOperPtr.p->op_struct.op_type != ZDELETE) if(regOperPtr.p->op_struct.op_type != ZDELETE)
{ {
Tuple_header *copy= (Tuple_header*) Tuple_header *copy= (Tuple_header*)
...@@ -132,7 +133,7 @@ void Dbtup::execTUP_ABORTREQ(Signal* signal) ...@@ -132,7 +133,7 @@ void Dbtup::execTUP_ABORTREQ(Signal* signal)
disk_page_abort_prealloc(signal, regFragPtr.p, &key, key.m_page_idx); disk_page_abort_prealloc(signal, regFragPtr.p, &key, key.m_page_idx);
} }
Uint32 bits= tuple_ptr->m_header_bits;
Uint32 copy_bits= copy->m_header_bits; Uint32 copy_bits= copy->m_header_bits;
if(! (bits & Tuple_header::ALLOC)) if(! (bits & Tuple_header::ALLOC))
{ {
...@@ -174,6 +175,15 @@ void Dbtup::execTUP_ABORTREQ(Signal* signal) ...@@ -174,6 +175,15 @@ void Dbtup::execTUP_ABORTREQ(Signal* signal)
tuple_ptr->m_header_bits |= Tuple_header::FREED; tuple_ptr->m_header_bits |= Tuple_header::FREED;
} }
} }
else if (regOperPtr.p->is_first_operation() &&
regOperPtr.p->is_last_operation())
{
if (bits & Tuple_header::ALLOC)
{
tuple_ptr->m_header_bits &= ~(Uint32)Tuple_header::ALLOC;
tuple_ptr->m_header_bits |= Tuple_header::FREED;
}
}
if(regOperPtr.p->is_first_operation() && regOperPtr.p->is_last_operation()) if(regOperPtr.p->is_first_operation() && regOperPtr.p->is_last_operation())
{ {
......
...@@ -1053,7 +1053,6 @@ Dbtup::disk_page_abort_prealloc_callback(Signal* signal, ...@@ -1053,7 +1053,6 @@ Dbtup::disk_page_abort_prealloc_callback(Signal* signal,
Ptr<Fragrecord> fragPtr; Ptr<Fragrecord> fragPtr;
getFragmentrec(fragPtr, pagePtr.p->m_fragment_id, tabPtr.p); getFragmentrec(fragPtr, pagePtr.p->m_fragment_id, tabPtr.p);
disk_page_set_dirty(pagePtr);
disk_page_abort_prealloc_callback_1(signal, fragPtr.p, pagePtr, sz); disk_page_abort_prealloc_callback_1(signal, fragPtr.p, pagePtr, sz);
} }
...@@ -1063,6 +1062,9 @@ Dbtup::disk_page_abort_prealloc_callback_1(Signal* signal, ...@@ -1063,6 +1062,9 @@ Dbtup::disk_page_abort_prealloc_callback_1(Signal* signal,
PagePtr pagePtr, PagePtr pagePtr,
Uint32 sz) Uint32 sz)
{ {
jam();
disk_page_set_dirty(pagePtr);
Disk_alloc_info& alloc= fragPtrP->m_disk_alloc_info; Disk_alloc_info& alloc= fragPtrP->m_disk_alloc_info;
Uint32 page_idx = pagePtr.p->list_index; Uint32 page_idx = pagePtr.p->list_index;
Uint32 used = pagePtr.p->uncommitted_used_space; Uint32 used = pagePtr.p->uncommitted_used_space;
...@@ -1075,13 +1077,6 @@ Dbtup::disk_page_abort_prealloc_callback_1(Signal* signal, ...@@ -1075,13 +1077,6 @@ Dbtup::disk_page_abort_prealloc_callback_1(Signal* signal,
ddassert(alloc.calc_page_free_bits(free - used) == old_idx); ddassert(alloc.calc_page_free_bits(free - used) == old_idx);
Uint32 new_idx = alloc.calc_page_free_bits(free - used + sz); Uint32 new_idx = alloc.calc_page_free_bits(free - used + sz);
#ifdef VM_TRACE
Local_key key;
key.m_page_no = pagePtr.p->m_page_no;
key.m_file_no = pagePtr.p->m_file_no;
ndbout << "disk_page_abort_prealloc_callback_1" << key << endl;
#endif
Ptr<Extent_info> extentPtr; Ptr<Extent_info> extentPtr;
c_extent_pool.getPtr(extentPtr, ext); c_extent_pool.getPtr(extentPtr, ext);
if (old_idx != new_idx) if (old_idx != new_idx)
......
...@@ -1408,8 +1408,6 @@ int Dbtup::handleInsertReq(Signal* signal, ...@@ -1408,8 +1408,6 @@ int Dbtup::handleInsertReq(Signal* signal,
} }
req_struct->m_use_rowid = false; req_struct->m_use_rowid = false;
base->m_header_bits &= ~(Uint32)Tuple_header::FREE; base->m_header_bits &= ~(Uint32)Tuple_header::FREE;
base->m_header_bits |= Tuple_header::ALLOC &
(regOperPtr.p->is_first_operation() ? ~0 : 1);
} }
else else
{ {
...@@ -1418,8 +1416,6 @@ int Dbtup::handleInsertReq(Signal* signal, ...@@ -1418,8 +1416,6 @@ int Dbtup::handleInsertReq(Signal* signal,
{ {
ndbout_c("no mem insert but rowid (same)"); ndbout_c("no mem insert but rowid (same)");
base->m_header_bits &= ~(Uint32)Tuple_header::FREE; base->m_header_bits &= ~(Uint32)Tuple_header::FREE;
base->m_header_bits |= Tuple_header::ALLOC &
(regOperPtr.p->is_first_operation() ? ~0 : 1);
} }
else else
{ {
...@@ -1427,6 +1423,9 @@ int Dbtup::handleInsertReq(Signal* signal, ...@@ -1427,6 +1423,9 @@ int Dbtup::handleInsertReq(Signal* signal,
ndbrequire(false); ndbrequire(false);
} }
} }
base->m_header_bits |= Tuple_header::ALLOC &
(regOperPtr.p->is_first_operation() ? ~0 : 1);
if (disk_insert) if (disk_insert)
{ {
...@@ -2888,7 +2887,7 @@ Dbtup::handle_size_change_after_update(KeyReqStruct* req_struct, ...@@ -2888,7 +2887,7 @@ Dbtup::handle_size_change_after_update(KeyReqStruct* req_struct,
if(needed <= alloc) if(needed <= alloc)
{ {
ndbassert(!regOperPtr->is_first_operation()); //ndbassert(!regOperPtr->is_first_operation());
ndbout_c(" no grow"); ndbout_c(" no grow");
return 0; return 0;
} }
......
...@@ -1041,6 +1041,38 @@ runMassiveRollback3(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -1041,6 +1041,38 @@ runMassiveRollback3(NDBT_Context* ctx, NDBT_Step* step){
HugoOperations hugoOps(*ctx->getTab()); HugoOperations hugoOps(*ctx->getTab());
Ndb* pNdb = GETNDB(step); Ndb* pNdb = GETNDB(step);
const Uint32 BATCH = 10;
const Uint32 OPS_TOTAL = 50;
const Uint32 LOOPS = 100;
for(Uint32 loop = 0; loop<LOOPS; loop++)
{
CHECK(hugoOps.startTransaction(pNdb) == 0);
bool ok = true;
for (Uint32 i = 0; i<OPS_TOTAL; i+= BATCH)
{
CHECK(hugoOps.pkInsertRecord(pNdb, i, BATCH, 0) == 0);
if (hugoOps.execute_NoCommit(pNdb) != 0)
{
ok = false;
break;
}
}
hugoOps.execute_Rollback(pNdb);
CHECK(hugoOps.closeTransaction(pNdb) == 0);
}
hugoOps.closeTransaction(pNdb);
return result;
}
int
runMassiveRollback4(NDBT_Context* ctx, NDBT_Step* step){
int result = NDBT_OK;
HugoOperations hugoOps(*ctx->getTab());
Ndb* pNdb = GETNDB(step);
const Uint32 BATCH = 10; const Uint32 BATCH = 10;
const Uint32 OPS_TOTAL = 20; const Uint32 OPS_TOTAL = 20;
const Uint32 LOOPS = 100; const Uint32 LOOPS = 100;
...@@ -1052,6 +1084,12 @@ runMassiveRollback3(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -1052,6 +1084,12 @@ runMassiveRollback3(NDBT_Context* ctx, NDBT_Step* step){
for (Uint32 i = 0; i<OPS_TOTAL; i+= BATCH) for (Uint32 i = 0; i<OPS_TOTAL; i+= BATCH)
{ {
CHECK(hugoOps.pkInsertRecord(pNdb, i, BATCH, 0) == 0); CHECK(hugoOps.pkInsertRecord(pNdb, i, BATCH, 0) == 0);
CHECK(hugoOps.pkDeleteRecord(pNdb, i, BATCH) == 0);
if (hugoOps.execute_NoCommit(pNdb) != 0)
{
ok = false;
break;
}
if (hugoOps.execute_NoCommit(pNdb) != 0) if (hugoOps.execute_NoCommit(pNdb) != 0)
{ {
ok = false; ok = false;
...@@ -1399,6 +1437,13 @@ TESTCASE("MassiveRollback3", ...@@ -1399,6 +1437,13 @@ TESTCASE("MassiveRollback3",
STEP(runMassiveRollback3); STEP(runMassiveRollback3);
FINALIZER(runClearTable2); FINALIZER(runClearTable2);
} }
TESTCASE("MassiveRollback4",
"Test rollback of 4096 operations"){
INITIALIZER(runClearTable2);
STEP(runMassiveRollback4);
STEP(runMassiveRollback4);
FINALIZER(runClearTable2);
}
TESTCASE("MassiveTransaction", TESTCASE("MassiveTransaction",
"Test very large insert transaction"){ "Test very large insert transaction"){
INITIALIZER(runLoadTable2); INITIALIZER(runLoadTable2);
......
...@@ -201,15 +201,19 @@ args: -n PkDeleteAsynch ...@@ -201,15 +201,19 @@ args: -n PkDeleteAsynch
max-time: 500 max-time: 500
cmd: testBasic cmd: testBasic
args: -n MassiveRollback T1 T6 T13 D1 D2 args: -n MassiveRollback T1 T7 D1 D2
max-time: 500 max-time: 500
cmd: testBasic cmd: testBasic
args: -n MassiveRollback2 T1 T6 T13 D1 D2 args: -n MassiveRollback2 T1 T7 D1 D2
max-time: 500 max-time: 500
cmd: testBasic cmd: testBasic
args: -n MassiveRollback3 T1 D1 args: -n MassiveRollback3 T1 T7 D1 D2
max-time: 500
cmd: testBasic
args: -n MassiveRollback4 T1 T7 D1 D2
max-time: 500 max-time: 500
cmd: testBasic cmd: testBasic
......
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