From 4313de6f72ff7c1946f756e36e3fff78c9afd55c Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Mon, 24 Jan 2011 19:34:59 +0000 Subject: [PATCH] Fix bug in bsddb 4.7 by moving the NOSYNC setting before env open svn: r16460 --- src/gen/db/write.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/gen/db/write.py b/src/gen/db/write.py index 8e7bf0c07..bffccd9c7 100644 --- a/src/gen/db/write.py +++ b/src/gen/db/write.py @@ -399,8 +399,16 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback): self.env.set_lk_max_locks(DBLOCKS) self.env.set_lk_max_objects(DBOBJECTS) + # Set to auto remove stale logs self.set_auto_remove() + # Set not to flush to disk synchronous, this greatly speeds up + # database changes, but comes at the cause of loss of durability, so + # power loss might cause a need to run db recovery, see BSDDB manual + ## NOTE: due to pre 4.8 bsddb bug it is needed to set this flag before + ## open of env, #16492 - http://download.oracle.com/docs/cd/E17076_02/html/installation/changelog_4_8.html + self.env.set_flags(db.DB_TXN_WRITE_NOSYNC, 1) + # The DB_PRIVATE flag must go if we ever move to multi-user setup env_flags = db.DB_CREATE | db.DB_PRIVATE |\ db.DB_INIT_MPOOL | db.DB_INIT_LOCK |\ @@ -417,8 +425,6 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback): except: pass raise DbEnvironmentError(msg) - # Set not to flush to disk synchronous - self.env.set_flags(db.DB_TXN_WRITE_NOSYNC, 1) self.env.txn_checkpoint() @@ -1643,9 +1649,6 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback): self.undodb.clear() self.env.txn_checkpoint() - #if db.version() < (4, 7): - # self.env.set_flags(db.DB_TXN_NOSYNC, 1) # async txn - if self.secondary_connected and not no_magic: # Disconnect unneeded secondary indices self.surnames.close() @@ -1683,8 +1686,6 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback): """ if transaction.batch: self.env.txn_checkpoint() - #if db.version() < (4, 7): - # self.env.set_flags(db.DB_TXN_NOSYNC, 0) # sync txn if not transaction.no_magic: # create new secondary indices to replace the ones removed