seatgeek/soulmate — Issue #16: Loader::remove can cause orphaned keys
Author: erwaller
Created: 2011-12-12 19:23:07+00:00
State: open

Add some items to the index:

$ echo '{"id":1, "term":"bun"}' | soulmate add test
Adding items of type test...
Loaded a total of 1 items
$ echo '{"id":2, "term":"buy"}' | soulmate add test
Adding items of type test...
Loaded a total of 1 items

redis> KEYS *
1) "soulmate-data:test"
2) "soulmate-index:test:buy"
3) "soulmate-index:test:bun"
4) "soulmate-index:test"
5) "soulmate-index:test:bu"

Remove one of those items:

$ echo '{"id":2, "term":"buy"}' | soulmate remove test
Removing items of type test...
Removed a total of 1 items

redis> KEYS *
1) "soulmate-data:test"
2) "soulmate-index:test:bun"
3) "soulmate-index:test"
4) "soulmate-index:test:bu"

Recreate the collection:

$ echo '{"id":2, "term":"eat"}' | soulmate load test
Loading items of type test...
Loaded a total of 1 items

redis> KEYS *
1) "soulmate-data:test"
2) "soulmate-index:test:eat"
3) "soulmate-index:test:ea"
4) "soulmate-index:test"
5) "soulmate-index:test:bu"

The key `soulmate-index:test:bu` was orphaned by the removal of `buy`.