TransactionAbortRequest is used to indicate both user abort
and 3PC abort, whereas current backend code assumed it is
only used for 3PC -- hence it required a cohort to be present.
Teach handleTransactionAbort to use a direct transaction abort
if it receives a request without having a cohort present.
Change-Id: Ia469d907edb575d5f1ee5e4f630fe1a19204032f
Signed-off-by: Robert Varga <rovarga@cisco.com>
handleTransactionDoCommit((TransactionDoCommitRequest) request, envelope, now);
return null;
} else if (request instanceof TransactionAbortRequest) {
handleTransactionDoCommit((TransactionDoCommitRequest) request, envelope, now);
return null;
} else if (request instanceof TransactionAbortRequest) {
- handleTransactionAbort((TransactionAbortRequest) request, envelope, now);
- return null;
+ return handleTransactionAbort((TransactionAbortRequest) request, envelope, now);
} else {
throw new UnsupportedRequestException(request);
}
} else {
throw new UnsupportedRequestException(request);
}
- private void handleTransactionAbort(final TransactionAbortRequest request, final RequestEnvelope envelope,
- final long now) throws RequestException {
+ private TransactionSuccess<?> handleTransactionAbort(final TransactionAbortRequest request,
+ final RequestEnvelope envelope, final long now) throws RequestException {
+ if (readyCohort == null) {
+ openTransaction.abort();
+ return new TransactionAbortSuccess(id, request.getSequence());
+ }
+
readyCohort.abort(new FutureCallback<Void>() {
@Override
public void onSuccess(final Void result) {
readyCohort.abort(new FutureCallback<Void>() {
@Override
public void onSuccess(final Void result) {
recordAndSendFailure(envelope, now, new RuntimeRequestException("Abort failed", failure));
}
});
recordAndSendFailure(envelope, now, new RuntimeRequestException("Abort failed", failure));
}
});
}
private void coordinatedCommit(final RequestEnvelope envelope, final long now) {
}
private void coordinatedCommit(final RequestEnvelope envelope, final long now) {