From bdb7832a59cfab3f20a9a94e9cf5dc997f623b2a Mon Sep 17 00:00:00 2001 From: b00ris Date: Wed, 9 Sep 2020 23:07:19 +0300 Subject: [PATCH] [lmdb] Stop force sync for ReadOnly mode (#1088) * fix warning * fix log --- ethdb/kv_lmdb.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ethdb/kv_lmdb.go b/ethdb/kv_lmdb.go index 903f7ab4f..e2836fe62 100644 --- a/ethdb/kv_lmdb.go +++ b/ethdb/kv_lmdb.go @@ -450,10 +450,10 @@ func (tx *lmdbTx) Commit(ctx context.Context) error { log.Info("Batch", "commit", commitTook) } - if !tx.isSubTx { // call fsync only after main transaction commit + if !tx.isSubTx && !tx.db.opts.readOnly { // call fsync only after main transaction commit fsyncTimer := time.Now() if err := tx.db.env.Sync(true); err != nil { - log.Warn("fsync after commit failed: \n", err) + log.Warn("fsync after commit failed", "err", err) } fsyncTook := time.Since(fsyncTimer) if fsyncTook > 20*time.Second {