Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17752#discussion_r113074883
  
    --- Diff: 
external/kafka-0-10-sql/src/main/scala/org/apache/spark/sql/kafka010/KafkaRelation.scala
 ---
    @@ -53,9 +54,27 @@ private[kafka010] class KafkaRelation(
       override def schema: StructType = KafkaOffsetReader.kafkaSchema
     
       override def buildScan(): RDD[Row] = {
    +    // Each running query should use its own group id. Otherwise, the 
query may be only assigned
    +    // partial data since Kafka will assign partitions to multiple 
consumers having the same group
    +    // id. Hence, we should generate a unique id for each query.
    +    val uniqueGroupId = s"spark-kafka-relation-${UUID.randomUUID}"
    --- End diff --
    
    generate the unique group id and KafkaOffsetReader here, and close it 
inside this method, so that we never use the same reader at different threads 
(such as using the same DataFrame in different threads).



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to