Skip to content

Conversation

@pdolif
Copy link
Contributor

@pdolif pdolif commented Oct 5, 2025

Fixes #24814

Motivation

The test is flaky. It works like this:

  1. Schedule a task incrementing a counter to run every 50ms.
  2. Wait 200ms so that the task is executed a few times.
  3. Get task execution count and verify it is greater than 0.
  4. Cancel the task.
  5. Wait 200ms.
  6. Verify execution count is still the same as before cancelling the task (take count from step 3).

What can happen is that between getting the execution count in step 3 and cancelling the task in step 4, another execution is started. Then the assertion in step 6 fails because one additional execution took place.

Modifications

Change the assertion in step 6 to allow one additional execution. This still verifies that the scheduled task is cancelled because we wait 200ms in step 5, and more than one additional execution would be expected if the task is not cancelled properly.

Verifying this change

  • Make sure that the change passes the CI checks.

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: pdolif#16

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Oct 5, 2025
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.21%. Comparing base (008e4eb) to head (1239635).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #24823      +/-   ##
============================================
- Coverage     74.42%   74.21%   -0.22%     
+ Complexity    33488    33388     -100     
============================================
  Files          1912     1912              
  Lines        149077   149077              
  Branches      17300    17300              
============================================
- Hits         110950   110636     -314     
- Misses        29331    29603     +272     
- Partials       8796     8838      +42     
Flag Coverage Δ
inttests 26.48% <ø> (-0.22%) ⬇️
systests 22.72% <ø> (-0.17%) ⬇️
unittests 73.75% <ø> (-0.20%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 103 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lhotari lhotari added this to the 4.2.0 milestone Oct 7, 2025
@lhotari lhotari merged commit 7d35d7c into apache:master Oct 7, 2025
97 of 100 checks passed
lhotari pushed a commit that referenced this pull request Oct 8, 2025
….testPeriodicTaskCancellation (#24823)

(cherry picked from commit 7d35d7c)
walkinggo pushed a commit to walkinggo/pulsar that referenced this pull request Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky-test: SingleThreadNonConcurrentFixedRateSchedulerTest.testPeriodicTaskCancellation

3 participants