Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix concurrent database access when deleting orphans #219

Merged
merged 2 commits into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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