On Wed, 2017-10-18 at 06:18 +0200, Hallvard Breien Furuseth wrote:
On 16/10/17 14:56, Hallvard Breien Furuseth wrote:
On 16. okt. 2017 13:43, Леонид Юрьев wrote:
(...) Inside freelist_save() the mt_loose_pages could be merged into the mt_free_pgs. http://www.openldap.org/devel/gitweb.cgi?p=openldap.git;a=blob;f= libraries/liblmdb/mdb.c;h=1bf81ed4c87901991b7cac885b0d8cbc4dd2343 6;hb=bb8502f08800a44a6b91a94d6478aa7101c4cc77#l3444
But at this point all loose_pages also still present in the mt_u.dirty_list. (...)
I don't understand you. page_alloc doesn't call mdb_mid2l_insert() for loose pages, since they are in dirty_list.
Duh, never mind, I was reading your explanation backwards.
So, when freelist_save() returns loose pages to mt_free_pgs(), you remove them from mt_u.dirty_list and update dirty_room. OK.
Howard, I accidentally suggested a different fix to this recently. Maybe in LMDB 1.0 we should switch to this:
Set INITIAL_TXNID > 2, so freelist_save() always has an unused freeDB key < txnid which it can back up to. Now allow ovpage_free() and freelist_save() to create me_pghead. That means finding a nonzero value to set me_pglast to as well, or removing the assumtion that me_phead == NULL if me_pglast == 0.
Discussed on irc on Aug 10 and rejected, but it may be cleaner after all - freelist_save() can quit messing with loose pages instead of adding to the code which does that. Unless we also rejected it because it wouldn't work:-)
Maybe mdb_page_dirty could be allowed to simply accept -1 as a return value from insert() and that could fix it? Since the page is already listed in the txn's dirty list, it shouldn't really matter. Or am I misunderstanding the consequences of this?