Skip to content

Commit 148775a

Browse files
author
Chris Elder
committed
[FAB-3247] Optimize 2nd commit CouchDB recordSavePoint
The second commit in recordSavepoint can be removed. The saveDoc in recordSavepoint will be flushed with the next batch. Change-Id: I9fc374d609c1770c872c2dcc38cf6a02bb558ed4 Signed-off-by: Chris Elder <[email protected]>
1 parent 0e0deac commit 148775a

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

core/ledger/kvledger/txmgmt/statedb/statecouchdb/statecouchdb.go

+3-8
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,9 @@ type couchSavepointData struct {
338338

339339
// recordSavepoint Record a savepoint in statedb.
340340
// Couch parallelizes writes in cluster or sharded setup and ordering is not guaranteed.
341-
// Hence we need to fence the savepoint with sync. So ensure_full_commit is called before AND after writing savepoint document
342-
// TODO: Optimization - merge 2nd ensure_full_commit with savepoint by using X-Couch-Full-Commit header
341+
// Hence we need to fence the savepoint with sync. So ensure_full_commit is called before
342+
// savepoint to ensure all block writes are flushed. Savepoint itself does not need to be flushed,
343+
// it will get flushed with next block if not yet committed.
343344
func (vdb *VersionedDB) recordSavepoint(height *version.Height) error {
344345
var err error
345346
var savepointDoc couchSavepointData
@@ -374,12 +375,6 @@ func (vdb *VersionedDB) recordSavepoint(height *version.Height) error {
374375
return err
375376
}
376377

377-
// ensure full commit to flush savepoint to disk
378-
dbResponse, err = vdb.db.EnsureFullCommit()
379-
if err != nil || dbResponse.Ok != true {
380-
logger.Errorf("Failed to perform full commit\n")
381-
return errors.New("Failed to perform full commit")
382-
}
383378
return nil
384379
}
385380

0 commit comments

Comments
 (0)