Skip to content

[9.2](backport #49414) Fix race that can block managerV2 shutdown#49449

Closed
mergify[bot] wants to merge 1 commit into9.2from
mergify/bp/9.2/pr-49414
Closed

[9.2](backport #49414) Fix race that can block managerV2 shutdown#49449
mergify[bot] wants to merge 1 commit into9.2from
mergify/bp/9.2/pr-49414

Conversation

@mergify
Copy link
Copy Markdown
Contributor

@mergify mergify bot commented Mar 12, 2026

As described in #49388, BeatV2Manager can miss the shutdown signal because its Stop method notifies the manager by sending to its signal channel stopChan rather than closing it, but there are two goroutines that both listen on that channel.

This PR changes Stop to close the channel rather than just sending. It also removes the second stopChan listener in watchErrChan, since the main goroutine already calls the context canceler for that helper when stopChan unblocks (this isn't strictly necessary but it will keep error states visible for a little longer during shutdown, and is what was previously happening in the "good" path where the main worker received the stop signal first).

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works. Where relevant, I have used the stresstest.sh script to run them under stress conditions and race detector to verify their stability.
  • I have added an entry in ./changelog/fragments using the changelog tool.

Related issues


This is an automatic backport of pull request #49414 done by [Mergify](https://mergify.com).

As described in #49388, `BeatV2Manager` can miss the shutdown signal because its `Stop` method notifies the manager by sending to its signal channel `stopChan` rather than closing it, but there are two goroutines that both listen on that channel.

This PR changes `Stop` to close the channel rather than just sending. It also removes the second `stopChan` listener in `watchErrChan`, since the main goroutine already calls the context canceler for that helper when `stopChan` unblocks (this isn't strictly necessary but it will keep error states visible for a little longer during shutdown, and is what was previously happening in the "good" path where the main worker received the stop signal first).

(cherry picked from commit d39cb49)
@mergify mergify bot added the backport label Mar 12, 2026
@mergify mergify bot requested a review from a team as a code owner March 12, 2026 20:57
@mergify mergify bot requested review from VihasMakwana and orestisfl and removed request for a team March 12, 2026 20:57
@mergify mergify bot added the backport label Mar 12, 2026
@mergify mergify bot assigned faec Mar 12, 2026
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Mar 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@github-actions github-actions bot added bug Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team labels Mar 12, 2026
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Mar 12, 2026
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@mergify
Copy link
Copy Markdown
Contributor Author

mergify bot commented Mar 16, 2026

This pull request has not been merged yet. Could you please review and merge it @faec? 🙏

2 similar comments
@mergify
Copy link
Copy Markdown
Contributor Author

mergify bot commented Mar 23, 2026

This pull request has not been merged yet. Could you please review and merge it @faec? 🙏

@mergify
Copy link
Copy Markdown
Contributor Author

mergify bot commented Mar 30, 2026

This pull request has not been merged yet. Could you please review and merge it @faec? 🙏

@belimawr
Copy link
Copy Markdown
Contributor

belimawr commented Apr 1, 2026

Superseded by #49849

@belimawr
Copy link
Copy Markdown
Contributor

belimawr commented Apr 1, 2026

Closing as #49849 already contains those changes.

@belimawr belimawr closed this Apr 1, 2026
@mergify mergify bot deleted the mergify/bp/9.2/pr-49414 branch April 1, 2026 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport bug Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants