use of org.voltdb.utils.VoltTrace in project voltdb by VoltDB.
the class MpProcedureTask method run.
/** Run is invoked by a run-loop to execute this transaction. */
@Override
public void run(SiteProcedureConnection siteConnection) {
// Thread name has to be materialized here
final String threadName = Thread.currentThread().getName();
final VoltTrace.TraceEventBatch traceLog = VoltTrace.log(VoltTrace.Category.MPSITE);
if (traceLog != null) {
traceLog.add(() -> VoltTrace.meta("thread_name", "name", threadName)).add(() -> VoltTrace.meta("thread_sort_index", "sort_index", Integer.toString(1000))).add(() -> VoltTrace.beginDuration("mpinittask", "txnId", TxnEgo.txnIdToString(getTxnId())));
}
hostLog.debug("STARTING: " + this);
// Cast up. Could avoid ugliness with Iv2TransactionClass baseclass
MpTransactionState txn = (MpTransactionState) m_txnState;
// Check for restarting sysprocs
String spName = txn.m_initiationMsg.getStoredProcedureName();
// restarted, the run() method is not rerun. Let the elastic join coordinator reissue it.
if (m_isRestart && spName.startsWith("@") && !spName.startsWith("@AdHoc") && !spName.startsWith("@LoadMultipartitionTable") && !spName.equals("@UpdateCore") && !spName.equals("@ApplyBinaryLogMP")) {
InitiateResponseMessage errorResp = new InitiateResponseMessage(txn.m_initiationMsg);
errorResp.setResults(new ClientResponseImpl(ClientResponse.UNEXPECTED_FAILURE, new VoltTable[] {}, "Failure while running system procedure " + txn.m_initiationMsg.getStoredProcedureName() + ", and system procedures can not be restarted."));
txn.setNeedsRollback(true);
completeInitiateTask(siteConnection);
errorResp.m_sourceHSId = m_initiator.getHSId();
m_initiator.deliver(errorResp);
hostLog.debug("SYSPROCFAIL: " + this);
return;
}
// at the masters we're going to try to use this time around.
if (m_isRestart) {
CompleteTransactionMessage restart = new CompleteTransactionMessage(// who is the "initiator" now??
m_initiator.getHSId(), m_initiator.getHSId(), m_txnState.txnId, m_txnState.isReadOnly(), 0, true, // really don't want to have ack the ack.
false, !m_txnState.isReadOnly(), m_msg.isForReplay());
restart.setTruncationHandle(m_msg.getTruncationHandle());
m_initiator.send(com.google_voltpatches.common.primitives.Longs.toArray(m_initiatorHSIds), restart);
}
final InitiateResponseMessage response = processInitiateTask(txn.m_initiationMsg, siteConnection);
// We currently don't want to restart read-only MP transactions because:
// 1) We're not writing the Iv2InitiateTaskMessage to the first
// FragmentTaskMessage in read-only case in the name of some unmeasured
// performance impact,
// 2) We don't want to perturb command logging and/or DR this close to the 3.0 release
// 3) We don't guarantee the restarted results returned to the client
// anyway, so not restarting the read is currently harmless.
// We could actually restart this here, since we have the invocation, but let's be consistent?
int status = response.getClientResponseData().getStatus();
if (status != ClientResponse.TXN_RESTART || (status == ClientResponse.TXN_RESTART && m_msg.isReadOnly())) {
if (!response.shouldCommit()) {
txn.setNeedsRollback(true);
}
completeInitiateTask(siteConnection);
// Set the source HSId (ugh) to ourselves so we track the message path correctly
response.m_sourceHSId = m_initiator.getHSId();
m_initiator.deliver(response);
execLog.l7dlog(Level.TRACE, LogKeys.org_voltdb_ExecutionSite_SendingCompletedWUToDtxn.name(), null);
hostLog.debug("COMPLETE: " + this);
} else {
restartTransaction();
hostLog.debug("RESTART: " + this);
}
if (traceLog != null) {
traceLog.add(VoltTrace::endDuration);
}
}
use of org.voltdb.utils.VoltTrace in project voltdb by VoltDB.
the class SysprocFragmentTask method processFragmentTask.
// Extracted the sysproc portion of ExecutionSite processFragmentTask(), then
// modified to work in the new world
public FragmentResponseMessage processFragmentTask(SiteProcedureConnection siteConnection) {
final FragmentResponseMessage currentFragResponse = new FragmentResponseMessage(m_fragmentMsg, m_initiator.getHSId());
currentFragResponse.setStatus(FragmentResponseMessage.SUCCESS, null);
for (int frag = 0; frag < m_fragmentMsg.getFragmentCount(); frag++) {
final long fragmentId = VoltSystemProcedure.hashToFragId(m_fragmentMsg.getPlanHash(frag));
// equivalent to dep.depId:
// final int outputDepId = m_fragmentMsg.getOutputDepId(frag);
final VoltTrace.TraceEventBatch traceLog = VoltTrace.log(VoltTrace.Category.SPSITE);
if (traceLog != null) {
traceLog.add(() -> VoltTrace.beginDuration("runfragmenttask", "txnId", TxnEgo.txnIdToString(getTxnId()), "partition", Integer.toString(siteConnection.getCorrespondingPartitionId()), "fragmentId", String.valueOf(fragmentId)));
}
ParameterSet params = m_fragmentMsg.getParameterSetForFragment(frag);
try {
// run the overloaded sysproc planfragment. pass an empty dependency
// set since remote (non-aggregator) fragments don't receive dependencies.
final DependencyPair dep = siteConnection.executeSysProcPlanFragment(m_txnState, m_inputDeps, fragmentId, params);
// @Shutdown returns null, handle it here
if (dep != null) {
currentFragResponse.addDependency(dep);
}
} catch (final EEException e) {
hostLog.l7dlog(Level.TRACE, LogKeys.host_ExecutionSite_ExceptionExecutingPF.name(), new Object[] { Encoder.hexEncode(m_fragmentMsg.getFragmentPlan(frag)) }, e);
currentFragResponse.setStatus(FragmentResponseMessage.UNEXPECTED_ERROR, e);
if (currentFragResponse.getTableCount() == 0) {
// Make sure the response has at least 1 result with a valid DependencyId
currentFragResponse.addDependency(new DependencyPair.BufferDependencyPair(m_fragmentMsg.getOutputDepId(0), m_rawDummyResult, 0, m_rawDummyResult.length));
}
break;
} catch (final SQLException e) {
hostLog.l7dlog(Level.TRACE, LogKeys.host_ExecutionSite_ExceptionExecutingPF.name(), new Object[] { Encoder.hexEncode(m_fragmentMsg.getFragmentPlan(frag)) }, e);
currentFragResponse.setStatus(FragmentResponseMessage.UNEXPECTED_ERROR, e);
if (currentFragResponse.getTableCount() == 0) {
// Make sure the response has at least 1 result with a valid DependencyId
currentFragResponse.addDependency(new DependencyPair.BufferDependencyPair(m_fragmentMsg.getOutputDepId(0), m_rawDummyResult, 0, m_rawDummyResult.length));
}
break;
} catch (final SpecifiedException e) {
// Note that with SpecifiedException, the error code here might get changed before
// the client/user sees it. It really just needs to indicate failure.
//
// Key point here vs the next catch block for VAE is to not wrap the subclass of
// SerializableException here to preserve it during the serialization.
//
currentFragResponse.setStatus(FragmentResponseMessage.USER_ERROR, e);
if (currentFragResponse.getTableCount() == 0) {
// Make sure the response has at least 1 result with a valid DependencyId
currentFragResponse.addDependency(new DependencyPair.BufferDependencyPair(m_fragmentMsg.getOutputDepId(0), m_rawDummyResult, 0, m_rawDummyResult.length));
}
} catch (final VoltAbortException e) {
currentFragResponse.setStatus(FragmentResponseMessage.USER_ERROR, new SerializableException(CoreUtils.throwableToString(e)));
if (currentFragResponse.getTableCount() == 0) {
// Make sure the response has at least 1 result with a valid DependencyId
currentFragResponse.addDependency(new DependencyPair.BufferDependencyPair(m_fragmentMsg.getOutputDepId(0), m_rawDummyResult, 0, m_rawDummyResult.length));
}
break;
}
if (traceLog != null) {
traceLog.add(VoltTrace::endDuration);
}
}
return currentFragResponse;
}
use of org.voltdb.utils.VoltTrace in project voltdb by VoltDB.
the class SpProcedureTask method run.
/** Run is invoked by a run-loop to execute this transaction. */
@Override
public void run(SiteProcedureConnection siteConnection) {
LatencyWatchdog.pet();
waitOnDurabilityBackpressureFuture();
if (HOST_DEBUG_ENABLED) {
hostLog.debug("STARTING: " + this);
}
final VoltTrace.TraceEventBatch traceLog = VoltTrace.log(VoltTrace.Category.SPI);
if (traceLog != null) {
traceLog.add(() -> VoltTrace.beginDuration("runsptask", "txnId", TxnEgo.txnIdToString(getTxnId()), "partition", Integer.toString(siteConnection.getCorrespondingPartitionId())));
}
if (!m_txnState.isReadOnly()) {
m_txnState.setBeginUndoToken(siteConnection.getLatestUndoToken());
}
// cast up here .. ugly.
SpTransactionState txnState = (SpTransactionState) m_txnState;
InitiateResponseMessage response;
int originalTimeout = siteConnection.getBatchTimeout();
int individualTimeout = m_txnState.getInvocation().getBatchTimeout();
try {
// run the procedure with a specific individual timeout
if (BatchTimeoutOverrideType.isUserSetTimeout(individualTimeout)) {
siteConnection.setBatchTimeout(individualTimeout);
}
response = processInitiateTask(txnState.m_initiationMsg, siteConnection);
} finally {
// reset the deployment timeout value back to its original value
if (BatchTimeoutOverrideType.isUserSetTimeout(individualTimeout)) {
siteConnection.setBatchTimeout(originalTimeout);
}
}
if (!response.shouldCommit()) {
m_txnState.setNeedsRollback(true);
}
completeInitiateTask(siteConnection);
response.m_sourceHSId = m_initiator.getHSId();
m_initiator.deliver(response);
if (EXEC_TRACE_ENABLED) {
execLog.l7dlog(Level.TRACE, LogKeys.org_voltdb_ExecutionSite_SendingCompletedWUToDtxn.name(), null);
}
if (HOST_DEBUG_ENABLED) {
hostLog.debug("COMPLETE: " + this);
}
if (traceLog != null) {
traceLog.add(VoltTrace::endDuration);
}
logToDR(siteConnection.getDRGateway(), txnState, response);
}
use of org.voltdb.utils.VoltTrace 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.utils.VoltTrace in project voltdb by VoltDB.
the class FragmentTask method run.
@Override
public void run(SiteProcedureConnection siteConnection) {
waitOnDurabilityBackpressureFuture();
if (hostLog.isDebugEnabled()) {
hostLog.debug("STARTING: " + this);
}
final VoltTrace.TraceEventBatch traceLog = VoltTrace.log(VoltTrace.Category.SPSITE);
if (traceLog != null) {
traceLog.add(() -> VoltTrace.beginDuration("runfragmenttask", "txnId", TxnEgo.txnIdToString(getTxnId()), "partition", Integer.toString(siteConnection.getCorrespondingPartitionId())));
}
// if this has a procedure name from the initiation bundled,
// inform the site connection here
String procName = m_fragmentMsg.getProcedureName();
if (procName != null) {
siteConnection.setProcedureName(procName);
}
// and do partial rollback
if (!m_txnState.isReadOnly()) {
if (m_txnState.getBeginUndoToken() == Site.kInvalidUndoToken) {
m_txnState.setBeginUndoToken(siteConnection.getLatestUndoToken());
}
}
int originalTimeout = siteConnection.getBatchTimeout();
int individualTimeout = m_fragmentMsg.getBatchTimeout();
try {
if (BatchTimeoutOverrideType.isUserSetTimeout(individualTimeout)) {
siteConnection.setBatchTimeout(individualTimeout);
}
// execute the procedure
final FragmentResponseMessage response = processFragmentTask(siteConnection);
deliverResponse(response);
} finally {
if (BatchTimeoutOverrideType.isUserSetTimeout(individualTimeout)) {
siteConnection.setBatchTimeout(originalTimeout);
}
}
completeFragment();
if (hostLog.isDebugEnabled()) {
hostLog.debug("COMPLETE: " + this);
}
if (traceLog != null) {
traceLog.add(VoltTrace::endDuration);
}
}
Aggregations