=== modified file 'storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp' --- storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp 2009-10-15 12:36:53 +0000 +++ storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp 2009-10-22 15:19:44 +0000 @@ -299,8 +299,15 @@ void Dbtc::execCONTINUEB(Signal* signal) ApiConnectRecordPtr transPtr; transPtr.i = Tdata0; ptrCheckGuard(transPtr, capiConnectFilesize, apiConnectRecord); - transPtr.p->triggerPending = false; - executeTriggers(signal, &transPtr); + /* Check that ConnectRecord is for the same Trans Id */ + if (likely((transPtr.p->transid[0] == Tdata1) && + (transPtr.p->transid[1] == Tdata2))) + { + ndbrequire(transPtr.p->triggerPending); + transPtr.p->triggerPending = false; + /* Try executing triggers now */ + executeTriggers(signal, &transPtr); + } return; case TcContinueB::DelayTCKEYCONF: jam(); @@ -14432,17 +14439,32 @@ void Dbtc::executeTriggers(Signal* signa // No more triggers, continue transaction after last executed trigger has // reurned (in execLQHKEYCONF or execLQHKEYREF) } else { - // Wait until transaction is ready to execute a trigger + jam(); - if (!regApiPtr->triggerPending) { + /* Not in correct state to fire triggers yet, need to wait + * (or keep waiting) + */ + + if ((regApiPtr->apiConnectstate == CS_RECEIVING) || + (regApiPtr->apiConnectstate == CS_REC_COMMITTING)) + { + // Wait until transaction is ready to execute a trigger jam(); - regApiPtr->triggerPending = true; - signal->theData[0] = TcContinueB::TRIGGER_PENDING; - signal->theData[1] = transPtr->i; - sendSignal(reference(), GSN_CONTINUEB, signal, 3, JBB); + if (!regApiPtr->triggerPending) { + jam(); + regApiPtr->triggerPending = true; + signal->theData[0] = TcContinueB::TRIGGER_PENDING; + signal->theData[1] = transPtr->i; + signal->theData[2] = regApiPtr->transid[0]; + signal->theData[3] = regApiPtr->transid[1]; + sendSignal(reference(), GSN_CONTINUEB, signal, 4, JBB); + } + // else + // We are already waiting for a pending trigger (CONTINUEB) } - // else - // We are already waiting for a pending trigger (CONTINUEB) + // else + // Transaction is in unexpected state + // ignore no-longer-needed trigger } } }