From 0c4c6fe72a57f812e4486cd017298f730df19c23 Mon Sep 17 00:00:00 2001
From: Howard Chu <hyc@symas.com>
Date: Thu, 27 Sep 2012 05:01:53 -0700
Subject: [PATCH] ITS#7385, check further for bad splits

More for 48ef27b6f5c804eca6a9d27f8dd2b4ded376f8af
Our definition of "large" data item needs to be smaller to
handle more cases where a bad split is possible
---
 libraries/libmdb/mdb.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/libraries/libmdb/mdb.c b/libraries/libmdb/mdb.c
index 807294c28d..d15fa7c8a7 100644
--- a/libraries/libmdb/mdb.c
+++ b/libraries/libmdb/mdb.c
@@ -6117,15 +6117,19 @@ mdb_page_split(MDB_cursor *mc, MDB_val *newkey, MDB_val *newdata, pgno_t newpgno
 	 * This check is only needed when the data items are
 	 * relatively large, such that being off by one will
 	 * make the difference between success or failure.
-	 * When the size of the data items is much smaller than
-	 * one-half of a page, this check is irrelevant.
+	 *
+	 * It's also relevant if a page happens to be laid out
+	 * such that one half of its nodes are all "small" and
+	 * the other half of its nodes are "large." If the new
+	 * item is also "large" and falls on the half with
+	 * "large" nodes, it also may not fit.
 	 */
 	if (IS_LEAF(mp)) {
 		unsigned int psize, nsize;
 		/* Maximum free space in an empty page */
 		pmax = mc->mc_txn->mt_env->me_psize - PAGEHDRSZ;
 		nsize = mdb_leaf_size(mc->mc_txn->mt_env, newkey, newdata);
-		if ((nkeys < 20) || (nsize > pmax/4)) {
+		if ((nkeys < 20) || (nsize > pmax/16)) {
 			if (newindx <= split_indx) {
 				psize = nsize;
 				newpos = 0;
-- 
GitLab