[ 
https://issues.apache.org/jira/browse/SPARK-29438?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16949465#comment-16949465
 ] 

Jungtaek Lim commented on SPARK-29438:
--------------------------------------

Could you please link the actual code block from Github repo?

* current master branch
https://github.com/apache/spark/blob/6390f02f9fba059ec5d089a68c8d758aca35c9cd/sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/StateStore.scala#L267-L280

* current branch-2.4 branch
https://github.com/apache/spark/blob/4f46e8f804cba6d845116cb7daf9b4c682e6a0f1/sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/StateStore.scala#L267-L280

* current branch-2.3 branch
https://github.com/apache/spark/blob/75cc3b2da9ee0b51ecf0f13169f2b634e36a60c4/sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/StateStore.scala#L265-L278

using taskId in the path is completely new to me so would like to confirm.

> Failed to get state store in stream-stream join
> -----------------------------------------------
>
>                 Key: SPARK-29438
>                 URL: https://issues.apache.org/jira/browse/SPARK-29438
>             Project: Spark
>          Issue Type: Bug
>          Components: Structured Streaming
>    Affects Versions: 2.4.4
>            Reporter: Genmao Yu
>            Priority: Critical
>
> Now, Spark use the `TaskPartitionId` to determine the StateStore path.
> {code:java}
> TaskPartitionId   \ 
> StateStoreVersion  --> StoreProviderId -> StateStore
> StateStoreName    /  
> {code}
> In spark stages, the task partition id is determined by the number of tasks. 
> As we said the StateStore file path depends on the task partition id. So if 
> stream-stream join task partition id is changed against last batch, it will 
> get wrong StateStore data or fail with non-exist StateStore data. In some 
> corner cases, it happened. Following is a sample pseudocode:
> {code:java}
> val df3 = streamDf1.join(streamDf2)
> val df5 = streamDf3.join(batchDf4)
> val df = df3.union(df5)
> df.writeStream...start()
> {code}
> A simplified DAG like this:
> {code:java}
> DataSourceV2Scan   Scan Relation     DataSourceV2Scan   DataSourceV2Scan
>  (streamDf3)            |               (streamDf1)        (streamDf2)
>      |                  |                   |                 |
>   Exchange(200)      Exchange(200)       Exchange(200)     Exchange(200)
>      |                  |                   |                 | 
>    Sort                Sort                 |                 |
>      \                  /                   \                 /
>       \                /                     \               /
>         SortMergeJoin                    StreamingSymmetricHashJoin
>                      \                 /
>                        \             /
>                          \         /
>                             Union
> {code}
> Stream-Steam join task Id will start from 200 to 399 as they are in the same 
> stage with `SortMergeJoin`. But when there is no new incoming data in 
> `streamDf3` in some batch, it will generate a empty LocalRelation, and then 
> the SortMergeJoin will be replaced with a BroadcastHashJoin. In this case, 
> Stream-Steam join task Id will start from 1 to 200. Finally, it will get 
> wrong StateStore path through TaskPartitionId, and failed with error reading 
> state store delta file.
> {code:java}
> LocalTableScan   Scan Relation     DataSourceV2Scan   DataSourceV2Scan
>      |                  |                   |                 |
> BroadcastExchange       |              Exchange(200)     Exchange(200)
>      |                  |                   |                 | 
>      |                  |                   |                 |
>       \                /                     \               /
>        \             /                        \             /
>       BroadcastHashJoin                 StreamingSymmetricHashJoin
>                      \                 /
>                        \             /
>                          \         /
>                             Union
> {code}
> In my job, I closed the auto BroadcastJoin feature (set 
> spark.sql.autoBroadcastJoinThreshold=-1) to walk around this bug. We should 
> make the StateStore path determinate but not depends on TaskPartitionId.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to