Skip to content

test(spark): Fix flaky TestSparkFilterHelper by giving it its own SparkSession - #19356

Merged
voonhous merged 1 commit into
apache:masterfrom
wombatu-kun:fix-testsparkfilterhelper-session-flake
Jul 23, 2026
Merged

test(spark): Fix flaky TestSparkFilterHelper by giving it its own SparkSession#19356
voonhous merged 1 commit into
apache:masterfrom
wombatu-kun:fix-testsparkfilterhelper-session-flake

Conversation

@wombatu-kun

@wombatu-kun wombatu-kun commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Describe the issue this Pull Request addresses

org.apache.hudi.TestSparkFilterHelper.testConvertInExpression is intermittently flaky, failing with IllegalStateException: LiveListenerBus is stopped (wrapped in Error while instantiating 'SessionStateBuilder'). It last surfaced across the spark3.3/3.4/3.5 test-spark-java-tests-part1 jobs on an unrelated Flink-only PR (#19354, CI run https://github.com/apache/hudi/actions/runs/29977957778). The test calls functions.expr(...), which needs an active SparkSession, but TestSparkFilterHelper extends HoodieSparkClientTestHarness directly and never wires initSparkContexts() (that wiring lives in HoodieClientTestBase), so it relied on a leaked active session from a prior test in the same Surefire fork and failed whenever that session's context was already stopped.

Summary and Changelog

Add @BeforeEach/@AfterEach that call the inherited initSparkContexts()/cleanupSparkContexts() so the test owns a fresh SparkSession, matching HoodieClientTestBase and the sibling TestHoodieDataSourceHelper. Test-only; no production code or assertions change. No code was copied.

Impact

None. Test-only change confined to TestSparkFilterHelper.

Risk Level

none

Documentation Update

none

Contributor's checklist

  • Read through contributor's guide
  • Enough context is provided in the sections above
  • Adequate tests were added if applicable

…rkSession

testConvertInExpression calls org.apache.spark.sql.functions.expr(...), which lazily builds a SessionState on the active SparkSession. TestSparkFilterHelper extended HoodieSparkClientTestHarness directly without wiring @beforeeach initSparkContexts(), so it relied on a leaked active session from a prior test in the same Surefire fork and intermittently failed with "LiveListenerBus is stopped" when that session's context was already stopped. Add @BeforeEach/@AfterEach that create and stop the session, matching HoodieClientTestBase and the sibling TestHoodieDataSourceHelper.
@hudi-bot

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

@voonhous
voonhous enabled auto-merge (squash) July 23, 2026 07:14
@voonhous
voonhous merged commit 5a42f89 into apache:master Jul 23, 2026
77 of 78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants