-
Notifications
You must be signed in to change notification settings - Fork 4
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
Conversation
@@ -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. |
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.
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?
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.
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): |
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's in-memory check right?
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.
get_root_hash
is not in-memory, but we should cache the version information in NodeDB.
closing, not an issue, see: cosmos/iavl#641 (comment) |
thanks @cool-develope find the issue.