Add resource free in err process (#9564)

Signed-off-by: fishpenguin <kun.yu@zilliz.com>
pull/9595/head
yukun 2021-10-09 19:39:16 +08:00 committed by GitHub
parent 6eb2fe6993
commit 12b985c32e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -614,10 +614,13 @@ func (rmq *rocksmq) Consume(topicName string, groupName string, n int) ([]Consum
for ; iter.Valid() && offset < n; iter.Next() {
key := iter.Key()
val := iter.Value()
strKey := string(key.Data())
key.Free()
offset++
msgID, err := strconv.ParseInt(string(key.Data())[FixedChannelNameLen+1:], 10, 64)
msgID, err := strconv.ParseInt(strKey[FixedChannelNameLen+1:], 10, 64)
if err != nil {
log.Debug("RocksMQ: parse int " + string(key.Data())[FixedChannelNameLen+1:] + " failed")
log.Debug("RocksMQ: parse int " + strKey[FixedChannelNameLen+1:] + " failed")
val.Free()
return nil, err
}
msg := ConsumerMessage{
@ -632,7 +635,6 @@ func (rmq *rocksmq) Consume(topicName string, groupName string, n int) ([]Consum
copy(msg.Payload, origData)
}
consumerMessage = append(consumerMessage, msg)
key.Free()
val.Free()
}