tdb: don't reduce file size on transaction recovery.
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 22 Feb 2010 12:33:36 +0000 (23:03 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 22 Feb 2010 12:33:36 +0000 (23:03 +1030)
There's little point in ever shrinking the file, and it definitely breaks in the case where a process has died during a transaction commit and other processes have the tdb mapped.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/tdb/transaction.c

index 238034f3700687a77e347b71f456e121485333b1..6b539d4045ee6ef2e91f7943387e2492ffa681ad 100644 (file)
@@ -1203,16 +1203,6 @@ int tdb_transaction_recover(struct tdb_context *tdb)
                return -1;                      
        }
        
                return -1;                      
        }
        
-       /* reduce the file size to the old size */
-       tdb_munmap(tdb);
-       if (ftruncate(tdb->fd, recovery_eof) != 0) {
-               TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to reduce to recovery size\n"));
-               tdb->ecode = TDB_ERR_IO;
-               return -1;                      
-       }
-       tdb->map_size = recovery_eof;
-       tdb_mmap(tdb);
-
        if (transaction_sync(tdb, 0, recovery_eof) == -1) {
                TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to sync2 recovery\n"));
                tdb->ecode = TDB_ERR_IO;
        if (transaction_sync(tdb, 0, recovery_eof) == -1) {
                TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to sync2 recovery\n"));
                tdb->ecode = TDB_ERR_IO;