From: Howard Chu Date: Wed, 4 Jan 2012 23:25:18 +0000 (-0800) Subject: ITS#7121 fix page splits when data+key size is too large X-Git-Tag: OPENLDAP_REL_ENG_2_4_32~125^2~50 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a17f8e73265d5407e0a3f98ab79add0f839b997b;p=openldap ITS#7121 fix page splits when data+key size is too large --- diff --git a/libraries/libmdb/mdb.c b/libraries/libmdb/mdb.c index bec30d3e06..d953ef941a 100644 --- a/libraries/libmdb/mdb.c +++ b/libraries/libmdb/mdb.c @@ -4342,7 +4342,7 @@ mdb_leaf_size(MDB_env *env, MDB_val *key, MDB_val *data) size_t sz; sz = LEAFSIZE(key, data); - if (data->mv_size >= env->me_psize / MDB_MINKEYS) { + if (sz >= env->me_psize / MDB_MINKEYS) { /* put on overflow page */ sz -= data->mv_size - sizeof(pgno_t); } @@ -4435,11 +4435,11 @@ mdb_node_add(MDB_cursor *mc, indx_t indx, if (F_ISSET(flags, F_BIGDATA)) { /* Data already on overflow page. */ node_size += sizeof(pgno_t); - } else if (data->mv_size >= mc->mc_txn->mt_env->me_psize / MDB_MINKEYS) { + } else if (node_size + data->mv_size >= mc->mc_txn->mt_env->me_psize / MDB_MINKEYS) { int ovpages = OVPAGES(data->mv_size, mc->mc_txn->mt_env->me_psize); /* Put data on overflow page. */ - DPRINTF("data size is %zu, put on overflow page", - data->mv_size); + DPRINTF("data size is %zu, node would be %zu, put data on overflow page", + data->mv_size, node_size+data->mv_size); node_size += sizeof(pgno_t); if ((ofp = mdb_page_new(mc, P_OVERFLOW, ovpages)) == NULL) return ENOMEM;