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

Re: Question regarding MDB_NOLOCK



On 30/01/15 22:57, David Barbour wrote:
On Mon, Dec 1, 2014 at 6:55 AM, Hallvard Breien Furuseth
<h.b.furuseth@usit.uio.no <mailto:h.b.furuseth@usit.uio.no>> wrote:
(...)
    Last snapshot is never overwritten.  So readers which did begin/renew
    after latest commit(write txn) are safe from txn_begin(write txn).

    The same with the commit of the write txn before that.  I think.
    MDB keeps the last two snapshots in the metapages.

> I've been reading the MDB source code a bit more to verify this
assumption. It is not valid.

MDB does keep the last two metapages, but may begin to dismantle the
elder of the two for pages if there are no readers for it.

Yes, true.  The last two snapshots' *data pages* are never
overwritten, and any readers using them will have read the
metapage and do not need it again.

I confused myself because I was thinking of sync issues:
Even if the oldest metapage has been overwritten, that
does not mean it is gone yet: If it has not been synced
to disk, a system crash can bring it back.  And with it,
its refs to datapages.

Looking closer though, that's only relevant if with
MDB_NOSYNC, where the previous metapage has not been
synced either.