Hello List,
The LMDB documentation says the following in its section on caveats:
- Use an MDB_env* in the process which opened it, without fork()ing.
- Do not have open an LMDB database twice in the same process at the same time. Not even from a plain open() call - close()ing it breaks flock() advisory locking.
This seems contrary to an earlier thread on this list (1), which suggests that fork/execing a process using LMDB is OK so long as the MDB_env is not used in the forked process. Looking at the flock man pages on FreeBSD and Linux tells me that this indeed should be ok: an flock is released only when all fds pointing to the open file table entry are closed (ignoring explicit unlock). Exec with FD_CLOEXEC set should therefore be OK.
Is my interpretation correct? I want to use this to implement graceful restarts in a daemon which uses LMDB:
* mdb_env_open() in old process * fork() -> exec() the daemon itself * mdb_env_open() in new process * mdb_env_close() in old process
If this works, I'd like to contribute the changes necessary to not leak fds on exec, which are mentioned in the other thread.
* Are there contribution guidelines somewhere? How do I submit a patch? * Seems like there is currently no call to SetHandleInformation with HANDLE_FLAG_INHERIT=0 for Winows, should that be added?
Best, Lorenz
1: http://www.openldap.org/lists/openldap-technical/201403/msg00149.html