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

Re: (ITS#7789) Unreliable mdb_env_set_mapsize()

On 09/07/14 04:19, hyc@symas.com wrote:
> Fixed now in mdb.master

I'm afraid it's broken worse now.

Splitting this ITS up in several component problems, copied in
part from IRC.

The recent fixes seem broken.  Mapsize is no longer checked against
the highest written page number.  And if one MDB_env shrinks the
mapsize, another co-existing MDB_env will not have MDB_RESIZING set,
so txn_renew0 will not return MDB_MAP_RESIZED nor will write_meta
resize the mapsize up again.  Thus it will run with a bigger mapsize
than the MDB_env which shrunk mapsize, and it can write pages beyond
what that other MDB_env has mapped.

I think LMDB 0.9.13 tried to implement this: mdb_env_set_mapsize() can
grow but not shrink the mapsize written to metapages.  lmdb writes the
biggest mapsize it ever saw, to the metapages.  But an MDB_env can run
with a smaller mapsize than the metapage says, as long as the
snapshots do not use pages beyond it.  So a metapage mapsize is just a

Seems a rule we can live with, but if so it should be documented.

However it did not and does not always write a new mapsize to both
metapages.  In LDMB 0.9.13, a fix would be for mdb_env_write_meta()
to always write mapsize = max(other metapage:mapsize, env:mapsize):

In current LMDB, it would be

I have not tested this against the test program in this ITS.
Getting late.