[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: (ITS#7789) Unreliable mdb_env_set_mapsize()
h.b.furuseth@usit.uio.no wrote:
> Another problem:
>
> With an MDB_RDONLY environment on Windows, env->me_mapsize
> does not seem to affect the actual map size or vice versa.
> mdb_env_map() does
> /* Don't set explicit map size, use whatever exists */
>
> If the user sets a mapsize bigger than the current file,
That is impossible on Windows. The OS will not allow a mapsize bigger than the
filesize.
> and another process resizes the map and grows the DB into
> the new size, then the RDONLY process will not discover
> in mdb_txn_renew0() that its map is too small.
>
> If there is a technical reason for the current behavior,
That change was made to accomodate opening of an mdb_copy'd DB file in
read-only mode. Since mdb_copy only copies the used pages, the resulting file
will be smaller than the configured mapsize. If you attempt to map this file
as-is with the configured mapsize, it will fail. You would have to resize the
file, but since the env is opened read-only, you should not make any such
change to the file.
We could alternatively change mdb_copy to explicitly set the filesize to match
the mapsize at the end of the copy, and then this particular hack wouldn't be
needed.
> maybe it could create the full map (for the address space)
> but record the smaller mapped size in MDB_env, and then
> mdb_txn_renew0 could do some mutex-protected magic to
> map in the new file segment if the file grew. That
> should avoid surprising the user.
--
-- Howard Chu
CTO, Symas Corp. http://www.symas.com
Director, Highland Sun http://highlandsun.com/hyc/
Chief Architect, OpenLDAP http://www.openldap.org/project/