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

(ITS#7969) LMDB: Globally shared fields of meta-data are not 'volatile'.



Full_Name: Leonid Yuriev
Version: 2.4.40
OS: RHEL7
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (31.130.36.33)


Several fields from the meta-data that shared globally across active writer and
all readers are not 'volatile'. This allow compiler to cache its values in
registers and reorder writes.

More over, in some cases compiler is free to eliminate the calls of function
which seems to be 'const' or 'pure', pls see http://lwn.net/Articles/285332/. 

Thereby a series of  Heisenbugs may be induced, for instance:

1) The mdb_find_oldest() calls may be potentially eliminated up to public (not
static) functions due to interprocedural optimization 'unit at once'.

2) Reordering of CPU instructions which updates the txn in a meta-page. Without
"volatile" or memory-barrier compiler may reorder instructions for update the
"mm_txnid" field in meta-page in "writemap" mode.
    
Thereby,  from the reader's point of view this cause a short time interval when
the transaction is corrupted.

On some architectures few actions are required for cache coherence, for instance
- GCC's __synchronize() must be called.

3) A really critical bugs will be described later in separate ITS.