tdas commented on a change in pull request #26225: [SPARK-29568][SS] Stop
existing running streams when a new stream is launched
URL: https://github.com/apache/spark/pull/26225#discussion_r344984443
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/streaming/StreamingQueryManagerSuite.scala
##########
@@ -274,48 +275,117 @@ class StreamingQueryManagerSuite extends StreamTest {
}
testQuietly("can't start multiple instances of the same streaming query in
the same session") {
- withTempDir { dir =>
- val (ms1, ds1) = makeDataset
- val (ms2, ds2) = makeDataset
- val chkLocation = new File(dir, "_checkpoint").getCanonicalPath
- val dataLocation = new File(dir, "data").getCanonicalPath
-
- val query1 = ds1.writeStream.format("parquet")
- .option("checkpointLocation", chkLocation).start(dataLocation)
- ms1.addData(1, 2, 3)
- try {
- val e = intercept[IllegalStateException] {
- ds2.writeStream.format("parquet")
+ withSQLConf(SQLConf.STOP_RUNNING_DUPLICATE_STREAM.key -> "false") {
+ withTempDir { dir =>
+ val (ms1, ds1) = makeDataset
+ val (ms2, ds2) = makeDataset
+ val chkLocation = new File(dir, "_checkpoint").getCanonicalPath
+ val dataLocation = new File(dir, "data").getCanonicalPath
+
+ val query1 = ds1.writeStream.format("parquet")
+ .option("checkpointLocation", chkLocation).start(dataLocation)
+ ms1.addData(1, 2, 3)
+ try {
+ val e = intercept[IllegalStateException] {
+ ds2.writeStream.format("parquet")
+ .option("checkpointLocation", chkLocation).start(dataLocation)
+ }
+ assert(e.getMessage.contains("same id"))
+ } finally {
+ query1.stop()
+ }
+ }
+ }
+ }
+
+ testQuietly("new instance of the same streaming query stops old query in the
same session") {
+ failAfter(90 seconds) {
+ withSQLConf(SQLConf.STOP_RUNNING_DUPLICATE_STREAM.key -> "true") {
+ withTempDir { dir =>
+ val (ms1, ds1) = makeDataset
+ val (ms2, ds2) = makeDataset
+ val chkLocation = new File(dir, "_checkpoint").getCanonicalPath
+ val dataLocation = new File(dir, "data").getCanonicalPath
+
+ val query1 = ds1.writeStream.format("parquet")
+ .option("checkpointLocation", chkLocation).start(dataLocation)
+ ms1.addData(1, 2, 3)
+ val query2 = ds2.writeStream.format("parquet")
.option("checkpointLocation", chkLocation).start(dataLocation)
+ try {
+ ms2.addData(1, 2, 3)
+ query2.processAllAvailable()
+ assert(spark.sharedState.activeStreamingQueries.get(query2.id) ===
+ query2.asInstanceOf[StreamingQueryWrapper].streamingQuery,
+ "The correct streaming query is not being tracked in global
state")
+
+ assert(!query1.isActive,
+ "First query should have stopped before starting the second
query")
+ } finally {
+ query2.stop()
Review comment:
stop all active streams
----------------------------------------------------------------
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]