[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (ITS#7651) LMDB: Uncontrolled database when opened from multiple processes



dimitrij.denissenko@blacksquaremedia.com wrote:
> Hi again,
>
> I was able to recreate the scenario in a test case. I must have mixed
> something up previously. After more tests it seems that the memory
> growth only appears when transactions are reset within the child.
>
> Here's the full code:
> https://gist.github.com/dim/6122131
>
> Output on my machine:
>
> $ rm -f testdb/* && mkdir -p testdb && make mtest8 && ./mtest8
> gcc -pthread -O2 -g -W -Wall -Wno-unused-parameter -Wbad-function-cast
> -c mtest8.c
> gcc -pthread -O2 -g -W -Wall -Wno-unused-parameter -Wbad-function-cast
> mtest8.o liblmdb.a  -o mtest8
> NO FORK     : 1699840
> FORK & OPEN : 1699840
> FORK & COPY : 6225920

This behavior is expected. Your child process is holding a read txn while it 
performs the env_copyfd(). During that time writers are not able to reuse old 
data pages, so all writes consume new pages. When the copyfd completes and 
releases its read txn the writers will resume reusing old pages.

There's no bug here, this ITS will be closed.

-- 
   -- Howard Chu
   CTO, Symas Corp.           http://www.symas.com
   Director, Highland Sun     http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP  http://www.openldap.org/project/