[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: LMDB: issue with mdb_cursor_del

Hi, Howard.

This is a bug (seems minor), I fixed it in the MDBX few days ago.

Inside freelist_save() the mt_loose_pages could be merged into the mt_free_pgs.

But at this point all loose_pages also still present in the mt_u.dirty_list.
On the next loop inside freelist_save() a one more page could be
requested, and page_alloc() could return a page which is already in
the mt_u.dirty_list.
In this case mdb_mid2l_insert() will return -1.

2017-10-16 13:51 GMT+03:00 Howard Chu <hyc@symas.com>:
> timur.kristof@gmail.com wrote:
>> Hi,
>> I have an app that uses LMDB, and I've experienced an interesting
>> issue: when trying to delete a certain item with mdb_cursor_del, it
>> crashed with the following backtrace: https://pastebin.com/7p9wtkj9
>> It appears that it couldn't mark a page as dirty.
>> Here is the relevant assertion from mdb_page_dirty:
>> rc = insert(txn->mt_u.dirty_list, &mid);
>> mdb_tassert(txn, rc == 0); // assertion failed
>> What might I be doing wrong in my application that triggers this sort
>> of error?
> Take a look at the value of rc, then look in midl.c. Most likely the dirty
> list is too big, which means you're trying to do too much in a single
> transaction.
>> Also interesting:
>> The database was about 60MB, and I now compacted it using mdb_copy -c.
>> Now it is only ~6MB, and running the app with the compacted database,
>> the above error also disappeared.
>> I'm not sure why the compacting fixed the problem, could somebody offer
>> an insight about this?
>> Thank you guys in advance for your answers!
>> Best regards,
>> Timur
> --
>   -- Howard Chu
>   CTO, Symas Corp.           http://www.symas.com
>   Director, Highland Sun     http://highlandsun.com/hyc/
>   Chief Architect, OpenLDAP  http://www.openldap.org/project/