Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fix 'MDB_MAP_FULL: Environment mapsize limit reached' in macOS homebrew LMDB installation [PHP7]

By default in PHP 7.3.11 lmdb database size is fixed by 1MB and no way to change it. Bug about it: https://bugs.php.net/bug.php?id=78808

This gist provide hotfix for this behaviour. (But it may be easier to create databases in python or from another lib?)

brew uninstall --ignore-dependencies lmdb
brew update
patch /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/lmdb.rb < patch-brew-lmdb.rb
brew install --build-from-source lmdb

Reinstall php if it not helped.

PS: this patch also raises database readers for better use in multi-threaded mode (but readers can also be increased by changing the environment variable MDB_READERS_FULL)

16a17,18
> patch :DATA
>
28a31,55
>
> __END__
> diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c
> index 692feaa..809ab9e 100644
> --- a/libraries/liblmdb/mdb.c
> +++ b/libraries/liblmdb/mdb.c
> @@ -612,7 +612,7 @@ typedef uint16_t indx_t;
> * This is certainly too small for any actual applications. Apps should always set
> * the size explicitly using #mdb_env_set_mapsize().
> */
> -#define DEFAULT_MAPSIZE 1048576
> +#define DEFAULT_MAPSIZE 1048576000
>
> /** @defgroup readers Reader Lock Table
> * Readers don't acquire any locks for their data access. Instead, they
> @@ -658,7 +658,7 @@ typedef uint16_t indx_t;
> * couple mutexes fit exactly into 8KB on my development machine.
> * Applications should set the table size using #mdb_env_set_maxreaders().
> */
> -#define DEFAULT_READERS 126
> +#define DEFAULT_READERS 1024
>
> /** The size of a CPU cache line in bytes. We want our lock structures
> * aligned to this size to avoid false cache line sharing in the
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.