mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-24 16:49:39 -05:00
Merge remote branch 'origin/mdb.master'
This commit is contained in:
commit
40477fae4e
1 changed files with 34 additions and 12 deletions
|
|
@ -227,17 +227,17 @@ typedef ID txnid_t;
|
|||
/** @defgroup debug Debug Macros
|
||||
* @{
|
||||
*/
|
||||
#ifndef DEBUG
|
||||
#ifndef MDB_DEBUG
|
||||
/** Enable debug output.
|
||||
* Set this to 1 for copious tracing. Set to 2 to add dumps of all IDLs
|
||||
* read from and written to the database (used for free space management).
|
||||
*/
|
||||
#define DEBUG 0
|
||||
#define MDB_DEBUG 0
|
||||
#endif
|
||||
|
||||
#if !(__STDC_VERSION__ >= 199901L || defined(__GNUC__))
|
||||
# define DPRINTF (void) /* Vararg macros may be unsupported */
|
||||
#elif DEBUG
|
||||
#elif MDB_DEBUG
|
||||
/** Print a debug message with printf formatting. */
|
||||
# define DPRINTF(fmt, ...) /**< Requires 2 or more args */ \
|
||||
fprintf(stderr, "%s:%d " fmt "\n", __func__, __LINE__, __VA_ARGS__)
|
||||
|
|
@ -294,7 +294,7 @@ typedef ID txnid_t;
|
|||
*/
|
||||
#define MAXKEYSIZE 511
|
||||
|
||||
#if DEBUG
|
||||
#if MDB_DEBUG
|
||||
/** A key buffer.
|
||||
* @ingroup debug
|
||||
* This is used for printing a hex dump of a key's contents.
|
||||
|
|
@ -1020,7 +1020,7 @@ mdb_strerror(int err)
|
|||
return strerror(err);
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
#if MDB_DEBUG
|
||||
/** Display a key in hexadecimal and return the address of the result.
|
||||
* @param[in] key the key to display
|
||||
* @param[in] buf the buffer to write into. Should always be #DKBUF.
|
||||
|
|
@ -1133,7 +1133,7 @@ mdb_page_alloc(MDB_cursor *mc, int num)
|
|||
txn->mt_env->me_pghead = mop;
|
||||
memcpy(mop->mo_pages, idl, MDB_IDL_SIZEOF(idl));
|
||||
|
||||
#if DEBUG > 1
|
||||
#if MDB_DEBUG > 1
|
||||
{
|
||||
unsigned int i;
|
||||
DPRINTF("IDL read txn %zu root %zu num %zu",
|
||||
|
|
@ -1777,7 +1777,7 @@ mdb_txn_commit(MDB_txn *txn)
|
|||
mdb_page_search(&mc, &key, 1);
|
||||
|
||||
mdb_midl_sort(txn->mt_free_pgs);
|
||||
#if DEBUG > 1
|
||||
#if MDB_DEBUG > 1
|
||||
{
|
||||
unsigned int i;
|
||||
ID *idl = txn->mt_free_pgs;
|
||||
|
|
@ -2959,9 +2959,15 @@ mdb_node_search(MDB_cursor *mc, MDB_val *key, int *exactp)
|
|||
|
||||
nkeys = NUMKEYS(mp);
|
||||
|
||||
#if DEBUG
|
||||
{
|
||||
pgno_t pgno;
|
||||
COPY_PGNO(pgno, mp->mp_pgno);
|
||||
DPRINTF("searching %u keys in %s %spage %zu",
|
||||
nkeys, IS_LEAF(mp) ? "leaf" : "branch", IS_SUBP(mp) ? "sub-" : "",
|
||||
mp->mp_pgno);
|
||||
pgno);
|
||||
}
|
||||
#endif
|
||||
|
||||
assert(nkeys > 0);
|
||||
|
||||
|
|
@ -3004,7 +3010,7 @@ mdb_node_search(MDB_cursor *mc, MDB_val *key, int *exactp)
|
|||
nodekey.mv_data = NODEKEY(node);
|
||||
|
||||
rc = cmp(key, &nodekey);
|
||||
#if DEBUG
|
||||
#if MDB_DEBUG
|
||||
if (IS_LEAF(mp))
|
||||
DPRINTF("found leaf index %u [%s], rc = %i",
|
||||
i, DKEY(&nodekey), rc);
|
||||
|
|
@ -4515,8 +4521,14 @@ mdb_node_del(MDB_page *mp, indx_t indx, int ksize)
|
|||
MDB_node *node;
|
||||
char *base;
|
||||
|
||||
#if DEBUG
|
||||
{
|
||||
pgno_t pgno;
|
||||
COPY_PGNO(pgno, mp->mp_pgno);
|
||||
DPRINTF("delete node %u on %s page %zu", indx,
|
||||
IS_LEAF(mp) ? "leaf" : "branch", mp->mp_pgno);
|
||||
IS_LEAF(mp) ? "leaf" : "branch", pgno);
|
||||
}
|
||||
#endif
|
||||
assert(indx < NUMKEYS(mp));
|
||||
|
||||
if (IS_LEAF2(mp)) {
|
||||
|
|
@ -5111,13 +5123,23 @@ mdb_rebalance(MDB_cursor *mc)
|
|||
unsigned int ptop;
|
||||
MDB_cursor mn;
|
||||
|
||||
#if DEBUG
|
||||
{
|
||||
pgno_t pgno;
|
||||
COPY_PGNO(pgno, mc->mc_pg[mc->mc_top]->mp_pgno);
|
||||
DPRINTF("rebalancing %s page %zu (has %u keys, %.1f%% full)",
|
||||
IS_LEAF(mc->mc_pg[mc->mc_top]) ? "leaf" : "branch",
|
||||
mc->mc_pg[mc->mc_top]->mp_pgno, NUMKEYS(mc->mc_pg[mc->mc_top]), (float)PAGEFILL(mc->mc_txn->mt_env, mc->mc_pg[mc->mc_top]) / 10);
|
||||
pgno, NUMKEYS(mc->mc_pg[mc->mc_top]), (float)PAGEFILL(mc->mc_txn->mt_env, mc->mc_pg[mc->mc_top]) / 10);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (PAGEFILL(mc->mc_txn->mt_env, mc->mc_pg[mc->mc_top]) >= FILL_THRESHOLD) {
|
||||
#if DEBUG
|
||||
pgno_t pgno;
|
||||
COPY_PGNO(pgno, mc->mc_pg[mc->mc_top]->mp_pgno);
|
||||
DPRINTF("no need to rebalance page %zu, above fill threshold",
|
||||
mc->mc_pg[mc->mc_top]->mp_pgno);
|
||||
pgno);
|
||||
#endif
|
||||
return MDB_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue