in src/main/java/com/amazonaws/services/dynamodbv2/transactions/Transaction.java [349:379]
public void sweep(long rollbackAfterDurationMills, long deleteAfterDurationMillis) {
// If the item has been completed for the specified threshold, delete it.
if(txItem.isCompleted()) {
delete(deleteAfterDurationMillis);
} else {
// If the transaction has been PENDING for too long, roll it back.
// If it's COMMITTED or PENDING, drive it to completion.
switch (txItem.getState()) {
case PENDING:
if((txItem.getLastUpdateTimeMillis() + rollbackAfterDurationMills) < System.currentTimeMillis()) {
try {
rollback();
} catch (TransactionCompletedException e) {
// Transaction is already completed, ignore
}
}
break;
case COMMITTED: // NOTE: falling through to ROLLED_BACK
case ROLLED_BACK:
// This could call either commit or rollback - they'll both do the right thing if it's already committed
try {
rollback();
} catch (TransactionCompletedException e) {
// Transaction is already completed, ignore
}
break;
default:
throw new TransactionAssertionException(txId, "Unexpected state in transaction: " + txItem.getState());
}
}
}