[lmdb] Stop force sync for ReadOnly mode (#1088)

* fix warning

* fix log
This commit is contained in:
b00ris 2020-09-09 23:07:19 +03:00 committed by GitHub
parent fd9c7c3b2d
commit bdb7832a59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -450,10 +450,10 @@ func (tx *lmdbTx) Commit(ctx context.Context) error {
log.Info("Batch", "commit", commitTook) 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() fsyncTimer := time.Now()
if err := tx.db.env.Sync(true); err != nil { 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) fsyncTook := time.Since(fsyncTimer)
if fsyncTook > 20*time.Second { if fsyncTook > 20*time.Second {