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

rax.h raxRemove recompression not working as expected (redirect from redis project) #29

Open
MEDSMEDS opened this issue Jul 4, 2020 · 0 comments

Comments

@MEDSMEDS
Copy link

MEDSMEDS commented Jul 4, 2020

in file rax.c, the comment within function raxRemove claims the following:

* Example of case "1". A tree stores the keys "FOO" = 1 and
     * "FOOBAR" = 2:
     *
     *
     * "FOO" -> "BAR" -> [] (2)
     *           (1)
     *
     * After the removal of "FOO" the tree can be compressed as:
     *
     * "FOOBAR" -> [] (2)
     *

However, the logic associated with variable trycompress didn't take compress node into account.
The two predicates if (h->size == 0) and else if (h->size == 1) don't catch the intermediate compress node obviously.

This demo shows the real scenario:

  1. insertion of key "foo", value 1.
  2. insertion of key "foobar", value 2.
  3. insertion of key "foobarzxc", value 3.
  4. deletion of key "foobarzxc".
  5. deletion of key "foobar".
// after 1/2/3
"foo" -> "bar"=0x7ffc7cbdb69c -> "zxc"=0x7ffc7cbdb64c -> []=0x7ffc7cbdb5fc
// after 4/5
"foo" -> "bar" -> "zxc" -> []=0x7ffc7cbdb5fc

Not "foobarzxc" -> []=0x7ffc7cbdb5fc as expected

Anyway, this only prolongs the recompression and no bug is incurred. @antirez

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

No branches or pull requests

1 participant