Skip to content

Commit

Permalink
Fix concurrent database access when deleting orphans (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikgrinaker authored Mar 13, 2020
1 parent cc023ad commit 17428bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ Special thanks to external contributors on this release:

### Bug Fix

- [nodedb] [\#219](https://github.com/tendermint/iavl/pull/219) Fix a concurrent database access issue when deleting orphans

## 0.13.0 (January 16, 2020)

Special thanks to external contributors on this release:
@rickyyangz, @mattkanwisher

### BREAKING CHANGES

- [pruning] [/#158](https://github.com/tendermint/iavl/pull/158) NodeDB constructor must provide `keepRecent` and `keepEvery` fields to define PruningStrategy. All Save functionality must specify whether they should flushToDisk as well using `flushToDisk` boolean argument. All Delete functionality must specify whether object should be deleted from memory only using the `memOnly` boolean argument.
- [pruning] [\#158](https://github.com/tendermint/iavl/pull/158) NodeDB constructor must provide `keepRecent` and `keepEvery` fields to define PruningStrategy. All Save functionality must specify whether they should flushToDisk as well using `flushToDisk` boolean argument. All Delete functionality must specify whether object should be deleted from memory only using the `memOnly` boolean argument.
- [dep] [\#194](https://github.com/tendermint/iavl/pull/194) Update tm-db to 0.4.0 this includes interface breaking to return errors.

### IMPROVEMENTS
Expand Down
6 changes: 1 addition & 5 deletions nodedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,17 +284,13 @@ func (ndb *nodeDB) deleteOrphans(version int64, memOnly bool) error {
if ndb.opts.KeepRecent != 0 {
ndb.deleteOrphansMem(version)
}
var err error
if ndb.isSnapshotVersion(version) && !memOnly {
predecessor := getPreviousVersionFromDB(version, ndb.snapshotDB)
traverseOrphansVersionFromDB(ndb.snapshotDB, version, func(key, hash []byte) {
err = ndb.snapshotDB.Delete(key)
ndb.snapshotBatch.Delete(key)
ndb.deleteOrphansHelper(ndb.snapshotDB, ndb.snapshotBatch, true, predecessor, key, hash)
})
}
if err != nil {
return errors.Wrap(err, "snapshotDB err in delete")
}
return nil
}

Expand Down

0 comments on commit 17428bb

Please sign in to comment.