Преглед на файлове

backend: do not commit unless there is a pending change

Reduce the nubmer of fsync etcd issues when the cluster is
idle.
Xiang Li преди 10 години
родител
ревизия
8bc59b66d1
променени са 1 файла, в които са добавени 4 реда и са изтрити 0 реда
  1. 4 0
      storage/backend/batch_tx.go

+ 4 - 0
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)
 		}