From ca840aea7fd2534ba6ef1c03f8427afcd45a8b08 Mon Sep 17 00:00:00 2001 From: Jeffrey Picard Date: Thu, 14 Apr 2022 02:18:08 +0000 Subject: [PATCH] fix memory leak (iterator never finished so cleanup didn't run) --- db/db.go | 1 + db/db_get.go | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/db/db.go b/db/db.go index cbeed41..3d3d724 100644 --- a/db/db.go +++ b/db/db.go @@ -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 diff --git a/db/db_get.go b/db/db_get.go index 1295715..7df756b 100644 --- a/db/db_get.go +++ b/db/db_get.go @@ -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