Use private environment for database rebuilds too, document
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 2 Feb 2012 12:31:17 +0000 (14:31 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 2 Feb 2012 12:39:49 +0000 (14:39 +0200)
- One of the more common reasons for users to do --rebuilddb is
  a paniced environment. Throwing DB_RUNRECOVER errors at the user
  who is trying to recover by rebuilding the db isn't terribly
  productive (RhBug:590710). Use a private environment while
  rebuilding for both the original and new database, and dont bother
  with CDB which only slows things down when there are no other
  players present.
- Verify wants the same flags but for different reasons...

lib/backend/db3.c
lib/rpmdb.c

index 38f14de..30ed7ac 100644 (file)
@@ -131,11 +131,13 @@ static int db_init(rpmdb rdb, const char * dbhome)
        return 0;
     }
 
-    /* By no means necessary but speeds things up a bit */
-    if (rdb->db_flags & RPMDB_FLAG_REBUILD)
-       eflags &= ~DB_INIT_CDB;
-    /* XXX Something bizarre with verify... use private environment, no cdb */
-    if (rdb->db_flags & RPMDB_FLAG_VERIFYONLY) {
+    /*
+     * Both verify and rebuild are rather special, if for different reasons:
+     * On rebuild we dont want to be affected by eg paniced environment, and
+     * CDB only slows things down there. Verify is a quirky beast unlike
+     * anything else in BDB, and does not like shared env or CDB.
+     */
+    if (rdb->db_flags & (RPMDB_FLAG_VERIFYONLY|RPMDB_FLAG_REBUILD)) {
        eflags |= DB_PRIVATE;
        eflags &= ~DB_INIT_CDB;
     }
index d3a5e23..79abde7 100644 (file)
@@ -2838,7 +2838,8 @@ int rpmdbRebuild(const char * prefix, rpmts ts,
     }
     removedir = 1;
 
-    if (openDatabase(prefix, dbpath, &olddb, O_RDONLY, 0644, 0)) {
+    if (openDatabase(prefix, dbpath, &olddb,
+                    O_RDONLY, 0644, RPMDB_FLAG_REBUILD)) {
        rc = 1;
        goto exit;
     }