Skip to content
This repository has been archived by the owner on Mar 9, 2019. It is now read-only.

Fix rebalance bug #539

Merged
merged 1 commit into from
Mar 22, 2016
Merged

Fix rebalance bug #539

merged 1 commit into from
Mar 22, 2016

Conversation

benbjohnson
Copy link
Member

Overview

This commit fixes a rare issue where a page can become accessible when it has already been freed. This occurs when the first two child pages of a parent both have deletions and the first page
has 1 remaining children and the second page has 2 remaining children. During rebalancing the first page pulls an element from the second page and then the second page pulls the same element back from the first. The child page was not being freed properly.

I resolved this issue by removing this part of the rebalancing.

I made this choice for two reasons:

  1. Moving a single item between pages has negligible benefit. The page will eventually be cleaned up when it reaches zero elements.
  2. This is an infrequently executed branch of code which increases the likelihood of bugs occurring and it makes it more difficult to test properly.

Fixes #348

This commit fixes a rare issue where a page can become accessible
when it has already been freed. This occurs when the first two
child pages of a parent both have deletions and the first page
has 1 remaining children and the second page has 2 remaining
children. During rebalancing the first page pulls an element from
the second page and then the second page pulls the same element
back from the first. The child page was not being freed properly.

I resolved this issue by removing this part of the rebalancing.
I made this choice for two reasons:

1. Moving a single item between pages has negligible benefit. The
   page will eventually be cleaned up when it reaches zero elements.

2. This is an infrequently executed branch of code which increases
   the likelihood of bugs occurring and it makes it more difficult
   to test properly.

Fixes boltdb#348
@DavidVorick
Copy link

+1 for removing code. Though it's not my project, I do prefer the philosophy of correctness over optimization. Given sufficient testing, you can have both, but time is valuable and sometimes it's not worth the effort.

@benbjohnson
Copy link
Member Author

@DavidVorick Agreed! There are few things in this world that I enjoy more than +0 PRs. :)

@xiang90
Copy link
Contributor

xiang90 commented Mar 21, 2016

LGTM. Can we do a release after this fix?

@benbjohnson
Copy link
Member Author

@xiang90 Yep. I'll tag it as v1.2.0. There's been enough changed between this and CoreOS's PRs that it probably warrants a minor release rather than a patch release.

benbjohnson added a commit that referenced this pull request Mar 22, 2016
@benbjohnson benbjohnson merged commit 6204c54 into boltdb:master Mar 22, 2016
@benbjohnson benbjohnson deleted the rebalance-fix branch March 22, 2016 03:40
@benbjohnson
Copy link
Member Author

@xiang90
Copy link
Contributor

xiang90 commented Mar 22, 2016

@benbjohnson Awesome! Thank you so much.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

panic: page 87 already freed
3 participants