Skip to content

Conversation

@lw309637554
Copy link
Contributor

Tips

What is the purpose of the pull request

add more tests for MarkerFiles,RollbackUtils, RollbackActionExecutor for markers and filelisting.
also fix the bugs for RollbackActionExecutor with markers mode or filelisting mode:

in HoodieWriteClient.java should not deleteMarkerDir, the rollback with markerfiles mode will failed
in ListingBasedRollbackHelper.java "(path.toString().endsWith(HoodieFileFormat.HOODIE_LOG.getFileExtension()))" can not check file is logfile
in "MarkerBasedRollbackStrategy.java" baseCommitTime should use FSUtils.getCommitTime(baseFilePathForAppend.getName());

Brief change log

(for example:)

  • Modify AnnotationLocation checkstyle rule in checkstyle.xml

Verify this pull request

(Please pick either of the following options)

This pull request is a trivial rework / code cleanup without any test coverage.

(or)

This pull request is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end.
  • Added HoodieClientWriteTest to verify the change.
  • Manually verified the change by running a job locally.

Committer checklist

  • Has a corresponding JIRA in PR title & commit

  • Commit message is descriptive of the change

  • CI is green

  • Necessary doc changes done or have another open PR

  • For large changes, please consider breaking it into sub-tasks under an umbrella JIRA.

@vinothchandar vinothchandar changed the title Adding unit test for MarkerFiles,RollbackUtils, RollbackActionExecutor for markers and filelisting [HUDI-839] Adding unit test for MarkerFiles,RollbackUtils, RollbackActionExecutor for markers and filelisting Jun 24, 2020
@vinothchandar
Copy link
Member

@lw309637554 is this ready for review? seems like we have unit test failures?

Copy link
Member

@vinothchandar vinothchandar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took a quick pass at the three test classes you have added.. LGTM .
Will do a detailed pass once you confirm PR is indeed ready..

@lw309637554
Copy link
Contributor Author

Took a quick pass at the three test classes you have added.. LGTM .
Will do a detailed pass once you confirm PR is indeed ready..

Thanks,i will fix the failed unit test

@lw309637554
Copy link
Contributor Author

lw309637554 commented Jun 26, 2020

Took a quick pass at the three test classes you have added.. LGTM .
Will do a detailed pass once you confirm PR is indeed ready..

@vinothchandar hello,i have add more test for end to end rollback. And the all hudi unit test passed.
There are a few questions to discuss with you:

  1. for rollback successful commit, in HoodieWriteClient.java i remove the deleteMarkerDir() in postcommit when is in usingmarkers mode. But it will double the file numbers in dfs.
  2. if the markers file retain, if we should clean it when the datafile is cleaned, also if we should archive the markers file when archiveCommitsWith

if these two question clear and solved, i think the patch will be ok .

@vinothchandar
Copy link
Member

for rollback successful commit, in HoodieWriteClient.java i remove the deleteMarkerDir() in postcommit when is in usingmarkers mode. But it will double the file numbers in dfs.

I think delaying marker deletion till cleaning is probably ok. but the reconcilation with data files i.e the deletion of extraeneous data files written due to spark stage retries must be handled pre-commit..

if the markers file retain, if we should clean it when the datafile is cleaned, also if we should archive the markers file when archiveCommitsWith

there is no need to archive teh marker files in my opinion.. the contract in Hudi is that once an instant leaves the active timeline, its effects are permanent on the table ... so if a rollback needs to happen based on marker files, then it needs to be within the retained commits for active timeline.. I think this is a practical approach..

think of active timeline as the transaction log with pending actions/inflight/completed actions..

@lw309637554
Copy link
Contributor Author

for rollback successful commit, in HoodieWriteClient.java i remove the deleteMarkerDir() in postcommit when is in usingmarkers mode. But it will double the file numbers in dfs.

I think delaying marker deletion till cleaning is probably ok. but the reconcilation with data files i.e the deletion of extraeneous data files written due to spark stage retries must be handled pre-commit..

if the markers file retain, if we should clean it when the datafile is cleaned, also if we should archive the markers file when archiveCommitsWith

there is no need to archive teh marker files in my opinion.. the contract in Hudi is that once an instant leaves the active timeline, its effects are permanent on the table ... so if a rollback needs to happen based on marker files, then it needs to be within the retained commits for active timeline.. I think this is a practical approach..

think of active timeline as the transaction log with pending actions/inflight/completed actions..

thanks, agree with you . I will update the PR.

@vinothchandar
Copy link
Member

I will do a deep review of this over the weekend.. and see if I fix few things and merge.. thanks @lw309637554 !

@lw309637554
Copy link
Contributor Author

I will do a deep review of this over the weekend.. and see if I fix few things and merge.. thanks @lw309637554 !

Thanks, i add the markerfiles clean in pre-commit for spark stage retries.

Copy link
Member

@vinothchandar vinothchandar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the tests.. left some comments..

I am trying to cross check the deletion of the marker dir once more (the issue you mentioned before in prev iteration).. I will push an update to the branch.. and it should be good to go.

Option<Map<String, String>> extraMetadata) {
protected void postCommit(HoodieTable<?> table, HoodieCommitMetadata metadata, String instantTime, Option<Map<String, String>> extraMetadata) {
try {
if (!config.getRollBackUsingMarkers()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if we should do this always.. having this logic be rollback dependent can become hard to reason with in the long run

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i also think it not so good. i think can do not delete markerfiles here.Can delete the unuseful markerfile in pre-commit. when clean delete the old markerfiles

@lw309637554
Copy link
Contributor Author

Thanks for adding the tests.. left some comments..

I am trying to cross check the deletion of the marker dir once more (the issue you mentioned before in prev iteration).. I will push an update to the branch.. and it should be good to go.

thanks , i will fix the issue as the comment. More comprehensive solution about delete markerfile will depend on you

@lw309637554 lw309637554 force-pushed the HUDI-839-lw branch 2 times, most recently from 0a896c6 to 07558e7 Compare July 7, 2020 15:16
Copy link
Contributor Author

@lw309637554 lw309637554 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vinothchandar I have fix all the issue as you comment. More comprehensive solution about delete markerfile will depend on you

}

@Test
public void testCopyOnWriteTableUsingMarkersRollBack() throws Exception {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes ,i will remove it

@lw309637554
Copy link
Contributor Author

@vinothchandar I have fix all the issue as you comment. More comprehensive solution about delete markerfile will depend on you

@vinothchandar
Copy link
Member

Thanks! on it!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lw309637554 any reason for changing this to PARQUET? (or was that me?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get it. it is because master merge do not handle well. Let me fix it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@vinothchandar
Copy link
Member

thanks @lw309637554 actually was working on fixing it myself :). I am working on the marker dir deletion now. Will push to this branch later today.

@lw309637554
Copy link
Contributor Author

thanks @lw309637554 actually was working on fixing it myself :). I am working on the marker dir deletion now. Will push to this branch later today.

thanks @lw309637554 actually was working on fixing it myself :). I am working on the marker dir deletion now. Will push to this branch later today.

okay

 - Added marker dir deletion after successful commit/rollback, individual files are not deleted during finalize
 - Fail safe for deleting marker directories, now during timeline archival process
 - Added check to ensure completed instants are not rolled back using marker based strategy. This will be incorrect
 - Reworked tests to rollback inflight instants, instead of completed instants whenever necessary
 - Added an unit test for MarkerBasedRollbackStrategy
Copy link
Member

@vinothchandar vinothchandar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lw309637554 I pushed the changes to the branch.. Once CI passes, this should be good to merge IMO. Please take a pass at teh changes I made in the last two commits..

@bvaradar @n3nash this is a tricky change. Since you both know rollback and marker files the best. can you make a quick pass of the places I have highlighted in the review.

protected void postCommit(HoodieTable<?> table, HoodieCommitMetadata metadata, String instantTime, Option<Map<String, String>> extraMetadata) {
try {

// Delete the marker directory for the instant.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this PR will change behavior for marker dir deletion, with or without marker based rollback turned on.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack.

/**
* THe marker path will be <base-path>/.hoodie/.temp/<instant_ts>/2019/04/25/filename.
*/
private Path makeNewMarkerPath(String partitionPath) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all of this stuff is now encapsulatd into a MarkerFiles class

baseFileExtension);
List<String> validDataPaths = stats.stream().map(w -> String.format("%s/%s", basePath, w.getPath()))
.filter(p -> p.endsWith(baseFileExtension)).collect(Collectors.toList());
// we are not including log appends here, since they are already fail-safe.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick skim of changes here would be nice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

/**
* Delete Marker directory corresponding to an instant.
*/
public boolean deleteMarkerDir() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@umehrot2 we can now add the parallelization changes here. for deletion of marker files.

return deleteBaseFile(createdBaseFilePath);
}

private HoodieRollbackStat deleteBaseFile(String baseFilePath) throws IOException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is resilient already to attempting to delete an non-existent file.. marker file may not imply the data file is thre.

.withPartitionPath(partitionPath)
.build();
}
writer = HoodieLogFormat.newWriterBuilder()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checked that the log scanner can deal with spurious rollback blocks.. i.e rollbacks logged without any data blocks for that instant

@vinothchandar vinothchandar changed the title [HUDI-839] Adding unit test for MarkerFiles,RollbackUtils, RollbackActionExecutor for markers and filelisting [HUDI-839] Introducing support for rollbacks using marker files Jul 20, 2020
@vinothchandar
Copy link
Member

test is failing on CI (linux?) while it passes locally.. Looking.

Copy link
Contributor

@bvaradar bvaradar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a pass. @vinothchandar : Code changes look safe and good to me.

protected void postCommit(HoodieTable<?> table, HoodieCommitMetadata metadata, String instantTime, Option<Map<String, String>> extraMetadata) {
try {

// Delete the marker directory for the instant.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack.

baseFileExtension);
List<String> validDataPaths = stats.stream().map(w -> String.format("%s/%s", basePath, w.getPath()))
.filter(p -> p.endsWith(baseFileExtension)).collect(Collectors.toList());
// we are not including log appends here, since they are already fail-safe.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

@vinothchandar vinothchandar force-pushed the HUDI-839-lw branch 4 times, most recently from c6afcb1 to 6371ace Compare July 20, 2020 22:13
@vinothchandar
Copy link
Member

@lw309637554 Looks good. Planning to merge after CI passes this time.. Thanks a lot of for your contributions. This is one very important PR !

@vinothchandar vinothchandar merged commit 1ec89e9 into apache:master Jul 21, 2020
@lw309637554
Copy link
Contributor Author

@lw309637554 Looks good. Planning to merge after CI passes this time.. Thanks a lot of for your contributions. This is one very important PR !

Great, a very good cooperation experience . I can start other work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants