Skip to content

Commit

Permalink
[SPARK-19168][STRUCTURED STREAMING] StateStore should be aborted upon…
Browse files Browse the repository at this point in the history
… error

## What changes were proposed in this pull request?

We should call `StateStore.abort()` when there should be any error before the store is committed.

## How was this patch tested?

Manually.

Author: Liwei Lin <[email protected]>

Closes apache#16547 from lw-lin/append-filter.
  • Loading branch information
lw-lin authored and cmonkey committed Feb 15, 2017
1 parent 58ea392 commit 7c2da35
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import org.apache.spark.sql.execution.streaming.state._
import org.apache.spark.sql.execution.SparkPlan
import org.apache.spark.sql.streaming.OutputMode
import org.apache.spark.sql.types.StructType
import org.apache.spark.TaskContext


/** Used to identify the state store for a given operator. */
Expand Down Expand Up @@ -150,6 +151,13 @@ case class StateStoreSaveExec(
val numTotalStateRows = longMetric("numTotalStateRows")
val numUpdatedStateRows = longMetric("numUpdatedStateRows")

// Abort the state store in case of error
TaskContext.get().addTaskCompletionListener(_ => {
if (!store.hasCommitted) {
store.abort()
}
})

outputMode match {
// Update and output all rows in the StateStore.
case Some(Complete) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private[state] class HDFSBackedStateStoreProvider(
/**
* Whether all updates have been committed
*/
override private[state] def hasCommitted: Boolean = {
override private[streaming] def hasCommitted: Boolean = {
state == COMMITTED
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ trait StateStore {
/**
* Whether all updates have been committed
*/
private[state] def hasCommitted: Boolean
private[streaming] def hasCommitted: Boolean
}


Expand Down

0 comments on commit 7c2da35

Please sign in to comment.