From: Robin Geuze Date: Thu, 17 Dec 2020 10:51:24 +0000 (+0100) Subject: Do a mdb_readers_check to clean up stale readers on database load X-Git-Tag: rec-4.5.0-alpha1~9^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F9888%2Fhead;p=thirdparty%2Fpdns.git Do a mdb_readers_check to clean up stale readers on database load --- diff --git a/ext/lmdb-safe/lmdb-safe.cc b/ext/lmdb-safe/lmdb-safe.cc index ccb090127a..7b968e20d6 100644 --- a/ext/lmdb-safe/lmdb-safe.cc +++ b/ext/lmdb-safe/lmdb-safe.cc @@ -46,6 +46,12 @@ Various other options may also need to be set before opening the handle, e.g. md mdb_env_close(d_env); throw std::runtime_error("Unable to open database file "+std::string(fname)+": " + MDBError(rc)); } + + if ((flags & MDB_RDONLY) == 0) { + // Check for stale readers to prevent unbridled database growth. + // Only do this when in RW mode since it affects the file. + mdb_reader_check(d_env, nullptr); + } } void MDBEnv::incROTX()