Skip to content

fix: stop ticker to prevent goroutine leak in PeriodicProbeProviders#2214

Merged
nimrod-teich merged 2 commits into
mainfrom
fix/timer-leak-consumer-session-manager
Feb 15, 2026
Merged

fix: stop ticker to prevent goroutine leak in PeriodicProbeProviders#2214
nimrod-teich merged 2 commits into
mainfrom
fix/timer-leak-consumer-session-manager

Conversation

@nimrod-teich

Copy link
Copy Markdown
Contributor

The ticker created in PeriodicProbeProviders was not being stopped when the function returned via ctx.Done(). This caused a goroutine leak as the ticker's internal goroutine would continue running.

This fix adds defer ticker.Stop() to ensure the ticker is properly cleaned up when the function exits.

Description

Closes: #XXXX


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • read the contribution guide
  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the main branch
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

The ticker created in PeriodicProbeProviders was not being stopped
when the function returned via ctx.Done(). This caused a goroutine
leak as the ticker's internal goroutine would continue running.

This fix adds defer ticker.Stop() to ensure the ticker is properly
cleaned up when the function exits.
Add TestPeriodicProbeProvidersTickerCleanup with three test cases:
- Verify function exits promptly when context is cancelled
- Test multiple probe sessions all exit cleanly on cancellation
- Verify ticker fires and is properly cleaned up

These tests validate the fix that added defer ticker.Stop() to
prevent goroutine leaks when the function exits.
@pull-request-size pull-request-size Bot added size/L and removed size/XS labels Feb 1, 2026
@codecov

codecov Bot commented Feb 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
consensus 8.54% <ø> (ø)
protocol 33.86% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
protocol/lavasession/consumer_session_manager.go 62.27% <100.00%> (-0.50%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Feb 1, 2026

Copy link
Copy Markdown

Test Results

    7 files  ±0     85 suites  ±0   32m 3s ⏱️ + 1m 2s
3 341 tests +4  3 340 ✅ +4  1 💤 ±0  0 ❌ ±0 
3 534 runs  +4  3 533 ✅ +4  1 💤 ±0  0 ❌ ±0 

Results for commit 23198fa. ± Comparison against base commit 4479425.

@nimrod-teich nimrod-teich merged commit fb45ff4 into main Feb 15, 2026
31 checks passed
@nimrod-teich nimrod-teich deleted the fix/timer-leak-consumer-session-manager branch February 15, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants