-
Notifications
You must be signed in to change notification settings - Fork 158
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
[Enhancement] Support restore/rollback sync during conversion (1/2) #569
Open
danielhumanmod
wants to merge
31
commits into
apache:main
Choose a base branch
from
danielhumanmod:40-rollback-support-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
e0a8710
Add a source identifier in target table transaction
danielhumanmod 9bc8256
detect rollback from source and target table
danielhumanmod 76e0bc0
boundary safe
danielhumanmod 45b279a
fix existing tests
danielhumanmod 8ac5717
support commit level info
danielhumanmod 53a58b6
remove redundant changes
danielhumanmod bb5ed78
simplify source id generation
danielhumanmod 9b8b71e
remove rollback detection in this PR
danielhumanmod 252ca2c
format
danielhumanmod d9cb5fd
avoid hard code
danielhumanmod c8dde9e
format
danielhumanmod bfbb78f
use timestamp as source identifier for Hudi
danielhumanmod 002d91b
optimize early termination logic
danielhumanmod bf5f0a0
source-target identifier mapping test
danielhumanmod 56fe85e
introduce source metadata
danielhumanmod a40cd6c
make some methods private
danielhumanmod 1e39d1a
make xtable metadata commit level in delta and iceberg
danielhumanmod 0af0a82
simplify hudi metadata operation
danielhumanmod 82b2d2d
refactor get target commit process
danielhumanmod 7ffda25
format
danielhumanmod 4198e5b
improve doc and test
danielhumanmod b181a07
format
danielhumanmod 4ca9c9a
Merge branch 'main' of https://github.com/danielhumanmod/incubator-xt…
danielhumanmod 9552679
fix compile error
danielhumanmod 5fe489e
make sourceIdentifier nonnull without default value
danielhumanmod 42c804b
keep existing table-level metadata
danielhumanmod e470e98
standard way for doc
danielhumanmod 2033c3a
complete tests after making sourceIdentifier nonnull
danielhumanmod edb99fd
using TimelineUtils#getCommitMetadata to extract commit metadata
danielhumanmod 65dc4c9
Merge branch 'main' of https://github.com/danielhumanmod/incubator-xt…
danielhumanmod 246ce6f
fix testing issue after merge main
danielhumanmod File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,7 +73,8 @@ public Map<String, SyncResult> syncSnapshot( | |
internalTable, | ||
target -> target.syncFilesForSnapshot(snapshot.getPartitionedDataFiles()), | ||
startTime, | ||
snapshot.getPendingCommits())); | ||
snapshot.getPendingCommits(), | ||
snapshot.getSourceIdentifier())); | ||
} catch (Exception e) { | ||
log.error("Failed to sync snapshot", e); | ||
results.put( | ||
|
@@ -121,7 +122,8 @@ public Map<String, List<SyncResult>> syncChanges( | |
change.getTableAsOfChange(), | ||
target -> target.syncFilesForDiff(change.getFilesDiff()), | ||
startTime, | ||
changes.getPendingCommits())); | ||
changes.getPendingCommits(), | ||
change.getSourceIdentifier())); | ||
} catch (Exception e) { | ||
log.error("Failed to sync table changes", e); | ||
resultsForFormat.add(buildResultForError(SyncMode.INCREMENTAL, startTime, e)); | ||
|
@@ -149,19 +151,26 @@ private SyncResult getSyncResult( | |
InternalTable tableState, | ||
SyncFiles fileSyncMethod, | ||
Instant startTime, | ||
List<Instant> pendingCommits) { | ||
List<Instant> pendingCommits, | ||
String sourceIdentifier) { | ||
// initialize the sync | ||
conversionTarget.beginSync(tableState); | ||
// Persist the latest commit time in table properties for incremental syncs | ||
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. Here We need to move the Metadata set operation earlier because it will be required during the |
||
// Syncing metadata must precede the following steps to ensure that the metadata is available | ||
// before committing | ||
TableSyncMetadata latestState = | ||
TableSyncMetadata.of( | ||
tableState.getLatestCommitTime(), | ||
pendingCommits, | ||
tableState.getTableFormat(), | ||
sourceIdentifier); | ||
conversionTarget.syncMetadata(latestState); | ||
// sync schema updates | ||
conversionTarget.syncSchema(tableState.getReadSchema()); | ||
// sync partition updates | ||
conversionTarget.syncPartitionSpec(tableState.getPartitioningFields()); | ||
// Update the files in the target table | ||
fileSyncMethod.sync(conversionTarget); | ||
// Persist the latest commit time in table properties for incremental syncs. | ||
TableSyncMetadata latestState = | ||
TableSyncMetadata.of(tableState.getLatestCommitTime(), pendingCommits); | ||
conversionTarget.syncMetadata(latestState); | ||
conversionTarget.completeSync(); | ||
|
||
return SyncResult.builder() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Will these identifier's always be the same? if so, is it simpler to make this a boolean method?
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 the source identifier stored in the target table remains unchanged. However, this API is designed to retrieve the corresponding target COMMIT based on an input source identifier (It would be the rollback source COMMIT in this feature). This allows us to initiate a rollback to the retrieved target COMMIT on the target table