haskell-works / hw-kafka-client

Kafka client for Haskell, including auto-rebalancing consumers
MIT License
140 stars 50 forks source link

Fix leak in storeOffsetMessage and storeOffsets #199

Closed lazamar closed 6 months ago

lazamar commented 7 months ago

The use of toNativeTopicPartitionListNoDispose in Kafka.Consumer.storeOffsetMessage and storeOffsets left the partition lists in memory indefinitely as there is no foreign pointer finaliser attached and the list isn't explicitly freed afterwards. This was causing OOMs in my application every few hours.

I confirmed that using toNativeTopicPartitionList instead fixes the issue and is also in line with how these lists are handled in librdkafka (example) by being destroyed after calls to rd_kafka_offsets_store.

This PR applies the fix to storeOffsetMessage and storeOffsets.

AlexeyRaga commented 6 months ago

Thanks @lazamar! :)