use of org.voltdb.messaging.CompleteTransactionResponseMessage in project voltdb by VoltDB.
the class SpScheduler method handleCompleteTransactionMessage.
private void handleCompleteTransactionMessage(CompleteTransactionMessage message) {
CompleteTransactionMessage msg = message;
if (m_isLeader) {
msg = new CompleteTransactionMessage(m_mailbox.getHSId(), m_mailbox.getHSId(), message);
// Set the spHandle so that on repair the new master will set the max seen spHandle
// correctly
advanceTxnEgo();
msg.setSpHandle(getCurrentTxnId());
if (m_sendToHSIds.length > 0 && !msg.isReadOnly()) {
m_mailbox.send(m_sendToHSIds, msg);
}
} else {
setMaxSeenTxnId(msg.getSpHandle());
}
logRepair(msg);
TransactionState txn = m_outstandingTxns.get(msg.getTxnId());
// now, fix that later.
if (txn != null) {
CompleteTransactionMessage finalMsg = msg;
final VoltTrace.TraceEventBatch traceLog = VoltTrace.log(VoltTrace.Category.SPI);
if (traceLog != null) {
traceLog.add(() -> VoltTrace.instant("recvCompleteTxn", "txnId", TxnEgo.txnIdToString(finalMsg.getTxnId()), "partition", Integer.toString(m_partitionId), "hsId", CoreUtils.hsIdToString(m_mailbox.getHSId())));
}
final boolean isSysproc = ((FragmentTaskMessage) txn.getNotice()).isSysProcTask();
if (m_sendToHSIds.length > 0 && !msg.isRestart() && (!msg.isReadOnly() || isSysproc)) {
DuplicateCounter counter;
counter = new DuplicateCounter(msg.getCoordinatorHSId(), msg.getTxnId(), m_replicaHSIds, msg);
safeAddToDuplicateCounterMap(new DuplicateCounterKey(msg.getTxnId(), msg.getSpHandle()), counter);
}
Iv2Trace.logCompleteTransactionMessage(msg, m_mailbox.getHSId());
final CompleteTransactionTask task = new CompleteTransactionTask(m_mailbox, txn, m_pendingTasks, msg);
queueOrOfferMPTask(task);
} else {
// Generate a dummy response message when this site has not seen previous FragmentTaskMessage,
// the leader may have started to wait for replicas' response messages.
// This can happen in the early phase of site rejoin before replica receiving the snapshot initiation,
// it also means this CompleteTransactionMessage message will be dropped because it's after snapshot.
final CompleteTransactionResponseMessage resp = new CompleteTransactionResponseMessage(msg);
resp.m_sourceHSId = m_mailbox.getHSId();
handleCompleteTransactionResponseMessage(resp);
}
}
use of org.voltdb.messaging.CompleteTransactionResponseMessage in project voltdb by VoltDB.
the class CompleteTransactionTask method run.
@Override
public void run(SiteProcedureConnection siteConnection) {
hostLog.debug("STARTING: " + this);
final VoltTrace.TraceEventBatch traceLog = VoltTrace.log(VoltTrace.Category.SPSITE);
if (traceLog != null) {
traceLog.add(() -> VoltTrace.beginDuration("execcompletetxn", "txnId", TxnEgo.txnIdToString(getTxnId()), "partition", Integer.toString(siteConnection.getCorrespondingPartitionId())));
}
if (!m_txnState.isReadOnly()) {
// the truncation point token SHOULD be part of m_txn. However, the
// legacy interaces don't work this way and IV2 hasn't changed this
// ownership yet. But truncateUndoLog is written assuming the right
// eventual encapsulation.
siteConnection.truncateUndoLog(m_completeMsg.isRollback(), m_txnState.getBeginUndoToken(), m_txnState.m_spHandle, m_txnState.getUndoLog());
}
if (!m_completeMsg.isRestart()) {
doCommonSPICompleteActions();
// Log invocation to DR
logToDR(siteConnection.getDRGateway());
hostLog.debug("COMPLETE: " + this);
} else {
// If we're going to restart the transaction, then reset the begin undo token so the
// first FragmentTask will set it correctly. Otherwise, don't set the Done state or
// flush the queue; we want the TransactionTaskQueue to stay blocked on this TXN ID
// for the restarted fragments.
m_txnState.setBeginUndoToken(Site.kInvalidUndoToken);
hostLog.debug("RESTART: " + this);
}
if (traceLog != null) {
traceLog.add(VoltTrace::endDuration);
}
final CompleteTransactionResponseMessage resp = new CompleteTransactionResponseMessage(m_completeMsg);
resp.m_sourceHSId = m_initiator.getHSId();
m_initiator.deliver(resp);
}
use of org.voltdb.messaging.CompleteTransactionResponseMessage in project voltdb by VoltDB.
the class CompleteTransactionTask method runForRejoin.
@Override
public void runForRejoin(SiteProcedureConnection siteConnection, TaskLog taskLog) throws IOException {
if (!m_txnState.isReadOnly() && !m_completeMsg.isRollback()) {
// ENG-5276: Need to set the last committed spHandle so that the rejoining site gets the accurate
// per-partition txnId set for the next snapshot. Normally, this is done through undo log truncation.
// Since the task is not run here, we need to set the last committed spHandle explicitly.
//
// How does this work?
// - Blocking rejoin with idle cluster: The spHandle is updated here with the spHandle of the stream
// snapshot that transfers the rejoin data. So the snapshot right after rejoin should have the spHandle
// passed here.
// - Live rejoin with idle cluster: Same as blocking rejoin.
// - Live rejoin with workload: Transactions will be logged and replayed afterward. The spHandle will be
// updated when they commit and truncate undo logs. So at the end of replay,
// the spHandle should have the latest value. If all replayed transactions rolled back,
// the spHandle is still guaranteed to be the spHandle of the stream snapshot that transfered the
// rejoin data, which is the correct value.
siteConnection.setSpHandleForSnapshotDigest(m_txnState.m_spHandle);
}
if (!m_completeMsg.isRestart()) {
// future: offer to siteConnection.IBS for replay.
doCommonSPICompleteActions();
}
if (!m_txnState.isReadOnly()) {
// We need to log the restarting message to the task log so we'll replay the whole
// stream faithfully
taskLog.logTask(m_completeMsg);
}
final CompleteTransactionResponseMessage resp = new CompleteTransactionResponseMessage(m_completeMsg);
resp.setIsRecovering(true);
resp.m_sourceHSId = m_initiator.getHSId();
m_initiator.deliver(resp);
}
use of org.voltdb.messaging.CompleteTransactionResponseMessage in project voltdb by VoltDB.
the class Iv2Trace method logInitiatorRxMsg.
public static void logInitiatorRxMsg(VoltMessage msg, long localHSId) {
if (IV2_TRACE_ENABLED) {
if (msg instanceof InitiateResponseMessage) {
InitiateResponseMessage iresp = (InitiateResponseMessage) msg;
String logmsg = "rxInitRsp %s from %s ciHandle %s txnId %s spHandle %s status %s";
iv2log.trace(String.format(logmsg, CoreUtils.hsIdToString(localHSId), CoreUtils.hsIdToString(iresp.m_sourceHSId), ClientInterfaceHandleManager.handleToString(iresp.getClientInterfaceHandle()), txnIdToString(iresp.getTxnId()), txnIdToString(iresp.getSpHandle()), respStatusToString(iresp.getClientResponseData().getStatus())));
} else if (msg instanceof FragmentResponseMessage) {
FragmentResponseMessage fresp = (FragmentResponseMessage) msg;
String logmsg = "rxFragRsp %s from %s txnId %s spHandle %s status %s";
iv2log.trace(String.format(logmsg, CoreUtils.hsIdToString(localHSId), CoreUtils.hsIdToString(fresp.m_sourceHSId), txnIdToString(fresp.getTxnId()), txnIdToString(fresp.getSpHandle()), fragStatusToString(fresp.getStatusCode())));
} else if (msg instanceof CompleteTransactionResponseMessage) {
CompleteTransactionResponseMessage cresp = (CompleteTransactionResponseMessage) msg;
String logmsg = "rxCompRsp %s from %s txnId %s spHandle %s SPI %s restart %s recovering %s";
iv2log.trace(String.format(logmsg, CoreUtils.hsIdToString(localHSId), CoreUtils.hsIdToString(cresp.m_sourceHSId), txnIdToString(cresp.getTxnId()), txnIdToString(cresp.getSpHandle()), txnIdToString(cresp.getSPIHSId()), cresp.isRestart(), cresp.isRecovering()));
} else if (msg instanceof DummyTransactionResponseMessage) {
DummyTransactionResponseMessage dresp = (DummyTransactionResponseMessage) msg;
String logmsg = "rxDummyRsp %s from %s to %s for txnId %s";
iv2log.trace(String.format(logmsg, CoreUtils.hsIdToString(localHSId), CoreUtils.hsIdToString(dresp.m_sourceHSId), txnIdToString(dresp.getSPIHSId()), txnIdToString(dresp.getTxnId())));
}
}
}
Aggregations