summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-01-03 18:49:36 +0100
committerChristoph M. Becker <cmbecker69@gmx.de>2020-01-03 18:51:07 +0100
commitf4aa0869acfd871f780ecf378f84f68a4755267e (patch)
tree26132b9ad3340453564b10123f2b7ca7813779c0
parent4c6ad099c649b81d03a6593009565ecbd447ea10 (diff)
parentc05a069adfcca56763d5db06afce8801382477a5 (diff)
downloadphp-git-f4aa0869acfd871f780ecf378f84f68a4755267e.tar.gz
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #78808: [LMDB] MDB_MAP_FULL: Environment mapsize limit reached
-rw-r--r--NEWS4
-rw-r--r--UPGRADING6
-rw-r--r--ext/dba/dba_lmdb.c16
-rw-r--r--ext/dba/tests/bug78808.phpt25
4 files changed, 51 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 87af6d1e0b..c4151a45ea 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,10 @@ PHP NEWS
- Date:
. Fixed bug #79015 (undefined-behavior in php_date.c). (cmb)
+- DBA:
+ . Fixed bug #78808 ([LMDB] MDB_MAP_FULL: Environment mapsize limit reached).
+ (cmb)
+
- Exif:
. Fixed bug #79046 (NaN to int cast undefined behavior in exif). (Nikita)
diff --git a/UPGRADING b/UPGRADING
index 8b83163da9..ccaa6fae44 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -563,6 +563,12 @@ PHP 7.4 UPGRADE NOTES
9. Other Changes to Extensions
========================================
+ DBA:
+ . As of PHP 7.4.2, dba_open() accepts a fifth optional parameter for lmdb
+ databases which allows to specify the mapsize. The parameter defaults to
+ zero, in which case the compiled in default mapsize (usually 1048576) will
+ be used. The mapsize should be a multiple of the page size of the OS.
+
- GD:
. The behavior of imagecropauto() in the bundled libgd has been synced with
that of system libgd:
diff --git a/ext/dba/dba_lmdb.c b/ext/dba/dba_lmdb.c
index 4bc085177d..ea8784bcb1 100644
--- a/ext/dba/dba_lmdb.c
+++ b/ext/dba/dba_lmdb.c
@@ -43,10 +43,18 @@ DBA_OPEN_FUNC(lmdb)
MDB_env *env;
MDB_txn *txn;
int rc, mode = 0644, flags = MDB_NOSUBDIR;
+ zend_long mapsize = 0;
if(info->argc > 0) {
mode = zval_get_long(&info->argv[0]);
+ if (info->argc > 1) {
+ mapsize = zval_get_long(&info->argv[1]);
+ if (mapsize < 0) {
+ *error = "mapsize must be greater than or equal to zero";
+ return FAILURE;
+ }
+ }
/* TODO implement handling of the additional flags. */
}
@@ -56,6 +64,14 @@ DBA_OPEN_FUNC(lmdb)
return FAILURE;
}
+ if (mapsize > 0) {
+ rc = mdb_env_set_mapsize(env, (size_t) mapsize);
+ if (rc) {
+ *error = mdb_strerror(rc);
+ return FAILURE;
+ }
+ }
+
rc = mdb_env_open(env, info->path, flags, mode);
if (rc) {
*error = mdb_strerror(rc);
diff --git a/ext/dba/tests/bug78808.phpt b/ext/dba/tests/bug78808.phpt
new file mode 100644
index 0000000000..9aa4e22a32
--- /dev/null
+++ b/ext/dba/tests/bug78808.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #78808 ([LMDB] MDB_MAP_FULL: Environment mapsize limit reached)
+--SKIPIF--
+<?php
+if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
+$handler = 'lmdb';
+require_once __DIR__ .'/skipif.inc';
+?>
+--FILE--
+<?php
+$handler = 'lmdb';
+require_once __DIR__ .'/test.inc';
+$lmdb_h = dba_open($db_filename, 'c', 'lmdb', 0644, 5*1048576);
+for ($i = 0; $i < 50000; $i++) {
+ dba_insert('key' . $i, 'value '. $i, $lmdb_h);
+}
+dba_close($lmdb_h);
+echo "done\n";
+?>
+--EXPECT--
+done
+--CLEAN--
+<?php
+require_once dirname(__FILE__) .'/clean.inc';
+?>