zlmdb._lmdb_vendor._envid¶
Identity of an environment’s files, for the “already open in this process” guard shared by the CPython and CFFI implementations.
LMDB forbids opening the same environment twice in one process: its locks are POSIX fcntl() locks, which belong to the (process, file) pair, so a second open silently shares the first one’s locks and closing it releases them. What must not be opened twice is therefore a file, not a path.
Keying on the path got this wrong in both directions. It refused an
environment that had been deleted and re-created at the same path while
the old one was still open, although the new files are unrelated to the
old ones (issue #491). And it missed the same files reached through two
different paths, such as a hard link to a subdir=False data file.
So an environment is identified by the (st_dev, st_ino) of its data
file and of its lock file. Both matter: deleting only the data file and
re-creating the environment would leave the new one sharing the old lock
file, whose reader table and fcntl locks belong to the environment still
open. Where a filesystem reports no inode number, as some do on Windows,
the resolved path stands in for it.