From 79dc3472276f3cf05e39c65a2f8b2a076a014105 Mon Sep 17 00:00:00 2001 From: Robin Geuze Date: Thu, 17 Dec 2020 11:51:24 +0100 Subject: [PATCH] Do a mdb_readers_check to clean up stale readers on database load --- ext/lmdb-safe/lmdb-safe.cc | 6 ++++++ 1 file changed, 6 insertions(+) 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() -- 2.47.2