Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Commit state should be unknown even when new location is not in history #3717

Merged
merged 1 commit into from Dec 12, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -306,8 +306,8 @@ protected CommitStatus checkCommitStatus(String newMetadataLocation, TableMetada
LOG.info("Commit status check: Commit to {} of {} succeeded", tableName(), newMetadataLocation);
status.set(CommitStatus.SUCCESS);
} else {
LOG.info("Commit status check: Commit to {} of {} failed", tableName(), newMetadataLocation);
status.set(CommitStatus.FAILURE);
LOG.warn("Commit status check: Commit to {} of {} unknown, new metadata location is not current " +
"or in history", tableName(), newMetadataLocation);
}
});

Expand Down
Expand Up @@ -77,10 +77,11 @@ public void testSuppressUnlockExceptions() throws TException, InterruptedExcepti
}

/**
* Pretends we throw an error while persisting that actually fails to commit serverside
* Pretends we throw an error while persisting, and not found with check state, commit state should be treated as
* unknown, because in reality the persisting may still succeed, just not yet by the time of checking.
*/
@Test
public void testThriftExceptionFailureOnCommit() throws TException, InterruptedException {
public void testThriftExceptionUnknownStateIfNotInHistoryFailureOnCommit() throws TException, InterruptedException {
Table table = catalog.loadTable(TABLE_IDENTIFIER);
HiveTableOperations ops = (HiveTableOperations) ((HasTableOperations) table).operations();

Expand All @@ -100,14 +101,15 @@ public void testThriftExceptionFailureOnCommit() throws TException, InterruptedE

failCommitAndThrowException(spyOps);

AssertHelpers.assertThrows("We should rethrow generic runtime errors if the " +
"commit actually doesn't succeed", RuntimeException.class, "Metastore operation failed",
() -> spyOps.commit(metadataV2, metadataV1));
AssertHelpers.assertThrows("We should assume commit state is unknown if the " +
"new location is not found in history in commit state check", CommitStateUnknownException.class,
"Datacenter on fire", () -> spyOps.commit(metadataV2, metadataV1));

ops.refresh();
Assert.assertEquals("Current metadata should not have changed", metadataV2, ops.current());
Assert.assertTrue("Current metadata should still exist", metadataFileExists(metadataV2));
Assert.assertEquals("No new metadata files should exist", 2, metadataFileCount(ops.current()));
Assert.assertEquals("New metadata files should still exist, new location not in history but" +
" the commit may still succeed", 3, metadataFileCount(ops.current()));
}

/**
Expand Down