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
dba: lmdb: allow to override the MDB_NOSUBDIR flag #8856
This is a problem for interoperability when sharing a single LMDB database between multiple programs written in different languages. LMDB itself defaults to using a subdirectory as a database, and will create two files data.mdb and lock.mdb in this directory. When using PHP, one has to open subdir/data.mdb explicitly, but now the PHP code will use subdir/data.mdb-lock instead of subdir/lock.mdb as a lock file, leading to two separate lock files when using different codebases:
host ~/test (master) # ls -l pkg.db
total 156K
-rw------- 1 root root 148K Jun 22 16:49 data.mdb
-rw------- 1 root root 8.0K Jun 23 19:30 lock.mdb
-rw-r--r-- 1 root root 8.0K Jun 22 18:49 data.mdb-lock
Currently, the only way to work around this issue is by changing all other codebases to use MDB_NOSUBDIR too because there is no way to disable it in PHP.
Hm, apparently there's also no way to open the environment with MDB_RDONLY, which causes a significant overhead when opening the environment just to read a key. In my Perl, Python and Rust implementations, enabling readonly increases the speed from ~150us to ~50us, but my PHP implementation is stuck at ~150us. Maybe it would be sensible to expose flags and the required constants completely?
I'm trying to determine what flags would be useful to support, and I'm currently thinking of just including MDB_NOSUBDIR (and probably a custom PHP constant MDB_USE_SUB_DIR) as the other ones don't seem that relevant
Activity
martinvonwittich commentedon Jun 23, 2022
Hm, apparently there's also no way to open the environment with
MDB_RDONLY, which causes a significant overhead when opening the environment just to read a key. In my Perl, Python and Rust implementations, enabling readonly increases the speed from ~150us to ~50us, but my PHP implementation is stuck at ~150us. Maybe it would be sensible to expose flags and the required constants completely?cmb69 commentedon Jun 24, 2022
Looks like a reasonable improvement; users should be able to at least specify some of the flags which are passed to
mdb_env_open(). PR welcome!Girgias commentedon Jun 29, 2022
I'm trying to determine what flags would be useful to support, and I'm currently thinking of just including MDB_NOSUBDIR (and probably a custom PHP constant MDB_USE_SUB_DIR) as the other ones don't seem that relevant
cmb69 commentedon Jun 29, 2022
Well,
MDB_RDONLYhas been requested here, and I think it may make sense to support that.Girgias commentedon Jun 29, 2022
This should be passed when the
"r"mode is passed todba_open()and I'm working on thatcmb69 commentedon Jun 29, 2022
Ah, right. It might make sense to set it automatically in that case.