From 0c4b39bd119dfe995f7a91195679615db35c7d02 Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Fri, 4 May 2018 17:22:59 +0300 Subject: [PATCH] mdbx: fix wrong freeDB search. Avoid search freeDB while tree is updating. Bug was inherited from LMDB. https://github.com/leo-yuriev/libmdbx/issues/31 --- mdb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mdb.c b/mdb.c index 43f95cb0..740ad00d 100644 --- a/mdb.c +++ b/mdb.c @@ -2140,6 +2140,10 @@ mdb_page_alloc(MDB_cursor *mc, int num, MDB_page **mp, int flags) /* If mc is updating the freeDB, then the freelist cannot play * catch-up with itself by growing while trying to save it. */ flags &= ~(MDBX_ALLOC_GC | MDBX_ALLOC_KICK | MDBX_COALESCE | MDBX_LIFORECLAIM); + } else if (unlikely(txn->mt_dbs[FREE_DBI].md_entries == 0)) { + /* avoid (recursive) search inside empty tree and while tree is updating, + * https://github.com/leo-yuriev/libmdbx/issues/31 */ + flags &= ~MDBX_ALLOC_GC; } }