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

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

2014-11-16 0:04 GMT+03:00 Hallvard Breien Furuseth <h.b.furuseth@usit.uio.no>:
> __sync_synchronize() needs an #ifdef around it.
> #ifdef __GNUC__, or something more general?
> Not sure what to do for the #else.  We could mostly
> avoid using mm_txnid when the lockfile is initialized
> and use mti_txnid instead (e.g. in pick_meta).  And
> penalize MDB_NOLOCK with some sync call in the #else.
> --
> Hallvard

Unfortunately IMDB programmed without accounting possibility of memory
reordering and cache incoherency (as a proof - the 'volatile' was
missed before ITS#7969).
So, currently seems LMDB is durable only on x86 and may be on MIPS.

I think memory-ordering (e.g. barriers) functions should be defined in
separate h-file, which will select implementation depends on cpu-arch
& compiler.
see http://en.wikipedia.org/wiki/Memory_ordering

The minimum seems to be required a memory_barrier_coherence() - to
make cache coherence and suppress dangerously load/store reordering,
e.g. flush/invalidate cache on some cpu-arch, but do nothing on x86
and so on.
Then __sync_synchronize() and MIPS's cache invalidate should be
replaced with memory_barrier_coherence().

But instead the original version recreate cleanly on the basis of
1Hippeus engine (manager of shared memory and queues for zero-copy
IPC, google it).