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] Fast return if rollback verion equals lastest version #4467

Closed
wants to merge 2 commits into from

Conversation

askwang
Copy link
Contributor

@askwang askwang commented Nov 6, 2024

Purpose

If the rollback snapshot version is equal to the lastest snapshot version, we should fast return.

Tests

API and Format

Documentation

@@ -625,14 +630,19 @@ public void rollbackTo(String tagName) {
checkArgument(tagManager.tagExists(tagName), "Rollback tag '%s' doesn't exist.", tagName);

Snapshot taggedSnapshot = tagManager.taggedSnapshot(tagName);
SnapshotManager snapshotManager = snapshotManager();
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a blank line.

@@ -512,6 +512,11 @@ public void rollbackTo(long snapshotId) {
"Rollback snapshot '%s' doesn't exist.",
snapshotId);

// fast return
if (new Long(snapshotId).equals(snapshotManager.latestSnapshotId())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think new Long has a little strange.
Why not:

Long latestSnapshotId = snapshotManager.latestSnapshotId();
if (latestSnapshotId == null) {
exception or error log
}
if (taggedSnapshot.id() == latestSnapshotId) {
fast return
}

@wwj6591812
Copy link
Contributor

wwj6591812 commented Nov 7, 2024

A question:
Assuming that when the user executes the rollback procedure with snapshot = 1, the latestSnapshot Id of the Paimon table is 1, and before the rollback procedure ends, the latestSnapshot Id of the Paimon table changes to 2.
After you apply this patch, in the end, the rollback procedure fast return, so the RollbackHelper#cleanLargerThan will not be called.
Is this the result that the user wants?

@askwang
Copy link
Contributor Author

askwang commented Nov 7, 2024

A question: Assuming that when the user executes the rollback procedure with snapshot = 1, the latestSnapshot Id of the Paimon table is 1, and before the rollback procedure ends, the latestSnapshot Id of the Paimon table changes to 2. After you apply this patch, in the end, the rollback procedure fast return, so the RollbackHelper#cleanLargerThan will not be called. Is this the result that the user wants?

In this case, the result is not what the user wants. But although there does not fast return, this case may also occur. For example, the rollback snapshot is 1 and the latest snapshot of table is also 1, before rollback ends the lastest snapshot of table changes to 2 or 3, the rollback logic gets the lastest shotshot is diffcult to keep always the newest, this will cause some new snapshots not to be processed.

@JingsongLi
Copy link
Contributor

Hi @askwang , what is this PR aims to? just for performance?

@askwang
Copy link
Contributor Author

askwang commented Nov 7, 2024

Hi @askwang , what is this PR aims to? just for performance?

yes, juse fast return, no need to execute RollbackHelper#cleanLargerThan.

@JingsongLi
Copy link
Contributor

Hi @askwang , what is this PR aims to? just for performance?

yes, juse fast return, no need to execute RollbackHelper#cleanLargerThan.

Do we need to care about the speed of this operation? I think it should be very fast even no optimization.

@askwang askwang closed this Nov 7, 2024
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