Skip to content

Commit

Permalink
fix bug where fast storage was not enabled when version 0 was attempt…
Browse files Browse the repository at this point in the history
…ed to be loaded
  • Loading branch information
p0mvn committed Feb 7, 2022
1 parent 51b6c2f commit a7e7fb2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mutable_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,10 @@ func (tree *MutableTree) LazyLoadVersion(targetVersion int64) (int64, error) {
// no versions have been saved if the latest version is non-positive
if latestVersion <= 0 {
if targetVersion <= 0 {
return 0, nil
tree.mtx.Lock()
defer tree.mtx.Unlock()
_, err := tree.enableFastStorageAndCommitIfNotEnabled()
return 0, err
}
return 0, fmt.Errorf("no versions found while trying to load %v", targetVersion)
}
Expand Down Expand Up @@ -472,7 +475,10 @@ func (tree *MutableTree) LoadVersion(targetVersion int64) (int64, error) {

if len(roots) == 0 {
if targetVersion <= 0 {
return 0, nil
tree.mtx.Lock()
defer tree.mtx.Unlock()
_, err := tree.enableFastStorageAndCommitIfNotEnabled()
return 0, err
}
return 0, fmt.Errorf("no versions found while trying to load %v", targetVersion)
}
Expand Down

0 comments on commit a7e7fb2

Please sign in to comment.