You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rescanning databases keeps a stale LMDB environment after its .mdb is removed or replaced #4041
On the LMDB engine, a database rescan (getDatabases() in resources/databases.ts) keeps using an environment it already opened, even after that database's .mdb file was removed or replaced on disk. readMetaDb takes lmdbDatabaseEnvs.get(path) when one is cached, so later loads read (and write) through the old environment, which still points at the unlinked file.
The sweep that should have marked those environments for deletion never worked: it iterated Object.values(lmdbDatabaseEnvs), but lmdbDatabaseEnvs is a Map, so the loop body never ran (since dcda017, 2025-07-11). #3920 removed that dead loop without changing behavior.
Impact
LMDB only (RocksDB, the v5 default, is not affected).
Needs the .mdb replaced or removed behind a running Harper, for example a manual file-level restore. Harper's own close paths (closeDatabase) delete the cached environment first.
Silent: reads keep returning the old data, and writes land in a file that is no longer reachable by name.
Fix sketch
On rescan, compare each cached environment's file identity (dev/inode) with the path on disk, and close and drop an environment whose file is gone or replaced, through the same close ordering closeDatabase uses (root once, never its dbis). A unit test replaces an open .mdb, rescans, and expects the new contents.
Activity