tdb: don't truncate tdb on recovery
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 22 Apr 2010 04:24:06 +0000 (13:54 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 22 Apr 2010 04:24:06 +0000 (13:54 +0930)
The current recovery code truncates the tdb file on recovery.  This is
fine if recovery is only done on first open, but is a really bad idea
as we move to allowing recovery on "live" databases.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from commit 8c3fda4318adc71899bc41486d5616da3a91a688)

lib/tdb/common/transaction.c

index 763afffc528e28b6d9533913487002e63f567c28..3d267af2b043bd85077fd0150d941cf6a07ccc2d 100644 (file)
@@ -1180,16 +1180,6 @@ int tdb_transaction_recover(struct tdb_context *tdb)
                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;