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

Re: LMDB persistent snapshots



Michael Conrad wrote:
Hi, I'm scoping out my options for databases that support snapshotting.  From what I've read so far, this is a natural feature of LMDB,

Not really. The persistent state only records the 2 most recent transactions.

however all the documentation talks about making sure not to let read transactions linger around.  What if I *want* to hold onto a read transaction long-term, hours or even months?

You should probably use the mdb_copy interface to just make a copy of that snapshot.

 Also, I haven't yet seen a way for a new client to re-open the database as of the point in time of an existing transaction.  Is this possible?

See above, only the 2 most recent transactions' metadata is preserved. So in general, no.

If I manage to do something like this, will the storage overhead be roughly equivalent to the quantity of changed data between the snapshot and the latest write? or will the overhead be more like the sum of all writes + overwrites that happened since the read transaction started?  i.e. if a read transaction is held starting from t0, then data is written at t1, then overwritten at t2 can the blocks affected by t1 be reclaimed for a write at t3?

No. For any read transaction started at time t, only old pages up to t-2 can be reclaimed. Once they're all consumed, only new pages will be used, for as long as that txn stays open.

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