Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ abstract class GraphExecution(

/** Increments flow execution retry count for `flow`. */
private def incrementFlowToNumConsecutiveFailure(flowIdentifier: TableIdentifier): Unit = {
flowToNumConsecutiveFailure.put(flowIdentifier, flowToNumConsecutiveFailure(flowIdentifier) + 1)
flowToNumConsecutiveFailure.updateWith(flowIdentifier) {
case Some(count) => Some(count + 1)
case None => Some(1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JiaqiWang18 shall we have a unit test for this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added unit test "consecutive failure event level is correct". flowToNumConsecutiveFailure controls the log level and if it is incremented correctly, we should only see the last retry execution event having ERROR level and all previous events having WARN level .

}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import org.apache.spark.sql.connector.catalog.{CatalogV2Util, Identifier, TableC
import org.apache.spark.sql.execution.streaming.runtime.MemoryStream
import org.apache.spark.sql.pipelines.common.{FlowStatus, RunState}
import org.apache.spark.sql.pipelines.graph.TriggeredGraphExecution.StreamState
import org.apache.spark.sql.pipelines.logging.EventLevel
import org.apache.spark.sql.pipelines.logging.{EventLevel, FlowProgress}
import org.apache.spark.sql.pipelines.utils.{ExecutionTest, TestGraphRegistrationContext}
import org.apache.spark.sql.test.SharedSparkSession
import org.apache.spark.sql.types.{IntegerType, StringType, StructType}
Expand Down Expand Up @@ -1027,4 +1027,33 @@ class TriggeredGraphExecutionSuite extends ExecutionTest with SharedSparkSession
}
)
}

test("consecutive failure event level is correct") {
val session = spark
import session.implicits._

val pipelineDef = new TestGraphRegistrationContext(spark) {
registerMaterializedView(
"retry_test",
partitionCols = Some(Seq("nonexistent_col")),
query = dfFlowFunc(spark.range(5).withColumn("id_mod", ($"id" % 2).cast("int")))
)
}

val graph = pipelineDef.toDataflowGraph
val updateContext = TestPipelineUpdateContext(spark, graph)
updateContext.pipelineExecution.runPipeline()
updateContext.pipelineExecution.awaitCompletion()

val failedEvents = updateContext.eventBuffer.getEvents.filter { e =>
e.details.isInstanceOf[FlowProgress] &&
e.details.asInstanceOf[FlowProgress].status == FlowStatus.FAILED
}

val warnCount = failedEvents.count(_.level == EventLevel.WARN)
// flowToNumConsecutiveFailure controls that the last failure should be logged as ERROR
val errorCount = failedEvents.count(_.level == EventLevel.ERROR)

assert(warnCount == 2 && errorCount == 1)
}
}