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
[HUDI-3180] Include files from completed commits while bootstrapping metadata table #4519
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
import org.apache.hudi.common.model.HoodieCommitMetadata; | ||
import org.apache.hudi.common.model.HoodieTableType; | ||
import org.apache.hudi.common.table.view.FileSystemViewStorageConfig; | ||
import org.apache.hudi.common.testutils.FileCreateUtils; | ||
import org.apache.hudi.common.testutils.HoodieMetadataTestTable; | ||
import org.apache.hudi.common.testutils.HoodieTestDataGenerator; | ||
import org.apache.hudi.common.testutils.HoodieTestTable; | ||
|
@@ -36,7 +37,10 @@ | |
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.EnumSource; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.Arrays; | ||
import java.util.UUID; | ||
|
||
import static java.util.Arrays.asList; | ||
import static java.util.Collections.emptyList; | ||
|
@@ -76,6 +80,36 @@ public void testMetadataBootstrapInsertUpsertClean(HoodieTableType tableType) th | |
bootstrapAndVerify(); | ||
} | ||
|
||
/** | ||
* Validate that bootstrap considers only files part of completed commit and ignore any extra files. | ||
*/ | ||
@Test | ||
public void testMetadataBootstrapWithExtraFiles() throws Exception { | ||
HoodieTableType tableType = COPY_ON_WRITE; | ||
init(tableType, false); | ||
doPreBootstrapWriteOperation(testTable, INSERT, "0000001"); | ||
doPreBootstrapWriteOperation(testTable, "0000002"); | ||
doPreBootstrapClean(testTable, "0000003", Arrays.asList("0000001")); | ||
doPreBootstrapWriteOperation(testTable, "0000005"); | ||
// add few extra files to table. bootstrap should include those files. | ||
String fileName = UUID.randomUUID().toString(); | ||
Path baseFilePath = FileCreateUtils.getBaseFilePath(basePath, "p1", "0000006", fileName); | ||
FileCreateUtils.createBaseFile(basePath, "p1", "0000006", fileName, 100); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we instead start the commit and not have it completed so that we have it in timeline also ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if its part of the timeline, bootstrap may not kick in. also, not sure if we will gain much from it. this test fails if not the fix in source code as part of this patch. So, we should be good. Let me know what you think. |
||
|
||
writeConfig = getWriteConfig(true, true); | ||
initWriteConfigAndMetatableWriter(writeConfig, true); | ||
syncTableMetadata(writeConfig); | ||
|
||
// remove those files from table. and then validate. | ||
Files.delete(baseFilePath); | ||
|
||
// validate | ||
validateMetadata(testTable); | ||
// after bootstrap do two writes and validate its still functional. | ||
doWriteInsertAndUpsert(testTable); | ||
validateMetadata(testTable); | ||
} | ||
|
||
@ParameterizedTest | ||
@EnumSource(HoodieTableType.class) | ||
public void testMetadataBootstrapInsertUpsertRollback(HoodieTableType tableType) throws Exception { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this does not filter out the failed old commits right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bootstrap itself will get triggered only if all operations are complete. If there was a partially failed commit, unless an explicit rollback happens, bootstrap may not kick in.