-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[HUDI-839] Introducing support for rollbacks using marker files #1756
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
Conversation
- Initial commit
…tionExecutor for markers and filelisting
|
@lw309637554 is this ready for review? seems like we have unit test failures? |
...c/test/java/org/apache/hudi/table/action/rollback/TestCopyOnWriteRollbackActionExecutor.java
Outdated
Show resolved
Hide resolved
vinothchandar
left a comment
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.
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 |
…ng markers, fix bugs
@vinothchandar hello,i have add more test for end to end rollback. And the all hudi unit test passed.
if these two question clear and solved, i think the patch will be ok . |
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..
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. |
|
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. |
vinothchandar
left a comment
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.
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()) { |
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.
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
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.
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
hudi-client/src/main/java/org/apache/hudi/io/HoodieAppendHandle.java
Outdated
Show resolved
Hide resolved
hudi-client/src/main/java/org/apache/hudi/io/HoodieMergeHandle.java
Outdated
Show resolved
Hide resolved
hudi-client/src/main/java/org/apache/hudi/io/HoodieWriteHandle.java
Outdated
Show resolved
Hide resolved
hudi-client/src/main/java/org/apache/hudi/table/action/rollback/ListingBasedRollbackHelper.java
Outdated
Show resolved
Hide resolved
hudi-client/src/test/java/org/apache/hudi/index/TestHoodieIndex.java
Outdated
Show resolved
Hide resolved
hudi-client/src/test/java/org/apache/hudi/table/TestCleaner.java
Outdated
Show resolved
Hide resolved
hudi-client/src/test/java/org/apache/hudi/table/TestHoodieMergeOnReadTable.java
Show resolved
Hide resolved
...c/test/java/org/apache/hudi/table/action/rollback/TestCopyOnWriteRollbackActionExecutor.java
Outdated
Show resolved
Hide resolved
...c/test/java/org/apache/hudi/table/action/rollback/TestMergeOnReadRollbackActionExecutor.java
Outdated
Show resolved
Hide resolved
thanks , i will fix the issue as the comment. More comprehensive solution about delete markerfile will depend on you |
0a896c6 to
07558e7
Compare
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.
@vinothchandar I have fix all the issue as you comment. More comprehensive solution about delete markerfile will depend on you
...c/test/java/org/apache/hudi/table/action/rollback/TestCopyOnWriteRollbackActionExecutor.java
Outdated
Show resolved
Hide resolved
hudi-client/src/main/java/org/apache/hudi/io/HoodieWriteHandle.java
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| @Test | ||
| public void testCopyOnWriteTableUsingMarkersRollBack() 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.
yes ,i will remove it
|
@vinothchandar I have fix all the issue as you comment. More comprehensive solution about delete markerfile will depend on you |
|
Thanks! on it! |
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.
@lw309637554 any reason for changing this to PARQUET? (or was that me?)
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.
Get it. it is because master merge do not handle well. Let me fix it
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.
done
|
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
vinothchandar
left a comment
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.
@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. |
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 PR will change behavior for marker dir deletion, with or without marker based rollback turned on.
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.
Ack.
| /** | ||
| * THe marker path will be <base-path>/.hoodie/.temp/<instant_ts>/2019/04/25/filename. | ||
| */ | ||
| private Path makeNewMarkerPath(String partitionPath) { |
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.
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. |
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.
quick skim of changes here would be nice.
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 looks good to me.
hudi-client/src/main/java/org/apache/hudi/table/HoodieTimelineArchiveLog.java
Show resolved
Hide resolved
| /** | ||
| * Delete Marker directory corresponding to an instant. | ||
| */ | ||
| public boolean deleteMarkerDir() { |
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.
@umehrot2 we can now add the parallelization changes here. for deletion of marker files.
| return deleteBaseFile(createdBaseFilePath); | ||
| } | ||
|
|
||
| private HoodieRollbackStat deleteBaseFile(String baseFilePath) throws IOException { |
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 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() |
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.
checked that the log scanner can deal with spurious rollback blocks.. i.e rollbacks logged without any data blocks for that instant
0e5a0bf to
37c1feb
Compare
|
test is failing on CI (linux?) while it passes locally.. Looking. |
bvaradar
left a comment
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.
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. |
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.
Ack.
hudi-client/src/main/java/org/apache/hudi/config/HoodieWriteConfig.java
Outdated
Show resolved
Hide resolved
| 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. |
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 looks good to me.
hudi-client/src/main/java/org/apache/hudi/table/HoodieTimelineArchiveLog.java
Show resolved
Hide resolved
hudi-client/src/main/java/org/apache/hudi/table/MarkerFiles.java
Outdated
Show resolved
Hide resolved
c6afcb1 to
6371ace
Compare
6371ace to
551ce84
Compare
|
@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 |
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:)
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:)
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.