Skip to content

Commit

Permalink
mvcc: check null before set FillPercent not to panic
Browse files Browse the repository at this point in the history
Since CreateBucketIfNotExists() can return nil when it gets an error,
accessing FillPercent must be done after a nil check, not to cause
a panic.
  • Loading branch information
Iwasaki Yudai authored and gyuho committed Jan 8, 2018
1 parent ec43197 commit 1ae0c0b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mvcc/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,10 @@ func defragdb(odb, tmpdb *bolt.DB, limit int) error {
}

tmpb, berr := tmptx.CreateBucketIfNotExists(next)
tmpb.FillPercent = 0.9 // for seq write in for each
if berr != nil {
return berr
}
tmpb.FillPercent = 0.9 // for seq write in for each

b.ForEach(func(k, v []byte) error {
count++
Expand Down

0 comments on commit 1ae0c0b

Please sign in to comment.