Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ protected void handleCommitConflict(Snapshot snapshot, Exception cause)
}

@VisibleForTesting
void onePhaseCommitRecords(Snapshot snapshot) throws CommitException {
void onePhaseCommitRecords(Snapshot snapshot)
throws CommitConflictException, UnknownTransactionStatusException {
try {
OnePhaseCommitMutationComposer composer =
new OnePhaseCommitMutationComposer(snapshot.getId(), tableMetadataManager);
Expand All @@ -279,7 +280,7 @@ void onePhaseCommitRecords(Snapshot snapshot) throws CommitException {
e,
snapshot.getId());
} catch (ExecutionException e) {
throw new CommitException(
throw new UnknownTransactionStatusException(
CoreError.CONSENSUS_COMMIT_COMMITTING_RECORDS_FAILED.buildMessage(), e, snapshot.getId());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,7 @@ public void canOnePhaseCommit_WhenMutationsGrouperThrowsException_ShouldThrowCom

@Test
public void onePhaseCommitRecords_WhenSuccessful_ShouldMutateUsingComposerMutations()
throws CommitException, ExecutionException {
throws CommitConflictException, UnknownTransactionStatusException, ExecutionException {
// Arrange
Snapshot snapshot = spy(prepareSnapshotWithSamePartitionPut());
doNothing().when(storage).mutate(anyList());
Expand Down Expand Up @@ -1131,15 +1131,16 @@ public void onePhaseCommitRecords_WhenSuccessful_ShouldMutateUsingComposerMutati
}

@Test
public void onePhaseCommitRecords_WhenExecutionExceptionThrown_ShouldThrowCommitException()
throws ExecutionException {
public void
onePhaseCommitRecords_WhenExecutionExceptionThrown_ShouldThrowUnknownTransactionStatusException()
throws ExecutionException {
// Arrange
Snapshot snapshot = prepareSnapshotWithSamePartitionPut();
doThrow(ExecutionException.class).when(storage).mutate(anyList());

// Act Assert
assertThatThrownBy(() -> handler.onePhaseCommitRecords(snapshot))
.isInstanceOf(CommitException.class)
.isInstanceOf(UnknownTransactionStatusException.class)
.hasCauseInstanceOf(ExecutionException.class);
}

Expand All @@ -1162,17 +1163,19 @@ public void commit_OnePhaseCommitted_ShouldNotThrowAnyException()
}

@Test
public void commit_OnePhaseCommitted_CommitExceptionThrown_ShouldThrowCommitException()
throws CommitException {
public void
commit_OnePhaseCommitted_UnknownTransactionStatusExceptionThrown_ShouldThrowUnknownTransactionStatusException()
throws CommitException, UnknownTransactionStatusException {
// Arrange
CommitHandler handler = spy(createCommitHandlerWithOnePhaseCommit());
Snapshot snapshot = prepareSnapshotWithSamePartitionPut();

doReturn(true).when(handler).canOnePhaseCommit(snapshot);
doThrow(CommitException.class).when(handler).onePhaseCommitRecords(snapshot);
doThrow(UnknownTransactionStatusException.class).when(handler).onePhaseCommitRecords(snapshot);

// Act Assert
assertThatThrownBy(() -> handler.commit(snapshot, true)).isInstanceOf(CommitException.class);
assertThatThrownBy(() -> handler.commit(snapshot, true))
.isInstanceOf(UnknownTransactionStatusException.class);

verify(handler).onFailureBeforeCommit(snapshot);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ public void onePhaseCommitRecords_WhenSuccessful_ShouldMutateUsingComposerMutati
@Disabled("Enabling both one-phase commit and group commit is not supported")
@Override
@Test
public void onePhaseCommitRecords_WhenExecutionExceptionThrown_ShouldThrowCommitException() {}
public void
onePhaseCommitRecords_WhenExecutionExceptionThrown_ShouldThrowUnknownTransactionStatusException() {}

@Disabled("Enabling both one-phase commit and group commit is not supported")
@Override
Expand All @@ -264,5 +265,6 @@ public void commit_OnePhaseCommitted_ShouldNotThrowAnyException() {}
@Disabled("Enabling both one-phase commit and group commit is not supported")
@Override
@Test
public void commit_OnePhaseCommitted_CommitExceptionThrown_ShouldThrowCommitException() {}
public void
commit_OnePhaseCommitted_UnknownTransactionStatusExceptionThrown_ShouldThrowUnknownTransactionStatusException() {}
}