// Note that when we call transactionFinish() right here this thread will then go on
// to invoke HStoreSite.transactionFinish() for us. That means when it returns we will
// have successfully aborted the txn at least at all of the local partitions at this site.
else {
if (hstore_conf.site.txn_profiling && ts.profiler != null) ts.profiler.startPostFinish();
LocalFinishCallback finish_callback = ts.getFinishCallback();
finish_callback.init(ts, status);
finish_callback.markForRequeue();
if (hstore_conf.site.exec_profiling) this.profiler.network_time.start();
this.hstore_coordinator.transactionFinish(ts, status, finish_callback);
if (hstore_conf.site.exec_profiling) this.profiler.network_time.stopIfStarted();
}
}
// -------------------------------
// ALL: Single-Partition Transactions
// -------------------------------
else if (ts.isPredictSinglePartition()) {
// Commit or abort the transaction only if we haven't done it already
// This can happen when we commit speculative txns out of order
if (ts.isMarkedFinished(this.partitionId) == false) {
this.finishTransaction(ts, status);
}
// We have to mark it as loggable to prevent the response
// from getting sent back to the client
if (hstore_conf.site.commandlog_enable) ts.markLogEnabled();
if (hstore_conf.site.exec_profiling) this.profiler.network_time.start();
this.hstore_site.responseSend(ts, cresponse);
if (hstore_conf.site.exec_profiling) this.profiler.network_time.stopIfStarted();
this.hstore_site.queueDeleteTransaction(ts.getTransactionId(), status);
}
// -------------------------------
// COMMIT: Distributed Transaction
// -------------------------------
else if (status == Status.OK) {
// We need to set the new ExecutionMode before we invoke transactionPrepare
// because the LocalTransaction handle might get cleaned up immediately
ExecutionMode newMode = null;
if (hstore_conf.site.specexec_enable) {
newMode = (ts.isExecReadOnly(this.partitionId) ? ExecutionMode.COMMIT_READONLY :
ExecutionMode.COMMIT_NONE);
} else {
newMode = ExecutionMode.DISABLED;
}
this.setExecutionMode(ts, newMode);
if (hstore_conf.site.txn_profiling && ts.profiler != null) ts.profiler.startPostPrepare();
if (hstore_conf.site.exec_profiling) {
this.profiler.network_time.start();
this.profiler.sp3_local_time.start();
}
// We will send a prepare message to all of our remote HStoreSites
// The coordinator needs to be smart enough to know whether a txn
// has already been marked as prepared at a partition (i.e., it's gotten
// responses).
PartitionSet partitions = ts.getPredictTouchedPartitions();
LocalPrepareCallback callback = ts.getPrepareCallback();
this.hstore_coordinator.transactionPrepare(ts, callback, partitions);
if (hstore_conf.site.exec_profiling) this.profiler.network_time.stopIfStarted();
ts.getDonePartitions().addAll(partitions);
}
// -------------------------------
// ABORT: Distributed Transaction
// -------------------------------
else {
// Send back the result to the client right now, since there's no way
// that we're magically going to be able to recover this and get them a result
// This has to come before the network messages above because this will clean-up the
// LocalTransaction state information
this.hstore_site.responseSend(ts, cresponse);
// Send a message all the partitions involved that the party is over
// and that they need to abort the transaction. We don't actually care when we get the
// results back because we'll start working on new txns right away.
// Note that when we call transactionFinish() right here this thread will then go on
// to invoke HStoreSite.transactionFinish() for us. That means when it returns we will
// have successfully aborted the txn at least at all of the local partitions at this site.
if (hstore_conf.site.txn_profiling && ts.profiler != null) ts.profiler.startPostFinish();
LocalFinishCallback callback = ts.getFinishCallback();
callback.init(ts, status);
if (hstore_conf.site.exec_profiling) this.profiler.network_time.start();
try {
this.hstore_coordinator.transactionFinish(ts, status, callback);
} finally {
if (hstore_conf.site.exec_profiling) this.profiler.network_time.stopIfStarted();