From 6eaeeb2648430893b9094e3bcf34d3da82b21cb3 Mon Sep 17 00:00:00 2001 From: Anthony Fieroni Date: Thu, 23 Jan 2020 10:16:58 +0200 Subject: [PATCH] Don't call lsn_reset at periodic time Signed-off-by: Anthony Fieroni --- src/wallet/db.cpp | 9 +++++---- src/wallet/db.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp index f7a54f414..f345207ce 100644 --- a/src/wallet/db.cpp +++ b/src/wallet/db.cpp @@ -469,10 +469,10 @@ bool BerkeleyEnvironment::Salvage(const std::string& strFile, bool fAggressive, } -void BerkeleyEnvironment::CheckpointLSN(const std::string& strFile) +void BerkeleyEnvironment::CheckpointLSN(const std::string& strFile, bool lsnReset) { dbenv->txn_checkpoint(0, 0, 0); - if (fMockDb) + if (fMockDb || !lsnReset) return; dbenv->lsn_reset(strFile.c_str(), 0); } @@ -799,9 +799,10 @@ bool BerkeleyBatch::PeriodicFlush(BerkeleyDatabase& database) // Flush wallet file so it's self contained env->CloseDb(strFile); - env->CheckpointLSN(strFile); + // don't call lsn_reset at periodic time + // it causes performace issues on big wallets + env->CheckpointLSN(strFile, /* lsnReset */ false); - env->mapFileUseCount.erase(mi++); LogPrint(BCLog::DB, "Flushed %s %dms\n", strFile, GetTimeMillis() - nStart); ret = true; } diff --git a/src/wallet/db.h b/src/wallet/db.h index ac70dc55e..00d5017f8 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -83,7 +83,7 @@ public: bool Open(bool retry); void Close(); void Flush(bool fShutdown); - void CheckpointLSN(const std::string& strFile); + void CheckpointLSN(const std::string& strFile, bool lsnReset = true); void CloseDb(const std::string& strFile); void ReloadDbEnv();