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

storage: use Arc<Version> during pin and unpin #549

Closed
wants to merge 1 commit into from

Conversation

Yisaer
Copy link

@Yisaer Yisaer commented Mar 4, 2022

Signed-off-by: yisaer disxiaofei@163.com

close #537

Currently, we use pin and unpin manually in code. In this request, we use Arc<Version> to help us automatically unpin instead of manual code.

Signed-off-by: yisaer <disxiaofei@163.com>
@skyzh skyzh self-requested a review March 4, 2022 07:29
Copy link
Member

@skyzh skyzh left a comment

Choose a reason for hiding this comment

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

Rest LGTM, thanks!

I've another idea: we can simply using Arc to help us do reference counting, instead of maintaining the ref_cnt by ourselves. For each epoch, we associate a single Version object, and wrap it with an Arc. When a user requests pin, we clone the Arc for them. When the last Arc gets dropped, the Version object gets dropped, and we can safely remove the version.

@@ -70,15 +67,15 @@ impl SecondaryTransaction {
update: bool,
) -> StorageResult<Self> {
// pin a snapshot at version manager
let (epoch, snapshot) = table.version.pin();
let version = table.version.pin();
Copy link
Member

Choose a reason for hiding this comment

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

Should store version inside txn struct, otherwise it will get immediately unpinned once txn is created.

@skyzh
Copy link
Member

skyzh commented Aug 25, 2022

solved by #685

@skyzh skyzh closed this Aug 25, 2022
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.

storage: use object to pin and unpin version
2 participants