Skip to content

Conversation

@Shekharrajak
Copy link
Contributor

[flink] Fix unstable test: handle MiniCluster shutdown gracefully in collect method

Purpose

Linked issue: close #5563

This PR fixes the unstable test PrimaryKeyFileStoreTableITCase.testNoChangelogProducerStreamingRandom by addressing a race condition in the collect method. The timeout thread was attempting to cancel jobs after the MiniCluster had already shut down, causing IllegalStateException and premature test termination. The fix follows the pattern used in Flink's CollectResultFetcher to gracefully handle shutdown scenarios.

Tests

  • Fixed PrimaryKeyFileStoreTableITCase.testNoChangelogProducerStreamingRandom which was failing intermittently with:
    • IllegalStateException: MiniCluster is not yet running or has already been shut down
    • Assertion failures due to incomplete data reading caused by premature job cancellation

The fix ensures that:

  1. When getJobStatus() throws an exception (e.g., MiniCluster shutdown), we assume the job has terminated instead of attempting cancellation
  2. Before cancelling, we check if the job is already in a terminal state
  3. All cancellation attempts are wrapped in try-catch to handle IllegalStateException gracefully
  4. Exceptions in the timeout thread no longer interfere with test execution

API and Format

No API or storage format changes.

Documentation

No documentation changes needed. This is a test stability fix.

@JingsongLi
Copy link
Contributor

Thanks @Shekharrajak for the contribution. +1

@JingsongLi JingsongLi merged commit bce56bf into apache:master Dec 28, 2025
23 checks passed
@Shekharrajak Shekharrajak deleted the fix-test-unstable-5563 branch December 28, 2025 16:34
jerry-024 added a commit to jerry-024/paimon that referenced this pull request Dec 29, 2025
* upstream/master: (51 commits)
  [test] Fix unstable test: handle MiniCluster shutdown gracefully in collect method (apache#6913)
  [python] fix ray dataset not lazy loading issue when parallelism = 1 (apache#6916)
  [core] Refactor ExternalPathProviders abstraction
  [spark] fix Merge Into unstable tests (apache#6912)
  [core] Enable Entropy Inject for data file path to prevent being throttled by object storage (apache#6832)
  [iceberg] support millisecond timestamps in iceberg compatibility mode (apache#6352)
  [spark] Handle NPE for pushdown aggregate when a datasplit has a null max/min value (apache#6611)
  [test] Fix unstable case testLimitPushDown
  [core] Refactor row id pushdown to DataEvolutionFileStoreScan
  [spark] paimon-spark supports row id push down (apache#6697)
  [spark] Support compact_database procedure (apache#6328) (apache#6910)
  [lucene] Fix row count in IndexManifestEntry
  [test] Remove unstable test: AppendTableITCase.testFlinkMemoryPool
  [core] Refactor Global index writer and reader for Btree
  [core] Minor refactor to magic number into footer
  [core] Support btree global index in paimon-common (apache#6869)
  [spark] Optimize compact for data-evolution table, commit multiple times to avoid out of memory (apache#6907)
  [rest] Add fromSnapshot to rollback (apache#6905)
  [test] Fix unstable RowTrackingTestBase test
  [core] Simplify FileStoreCommitImpl to extract some classes (apache#6904)
  ...
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.

[Bug] PrimaryKeyFileStoreTableITCase.testNoChangelogProducerStreamingRandom unstable

2 participants