Isolate cached serializers between SQL test suites [fast-ut] [reduced-it] - #15488
Conversation
Signed-off-by: Haoyang Li <haoyangl@nvidia.com>
Greptile SummaryThe PR centralizes Spark’s cached-batch serializer reset and applies it at RAPIDS SQL suite boundaries so serial and parallel test execution isolate JVM-global serializer state consistently.
Confidence Score: 5/5The PR appears safe to merge, with serializer state consistently reset at suite and worker boundaries. The shared helper preserves the existing worker cleanup and adds correctly ordered, exception-safe suite cleanup without exposing a concurrent same-JVM suite path. Important Files Changed
Sequence DiagramsequenceDiagram
participant Runner as ScalaTest Runner
participant Suite as RAPIDS SQL Suite
participant Cache as InMemoryRelation Singleton
participant Spark as SparkSession
Runner->>Suite: beforeAll()
Suite->>Cache: clearSerializer()
Suite->>Spark: super.beforeAll()
Runner->>Suite: run tests
Runner->>Suite: afterAll()
Suite->>Spark: super.afterAll()
Suite->>Cache: clearSerializer() in finally
Runner->>Cache: defensive worker cleanup
Reviews (1): Last reviewed commit: "Isolate cached serializers between SQL t..." | Re-trigger Greptile |
There was a problem hiding this comment.
Pull request overview
This PR fixes intermittent Spark SQL suite failures caused by Spark caching the first configured CachedBatchSerializer in a JVM-global singleton, which allowed earlier suites to influence later suites’ cache-serialization behavior in serial test runs.
Changes:
- Centralizes the reflective reset of Spark’s cached cache-serializer into
TestUtils. - Clears the cached serializer at RAPIDS SQL suite boundaries (before/after suite execution).
- Reuses the shared helper from the fast parallel unit test worker cleanup.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/src/test/spark330/scala/org/apache/spark/sql/rapids/utils/RapidsSQLTestsBaseTrait.scala | Adds suite-boundary serializer resets to isolate Spark SQL suite state in serial runs. |
| tests/src/test/scala/com/nvidia/spark/rapids/TestUtils.scala | Introduces a shared helper to reflectively clear Spark’s JVM-global cached serializer. |
| tests/src/test/scala/com/nvidia/spark/rapids/ParallelUnitTestRunner.scala | Switches worker cleanup to call the shared serializer-reset helper. |
|
build |
Fixes #15464.
Description
RapidsStatisticsCollectionSuiteselects Spark'sDefaultCachedBatchSerializer, while other RAPIDS SQL suites useParquetCachedBatchSerializer. Spark caches the first configured serializer in a JVM-globalInMemoryRelationsingleton. The standard serial ScalaTest path reused that state between suites, so a preceding cache suite could causeSPARK-33687: analyze all tables in a specific databaseto report a size of 161 bytes instead of the expected 4 bytes.The fast parallel unit test runner already cleared this state between suites, which made serial and parallel runs behave differently. This change:
There is no user-facing behavior change.
Validation:
RapidsCachedTableSuitefollowed byRapidsStatisticsCollectionSuiteserially reproduced the issue: 107 succeeded and 1 failed.-Drapids.parallelUnitTests=true -DparallelForkCount=2, the suites pass in separate child JVMs: 73/73 and 35/35.Checklists
Documentation
Testing
(Please provide the names of the existing tests in the PR description.)
Performance