Hello,
I have a question about usage of the same lmdb database in different containers and in the host machine.
So far I just mapped lmdp file in docker-compose.yml:
volumes: - "/var/spool/lmdbenv/:/var/spool/lmdbenv/"
And I'm reading/writing to/from the database from different containers.
Everything seems to work at a first glance.
Example of adding an element to lmdb:
/usr/bin/python -mlmdb --env /var/spool/lmdbenv edit \ --set "client"="{ "client_ip" : "$client_ip", "client_data" : "$client_data" }"
Is it the proper use case for lmdb? Is there any special "flush" API which I have to use to make sure that the record inserted in one container becomes visible in another?
Thanks in advance!
-- WBR & WBW, Vitaly
Vitaly Repin wrote:
Hello,
I have a question about usage of the same lmdb database in different containers and in the host machine.
So far I just mapped lmdp file in docker-compose.yml:
volumes: - "/var/spool/lmdbenv/:/var/spool/lmdbenv/"
And I'm reading/writing to/from the database from different containers.
Everything seems to work at a first glance.
Example of adding an element to lmdb:
/usr/bin/python -mlmdb --env /var/spool/lmdbenv edit \ --set "client"="{ "client_ip" : "$client_ip", "client_data" : "$client_data" }"
Is it the proper use case for lmdb? Is there any special "flush" API which I have to use to make sure that the record inserted in one container becomes visible in another?
LMDB requires every process using it to have a unique PID. Usually containers all run their job as PID number 1, you'll have to make sure they all use unique PIDs.
Thanks in advance!
-- WBR & WBW, Vitaly
Hello,
Thanks! This is very interesting.
Could you point me to the lmdb source files which uses this assumption?
Is it mdb_reader_pid() function in mdb.c ?
Do I interpret it correctly that only the processes which access the database simultaniously have to have different pids? And it means that if I wrap lmdb operations with file locks (using flock) then the data will be consistent (but performance would degrade) ?
Den sön 20 aug. 2023 kl 21:56 skrev Howard Chu hyc@symas.com:
Is it the proper use case for lmdb? Is there any special "flush" API
which I have to use to make sure that the record inserted in one container becomes visible
in another?
LMDB requires every process using it to have a unique PID. Usually
containers all run their job as PID number 1, you'll have to make sure
they all use unique PIDs.
-- WBR & WBW, Vitaly
openldap-technical@openldap.org