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] Introduce RollbackToTimestamp Procedure and Action #4410

Merged
merged 4 commits into from
Oct 31, 2024

Conversation

xuzifu666
Copy link
Member

@xuzifu666 xuzifu666 commented Oct 30, 2024

Purpose

Linked issue: close #xxx
Currently Rollback cannot rollback according timestamp which can make user more easy to rollback, as #4333 suggest introduce RollbackToTimestamp to support for procedure and action.

Tests

API and Format

Documentation

-- for Flink 1.19 and later<br/>
CALL sys.rollback_to(`table` => 'default.T', snapshot_id => 1730292023000)
</td>
</tr>
Copy link
Contributor

Choose a reason for hiding this comment

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

rollback_to -> rollback_to_timestamp

snapshot_id -> timestamp

Copy link
Member Author

Choose a reason for hiding this comment

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

My mistake, Thanks! @LinMingQiang

* Rollback to timestamp procedure. Usage:
*
* <pre><code>
* -- rollback to a snapshot
Copy link
Contributor

@LinMingQiang LinMingQiang Oct 31, 2024

Choose a reason for hiding this comment

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

rollback to the snapshot which earlier or equal than timestamp.

String.format("count not find snapshot earlier than %s", timestamp));
fileStoreTable.rollbackTo(snapshot.id());
InternalRow outputRow = newInternalRow(true);
return new InternalRow[] {outputRow};
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

snapshot, String.format("count not find snapshot earlier than %s", timestamp));
fileStoreTable.rollbackTo(snapshot.id());

return new String[] {"Success"};
Copy link
Contributor

Choose a reason for hiding this comment

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

Show which snapshot id to roll back to

Copy link
Member Author

Choose a reason for hiding this comment

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

Good reminder~

Preconditions.checkNotNull(
snapshot, String.format("count not find snapshot earlier than %s", timestamp));
fileStoreTable.rollbackTo(snapshot.id());
return new String[] {"Success"};
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto


public String[] call(ProcedureContext procedureContext, String tableId, long timestamp)
throws Catalog.TableNotExistException {
Table table = catalog.getTable(Identifier.fromString(tableId));
Copy link
Contributor

Choose a reason for hiding this comment

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

check table not empty

@xuzifu666 xuzifu666 closed this Oct 31, 2024
@xuzifu666 xuzifu666 reopened this Oct 31, 2024
@xuzifu666
Copy link
Member Author

@LinMingQiang had addressed, Thanks

@LinMingQiang
Copy link
Contributor

+1

Copy link
Contributor

@JingsongLi JingsongLi left a comment

Choose a reason for hiding this comment

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

@JingsongLi JingsongLi merged commit 5ffc6a1 into apache:master Oct 31, 2024
13 checks passed
hang8929201 pushed a commit to hang8929201/paimon that referenced this pull request 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