skonto commented on a change in pull request #19096: [SPARK-21869][SS] A cached
Kafka producer should not be closed if any task is using it - adds inuse
tracking.
URL: https://github.com/apache/spark/pull/19096#discussion_r263333944
##########
File path:
external/kafka-0-10-sql/src/main/scala/org/apache/spark/sql/kafka010/CachedKafkaProducer.scala
##########
@@ -86,27 +112,38 @@ private[kafka010] object CachedKafkaProducer extends
Logging {
paramsSeq
}
- /** For explicitly closing kafka producer */
+ /** For explicitly closing kafka producer, will not close an inuse producer
until released. */
private[kafka010] def close(kafkaParams: ju.Map[String, Object]): Unit = {
val paramsSeq = paramsToSeq(kafkaParams)
guavaCache.invalidate(paramsSeq)
}
- /** Auto close on cache evict */
- private def close(paramsSeq: Seq[(String, Object)], producer: Producer):
Unit = {
+ /** Close this producer and process pending closes. */
+ private def close(producer: CachedKafkaProducer): Unit = synchronized {
Review comment:
Is there a guarantee that this will be called? I can imagine a scenario
where long running tasks make all producers to be evicted, then at some point `
producer.inUseCount.decrementAndGet()` is called in the write task for each
producer and this causes all of them to be closable but the method here is
never called (might be wrong).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]