[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: (ITS#8300) LMDB mdb_cursor_del data loss
Michael Alyn Miller wrote:
>>>> Another issue similar to ITS#8264 and ITS#8299, but this time using
>>>> mdb_cursor_del inside of the cursor causes corruption. mdb_del
>>>> causes corruption as well, but this is the first time that I have
>>>> seen mdb_cursor_del do the wrong thing.
>>>>
>>>> In this case, mdb_cursor_del incorrectly removes one extra key (a key
>>>> prefixed with 0c000000000000003a...) in addition to correctly
>>>> removing all of the keys that begin with 0d000000000000003a.
>>>>
>>>> mdb_del does not remove that extra key, but instead fails to remove
>>>> two 0d000000000000003a keys that should have been removed.
>>>>
>>>> I am not sure if these are two different bugs or if they are caused
>>>> by the same underlying issue.
>>>
>>> Similar reason, two different mistakes. Fixed now in git.
>>>>
>>>> mdb_cursor_del performs correctly on subsequent runs if you do *not*
>>>> remove the database between tests, whereas mdb_del continues to fail,
>>>> but stabilizes on a different set of results after the first run.
>>
>> For future reference, here's a patch to your test program that also checks for
>> cursors pointed adjacent to the item being deleted. The previous fix was
>> missing a step, fixed now. Note you must build LMDB with -DMDB_DEBUG
>> for the mdb_cursor_chk() function to be defined.
>
> Just to confirm, are you saying that this is something that I should
> include
only in the test harness, or should these checks be in my actual library as well?
That was primarily a note for *myself* or anyone who may need to research this
issue in the future. Building LMDB with -DMDB_DEBUG is something that we only
do for test/debug efforts, not something that any user code should ever worry
about.
So no, I was not saying there was any particular action you should take.
Merely an FYI on how I verified the fix.
> Thank you for taking the time to work through these bugs and address all
> of
the various edge cases. I really appreciate the help.
I stand behind my code.
> Michael Alyn Miller
>
--
-- Howard Chu
CTO, Symas Corp. http://www.symas.com
Director, Highland Sun http://highlandsun.com/hyc/
Chief Architect, OpenLDAP http://www.openldap.org/project/