-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat: Add support to PageGuard upgrade #581
Conversation
Could I ask whether |
I rethought the upgrade logic, and found that we should drop the current |
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.
In my definition of upgrade, it should be an atomic operation. For example, in read -> write upgrade, we will not drop the read lock. I think the same should apply to basic -> read upgrade.
I remembered there is a manual upgrade in table heap. Probably we can copy-paste that implementation.
Overall this sounds like a good practice for students and I would like to take this test case without implementation. I can remove UpgradeWrite/Read
when I finish the refsol implementation and merge this.
src/storage/page/page_guard.cpp
Outdated
auto *bpm = bpm_; | ||
auto cur_pid = page_->GetPageId(); | ||
// First drop the current page guard | ||
this->Drop(); |
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.
In this implementation, there is possibility that the page will be evicted between L23 and L25?
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.
Ahh I see, I ignore the inner condition when implementing the upgrade logic😭
I update the inner logic for Also, I'd be glad to help write test cases, and I'll write more test cases in addition to basic sanity check, probably you can integrate some of the tests into |
If the updated logic looks good, I'll just remove the implementation part, and leave it blank to the students, along with the tests. |
Seems that |
Also, do we currently support upgrade from |
we do not plan to support read -> write b/c it's hard to make it atomic :( Thanks for your contribution and I think we have incorporated what we need from this PR, and probably we can close it for now? |
Yea I've tried implementing this months before and also found it hard to maintain the atomicity without relying on some outer libraries 🤣
Sure! Thanks for reviewing 🥰 |
This PR acts as a basic approach to issue #539, which adds two upgrade method,
UpgradeRead()
&UpgradeWrite
toBasicPageGuard
, also creates the correspondingGuardUpgradeTest
, which is now disabled (Already been tested locally).But if these two are left to future students, I can then remove the actual implementation part, and add guidelines to the comments🫣