I encountered a problem trying to change the mapsize of an existing store.

It turned out to be that the newsize argument to mdb_env_map wasn't set correctly when coming from
mdb_env_open2.

So I had to change the call to be:
    rc = mdb_env_map(env, meta.mm_address, newenv || env->me_mapsize != meta.mm_mapsize);

(adding the || != test)

Also I had some issues with large files (4GB) and I made some small changes which better match documentation and reported issues, but not sure if the original code was flawed or not. It is in mdb_env_map when we set the file pointer and EOF:

    if (newsize) {
        if ((SetFilePointer(env->me_fd, sizelo, &sizehi, 0) == INVALID_SET_FILE_POINTER && GetLastError() != ERROR_SUCCESS)
            || !SetEndOfFile(env->me_fd)
            || (SetFilePointer(env->me_fd, 0, NULL, 0) == INVALID_SET_FILE_POINTER && GetLastError() != ERROR_SUCCESS))
            return ErrCode();
    }


Again, I made those changes according to what I noticed and this might not be the perfect final solution.

Cheers,
Alain