From 8bc59b66d157d4959528ee0aad131b824f25b351 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Wed, 23 Dec 2015 18:58:34 -0800 Subject: [PATCH] backend: do not commit unless there is a pending change Reduce the nubmer of fsync etcd issues when the cluster is idle. --- storage/backend/batch_tx.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/storage/backend/batch_tx.go b/storage/backend/batch_tx.go index 9aa25bbc4..06b5b416d 100644 --- a/storage/backend/batch_tx.go +++ b/storage/backend/batch_tx.go @@ -132,7 +132,11 @@ func (t *batchTx) commit(stop bool) { var err error // commit the last tx if t.tx != nil { + if t.pending == 0 && !stop { + return + } err = t.tx.Commit() + t.pending = 0 if err != nil { log.Fatalf("storage: cannot commit tx (%s)", err) }