]> git.sur5r.net Git - openldap/commitdiff
Fix free page reclaim and dbs table update
authorHoward Chu <hyc@symas.com>
Fri, 26 Aug 2011 07:01:16 +0000 (00:01 -0700)
committerHoward Chu <hyc@symas.com>
Thu, 1 Sep 2011 23:31:10 +0000 (16:31 -0700)
Can re-use free pages 1 txn earlier
Must update all dbs tables on txn commit

libraries/libmdb/mdb.c

index 14a4c21b275e69664b435b9e847913bb92fc1be7..ad4e903a2ea32c0f360009000281c1ff6827acd7 100644 (file)
@@ -553,7 +553,7 @@ mdb_alloc_page(MDB_txn *txn, MDB_page *parent, unsigned int parent_idx, int num)
 
        if (txn->mt_txnid > 2) {
 
-       oldest = txn->mt_txnid - 2;
+       oldest = txn->mt_txnid - 1;
        if (!txn->mt_env->me_pghead && txn->mt_dbs[FREE_DBI].md_root != P_INVALID) {
                /* See if there's anything in the free DB */
                MDB_pageparent mpp;
@@ -1083,16 +1083,12 @@ done:
        {
                int toggle = !env->me_db_toggle;
 
-               for (i = 2; i < env->me_numdbs; i++) {
-                       if (txn->mt_dbxs[i].md_dirty) {
-                               env->me_dbs[toggle][i] = txn->mt_dbs[i];
-                               txn->mt_dbxs[i].md_dirty = 0;
-                       }
-               }
-               for (i = env->me_numdbs; i < txn->mt_numdbs; i++) {
-                       txn->mt_dbxs[i].md_dirty = 0;
-                       env->me_dbxs[i] = txn->mt_dbxs[i];
+               for (i = 2; i < txn->mt_numdbs; i++)
                        env->me_dbs[toggle][i] = txn->mt_dbs[i];
+
+               for (i = 2; i < txn->mt_numdbs; i++) {
+                       if (txn->mt_dbxs[i].md_dirty)
+                               txn->mt_dbxs[i].md_dirty = 0;
                }
                env->me_db_toggle = toggle;
                env->me_numdbs = txn->mt_numdbs;