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

fix: pruning don't delete all orphaned nodes #8

Closed
wants to merge 1 commit into from

Conversation

yihuang
Copy link
Collaborator

@yihuang yihuang commented Dec 7, 2022

thanks @cool-develope find the issue.

@yihuang yihuang requested a review from mmsqe December 7, 2022 00:51
@@ -130,12 +130,16 @@ def delete_version(self, v: int) -> int:
from .diff import diff_tree

counter = 0
# optimize the case when deleting from the beginning,
# in that case, the previous version will always be 0.
Copy link

Choose a reason for hiding this comment

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

so we cant add test for case like version 2 node in version 5, deleted in version 7, del when more than 3 versions diff?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, we should have more tests for pruning.

prev_version = self.prev_version(v) or 0
root1 = self.get_root_node(v)
root2 = self.get_root_node(self.next_version(v))
for orphaned, _ in diff_tree(self.get, root1, root2):
for n in orphaned:
if n.version > prev_version:
if n.version > prev_version or not self.get_root_hash(n.version):
Copy link

Choose a reason for hiding this comment

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

it's in-memory check right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

get_root_hash is not in-memory, but we should cache the version information in NodeDB.

@yihuang
Copy link
Collaborator Author

yihuang commented Dec 7, 2022

closing, not an issue, see: cosmos/iavl#641 (comment)

@yihuang yihuang closed this Dec 7, 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.

2 participants