fix memory leak (iterator never finished so cleanup didn't run)

This commit is contained in:
Jeffrey Picard 2022-04-14 02:18:08 +00:00
parent f9011c7d52
commit ca840aea7f
2 changed files with 2 additions and 3 deletions

View file

@ -335,6 +335,7 @@ func IterCF(db *grocksdb.DB, opts *IterOptions) <-chan *prefixes.PrefixRowKV {
defer func() {
it.Close()
close(ch)
ro.Destroy()
}()
var prevKey []byte

View file

@ -164,7 +164,7 @@ func (db *ReadOnlyDBColumnFamily) GetShortClaimIdUrl(name string, normalizedName
// Prefix and handle
options := NewIterateOptions().WithPrefix(prefix).WithCfHandle(handle)
// Start and stop bounds
options = options.WithStart(keyPrefix)
options = options.WithStart(keyPrefix).WithStop(keyPrefix)
// Don't include the key
options = options.WithIncludeValue(false)
@ -428,8 +428,6 @@ func (db *ReadOnlyDBColumnFamily) GetControllingClaim(name string) (*prefixes.Cl
log.Println(hex.EncodeToString(rawKey))
slice, err := db.DB.GetCF(db.Opts, handle, rawKey)
defer slice.Free()
log.Printf("slice: %#v", slice)
log.Printf("err: %#v", err)
if err != nil {
return nil, err