Issue 8582 - LMDB lockfile/mutex arch dependency
Summary: LMDB lockfile/mutex arch dependency
Status: IN_PROGRESS
Alias: None
Product: LMDB
Classification: Unclassified
Component: liblmdb (show other issues)
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-06 15:07 UTC by Howard Chu
Modified: 2020-03-12 15:56 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Howard Chu 2017-02-06 15:07:38 UTC
Full_Name: Howard Chu
Version: HEAD
OS: Linux
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (195.235.15.200)
Submitted by: hyc


I ran into some corruption problems when running a 64bit LMDB process concurrent
with a 32bit one using MDB_VL32. While LMDB's own structures are all 64bit clean
in a VL32 build, unfortunately pthread_mutex_t structures are not. In
particular, in glibc a pthread_mutex_t can be one of 3 different sizes - 24
bytes for 32bit runtime on 32bit processor, 32 bytes for 32bit runtime on
x86-64, and 40 bytes for 64bit runtime on x86-64. As such, we cannot safely
share an LMDB environment between 32 and 64bit Linux processes, even when using
MDB_VL32.

This problem doesn't affect Windows, platforms using SysV semaphores, or
platforms using POSIX named semaphores. I don't currently know whether this is a
problem on other platforms that support POSIX process-shared mutexes.


Hallvard has suggested that we add some additional LOCK_FORMAT bits to protect
against incompatible accesses. This would primarily be useful for the mdb_stat
command, which can still safely retrieve some useful information from an
environment without acquiring any mutexes. E.g., an MDB_VL32 build of mdb_stat
could retrieve most envinfo, statinfo, and readerinfo from a running 64bit
environment. It could not scan the freelist, scan all the names of named DBs, or
clean the reader list, since these operations all require taking the reader
mutex.
Comment 1 Howard Chu 2017-02-07 20:46:47 UTC
changed state Open to Active
moved from Incoming to Software Bugs
Comment 2 Howard Chu 2017-02-09 14:13:37 UTC
hyc@openldap.org wrote:
> Full_Name: Howard Chu
> Version: HEAD
> OS: Linux
> URL: ftp://ftp.openldap.org/incoming/
> Submission from: (NULL) (195.235.15.200)
> Submitted by: hyc
>
>
> I ran into some corruption problems when running a 64bit LMDB process concurrent
> with a 32bit one using MDB_VL32. While LMDB's own structures are all 64bit clean
> in a VL32 build, unfortunately pthread_mutex_t structures are not. In
> particular, in glibc a pthread_mutex_t can be one of 3 different sizes - 24
> bytes for 32bit runtime on 32bit processor, 32 bytes for 32bit runtime on
> x86-64, and 40 bytes for 64bit runtime on x86-64. As such, we cannot safely
> share an LMDB environment between 32 and 64bit Linux processes, even when using
> MDB_VL32.
>
> This problem doesn't affect Windows, platforms using SysV semaphores, or
> platforms using POSIX named semaphores. I don't currently know whether this is a
> problem on other platforms that support POSIX process-shared mutexes.

For glibc, I've submitted an enhancement request regarding mutex sizes:

https://sourceware.org/bugzilla/show_bug.cgi?id=21119

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