From 632ffa0c575513e4980f509d7903bcaf45495b7a Mon Sep 17 00:00:00 2001 From: Kris Zyp Date: Fri, 26 Apr 2024 08:44:42 -0600 Subject: [PATCH] More careful about not doing anything but forward iteration while freelist entries are being deleted --- dependencies/lmdb/libraries/liblmdb/mdb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dependencies/lmdb/libraries/liblmdb/mdb.c b/dependencies/lmdb/libraries/liblmdb/mdb.c index 49c304948..0375b52c4 100644 --- a/dependencies/lmdb/libraries/liblmdb/mdb.c +++ b/dependencies/lmdb/libraries/liblmdb/mdb.c @@ -2856,6 +2856,7 @@ mdb_page_alloc(MDB_cursor *mc, int num, MDB_page **mp) load_more: if (op == MDB_SET_RANGE) { /* 1st iteration */ /* Prepare to fetch more and coalesce */ + if (env->me_freelist_state & MDB_FREELIST_DELETING) break; oldest = env->me_pgoldest; mdb_cursor_init(&m2, txn, FREE_DBI, NULL); #if (MDB_DEVEL) & 2 /* "& 2" so MDB_DEVEL=1 won't hide bugs breaking freeDB */ @@ -2926,6 +2927,7 @@ mdb_page_alloc(MDB_cursor *mc, int num, MDB_page **mp) if (last >= oldest || rc == MDB_NOTFOUND) { if (!rc) env->me_freelist_end = oldest; // no more newer transactions, go to the beginning of the range and look for older txns + if (env->me_freelist_state & MDB_FREELIST_DELETING) break; op = MDB_SET_RANGE; if (env->me_freelist_start <= 1) break; // should be no zero entry, break out last = env->me_freelist_start - 1;