Skip to content

Commit

Permalink
[FAB-3247] Optimize 2nd commit CouchDB recordSavePoint
Browse files Browse the repository at this point in the history
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 <chris.elder@us.ibm.com>
  • Loading branch information
Chris Elder committed Apr 26, 2017
1 parent 0e0deac commit 148775a
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions core/ledger/kvledger/txmgmt/statedb/statecouchdb/statecouchdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,9 @@ type couchSavepointData struct {

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

// ensure full commit to flush savepoint to disk
dbResponse, err = vdb.db.EnsureFullCommit()
if err != nil || dbResponse.Ok != true {
logger.Errorf("Failed to perform full commit\n")
return errors.New("Failed to perform full commit")
}
return nil
}

Expand Down

0 comments on commit 148775a

Please sign in to comment.