-
Notifications
You must be signed in to change notification settings - Fork 90
feat: add SnapshotManager #542
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
base: main
Are you sure you want to change the base?
Conversation
The test cases are derived from Java's TestSnapshotManager.java. Since MergeAppend is not supported yet, some tests are omitted for now and can be added later.
evindj
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.
Overall LGTM only question that I have is why is UpdateSnapshotReference and SnapShotManager both exposed. Also, is there a way we can integration test this change?
…SnapshotManager::Commit
0ae7a0d to
db23355
Compare
|
|
||
| private: | ||
| friend class PendingUpdate; | ||
| friend class SnapshotManager; |
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.
Is this required?
| } | ||
|
|
||
| Result<std::shared_ptr<SnapshotManager>> Transaction::NewSnapshotManager() { | ||
| // SnapshotManager has its own commit logic, so it is not added to the pending updates. |
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.
We can still call AddUpdate just like other updates and do not set last_update_committed_ to false for SnapshotManager. However, it seems that SnapshotManager cannot be retried easily so I'm fine to keep the current approach as is.
| Result<std::shared_ptr<SnapshotManager>> Table::NewSnapshotManager() { | ||
| ICEBERG_ASSIGN_OR_RAISE( | ||
| auto transaction, Transaction::Make(shared_from_this(), Transaction::Kind::kUpdate, | ||
| /*auto_commit=*/false)); |
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.
Here auto_commit means that users do not need to call Transaction::Commit() after calling SnapshotManager::Commit(). Should we set this to true and handle the commit logic internally?
| } | ||
|
|
||
| Status SnapshotManager::Commit() { | ||
| transaction_->EnableAutoCommit(); |
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 think we need to read and backup Transaction::auto_commit_ in the SnapshotManager ctor and then restore it before exiting this function, otherwise any CommitIfRefUpdatesExist() before SnapshotManager::Commit() will set Transaction::committed_ to true.
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.
To verify this issue, we can create a SnapshotManager from Table & Transaction and then call SetCurrentSnapshot and RollbackXXX for multiple times to see it they can be committed successfully.
| void SetUp() override { | ||
| InitializeFileIO(); | ||
| RegisterTableFromResource("TableMetadataV2Valid.json"); | ||
| RegisterMinimalTableFromResource("TableMetadataV2ValidMinimal.json"); |
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.
It looks weird to register two resources in the per-case setup function but each case uses only one of them. Does it make sense to use class inheritance for each resource?
The test cases are derived from Java's TestSnapshotManager.java. Since MergeAppend is not supported yet, some tests are omitted for now and can be added later.