]> git.sur5r.net Git - openldap/commitdiff
Merge remote branch 'origin/mdb.master' into OPENLDAP_REL_ENG_2_4
authorQuanah Gibson-Mount <quanah@openldap.org>
Mon, 27 Aug 2012 21:55:30 +0000 (14:55 -0700)
committerQuanah Gibson-Mount <quanah@openldap.org>
Mon, 27 Aug 2012 21:55:30 +0000 (14:55 -0700)
libraries/libmdb/mdb.c

index f8211c60199dba43155e4dead2824bc866c784be..a2d0cd2e0ab0ddbe11439c1974a5b34271682dd5 100644 (file)
@@ -1107,17 +1107,18 @@ static void mdb_audit(MDB_txn *txn)
        mdb_cursor_init(&mc, txn, FREE_DBI, NULL);
        while ((rc = mdb_cursor_get(&mc, &key, &data, MDB_NEXT)) == 0)
                freecount += *(MDB_ID *)data.mv_data;
-       freecount += txn->mt_dbs[0].md_branch_pages + txn->mt_dbs[0].md_leaf_pages +
-               txn->mt_dbs[0].md_overflow_pages;
 
        count = 0;
        for (i = 0; i<txn->mt_numdbs; i++) {
+               MDB_xcursor mx, *mxp;
+               mxp = (txn->mt_dbs[i].md_flags & MDB_DUPSORT) ? &mx : NULL;
+               mdb_cursor_init(&mc, txn, i, mxp);
+               if (txn->mt_dbs[i].md_root == P_INVALID)
+                       continue;
                count += txn->mt_dbs[i].md_branch_pages +
                        txn->mt_dbs[i].md_leaf_pages +
                        txn->mt_dbs[i].md_overflow_pages;
                if (txn->mt_dbs[i].md_flags & MDB_DUPSORT) {
-                       MDB_xcursor mx;
-                       mdb_cursor_init(&mc, txn, i, &mx);
                        mdb_page_search(&mc, NULL, 0);
                        do {
                                unsigned j;
@@ -1136,7 +1137,10 @@ static void mdb_audit(MDB_txn *txn)
                        while (mdb_cursor_sibling(&mc, 1) == 0);
                }
        }
-       assert(freecount + count + 2 >= txn->mt_next_pgno - 1);
+       if (freecount + count + 2 /* metapages */ != txn->mt_next_pgno) {
+               fprintf(stderr, "audit: %lu freecount: %lu count: %lu total: %lu next_pgno: %lu\n",
+                       txn->mt_txnid, freecount, count+2, freecount+count+2, txn->mt_next_pgno);
+       }
 }
 #endif