Skip to content

[Bug]: Spark ValidatesRunner PostCommits red since parallel test threads (#40324) #40427

Closed

Description

@tkaymak

What happened?

Since #40324 (merged 2026-10-01), every Spark ValidatesRunner PostCommit on master is red. Last green runs were 2026-10-01 16:47 UTC, first red 2026-10-01 22:46 UTC.

Affected: beam_PostCommit_Java_ValidatesRunner_Spark, beam_PostCommit_Java_ValidatesRunner_SparkStructuredStreaming, beam_PostCommit_Java_ValidatesRunner_Spark4, beam_PostCommit_Java_PVR_Spark_Batch, beam_PostCommit_Java_PVR_Spark3_Streaming, beam_PostCommit_Java_PVR_Spark4_Batch, beam_PostCommit_Java_PVR_Spark4_Streaming, beam_PostCommit_Java_PVR_Spark4_StructuredStreaming. Flink and Direct stay green.

Symptoms: 100 to 200 tests per run fail with Expected 1 successful assertions, but found 4 (or 0), the failing set differs between runs. The PVR suites fail with Only one SparkContext should be running in this JVM.

Cause: #40324 sets beam.test.parallelThreads=8 for every Test task. BeamParallelJunit4Runner.selectExecutor falls back from beam.validatesRunner.parallelThreads to that value, so every runner's ValidatesRunner suite became parallel without an opt in. Dataflow opts in explicitly in its build.gradle. The Spark runners keep metrics in a JVM wide MetricsAccumulator singleton, cleared on every run(), and allow one SparkContext per JVM, so concurrent pipelines mix or reset each other's PAssert counters.

Fix: set beam.validatesRunner.parallelThreads=1 for the Spark runner and Spark job server test tasks, as the Dataflow runner already sets its own value. Per pipeline metrics in the Spark runners would allow parallel tests later. A default of 1 for beam.validatesRunner.parallelThreads in BeamParallelJunit4Runner would protect other runners too.

Issue Priority

Priority: 2 (default / most bugs should be filed as P2)

Issue Components

  • Component: Java SDK
  • Component: Spark Runner

Activity

  1. tkaymak commented on Oct 6, 2026

    @tkaymak
    ContributorAuthor

    .take-issue

  2. added a commit that references this issue on Oct 6, 2026
    32d54e8
  3. added this to the 2.78.0 Release milestone on Oct 6, 2026
  4. added a commit that references this issue on Oct 6, 2026
    bfff19a
  5. tkaymak commented on Oct 6, 2026

    @tkaymak
    ContributorAuthor

    @Abacn #40428 fixed Spark with the Spark only setting, thanks for merging. On the PR you first suggested defaulting beam.validatesRunner.parallelThreads to 1 in BeamParallelJunit4Runner, so runners opt in like Dataflow does. Do you still want that as a follow up? I have it ready as a small change with a test, plus an opt in for the Direct runner to keep the PreCommit Java speedup from #40324. Happy to drop it if the Spark fix is enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions