Badger: MergeOperator is merging the appended values with the previous existing value even if it is deleted (i.e marked for deletion)

  1. I created a new key using GetMergeOperator() and then added values to it (my add function appends the values together). Finally, doing an m.Stop().
  2. After that, I deleted that merged value using txn.Delete().
  3. Then, I did a GetMergeOperator for the key again and appended some new set of values.
  4. Now, if I do a Get on that key, I expect to see only the new set of values merged (from step #3 above) . But, MergeOperator ends up merging the old value (which was created in step #1 and deleted in step #2) also along with new set of values.

GitHub Gist of my test code - testbadger.go · GitHub

Am I misunderstanding something about how merge operators are supposed to be used?

Can someone please clarify on this?

This looks like a bug. Thanks @sathishweb , for reporting this. Should be fixed by fix(merge-operator): don't read the deleted keys by NamanJain8 · Pull Request #1675 · dgraph-io/badger · GitHub

1 Like

Thank you, Naman.

1 Like