raviston opened a new pull request, #60556: URL: https://github.com/apache/spark/pull/60556
### What changes were proposed in this pull request? `StateStoreInstanceMetricSuite` now stops the state store in `beforeEach`, as `RocksDBTimestampEncoderOperationsSuite` does, so that each test starts the maintenance task with its own configuration. ### Why are the changes needed? The snapshot lag tests set `spark.sql.streaming.stateStore.maintenanceInterval` to 100 ms and expect snapshots to be uploaded during the test. But the maintenance task is shared by the JVM, and `StateStore.startMaintenanceIfNeeded` only starts one when none is running, so it keeps the interval of the test that started it. If an earlier test in the same JVM started it with the default interval of 60 seconds, no snapshot is uploaded during the test, every `SnapshotLastUploaded` metric stays -1, and the test fails: ``` Assert on query failed: Execute: The code passed to eventually never returned normally. Attempted 669 times over 10.005817232000002 seconds. Last failure message: instanceMetrics.forall(((x$2: (String, Long)) => scala.Predef.Long2long(x$2._2).>=(0))) was false. ``` `StreamTest` stops the state store after each `testStream`, but not before the first one, so only the first test of the suite is affected. This happened in "sql - other tests" in https://github.com/raviston/spark/actions/runs/43067912461 (attempts 10 to 12, for #60293), where `WriteDistributionAndOrderingSuite` ("ordered distribution and sort with same exprs: micro-batch complete") started the task just before `StateStoreInstanceMetricSuiteWithRowChecksum`. That suite runs in "sql - other tests" because the `ExtendedSQLTest` tag of `StateStoreInstanceMetricSuite` is not inherited. ### Does this PR introduce _any_ user-facing change? No, test only. ### How was this patch tested? This fails on master and passes with this PR: ``` build/sbt 'sql/testOnly org.apache.spark.sql.connector.WriteDistributionAndOrderingSuite org.apache.spark.sql.execution.streaming.state.StateStoreInstanceMetricSuiteWithRowChecksum -- -z "ordered distribution and sort with same exprs: micro-batch complete" -z "SPARK-51097: Verify snapshot lag metrics are updated correctly with RocksDBStateStoreProvider (with changelog"' ``` `StateStoreInstanceMetricSuite` and `StateStoreInstanceMetricSuiteWithRowChecksum` pass locally (JDK 21), and so does `sql/Test/scalastyle`. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 5.5) -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
