Skip to content

Conversation

leehinman
Copy link
Contributor

Proposed commit message

Fix race condition in beat LoadMeta function. If 2 (or more) beats had the same path to the meta file, then it was possible for one not to start. This would only affect beat receivers because a normal beat requires a unique path to the meta file.

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
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Disruptive User Impact

Author's Checklist

  • [ ]

How to test this PR locally

cd libbeat/cmd/instance
go test . -v -count 1 -run TestMultipleLoadMeta

Related issues

Use cases

Screenshots

Logs

@leehinman leehinman added Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team backport-8.x Automated backport to the 8.x branch with mergify backport-9.1 Automated backport to the 9.1 branch labels Sep 29, 2025
@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Sep 29, 2025
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

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

@leehinman leehinman force-pushed the 46841_load_meta_race_condition branch from 5e0930e to 439c766 Compare September 30, 2025 19:20
Copy link
Contributor

mergify bot commented Oct 1, 2025

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b 46841_load_meta_race_condition upstream/46841_load_meta_race_condition
git merge upstream/main
git push upstream 46841_load_meta_race_condition

@leehinman leehinman force-pushed the 46841_load_meta_race_condition branch from 439c766 to be310b9 Compare October 1, 2025 04:38
@leehinman leehinman marked this pull request as ready for review October 1, 2025 19:14
@leehinman leehinman requested a review from a team as a code owner October 1, 2025 19:14
@elasticmachine
Copy link
Collaborator

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

Copy link
Member

@cmacknz cmacknz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test fails if you go back to using just os.OpenFile so this fixes things as expected 👍

@leehinman leehinman merged commit 89721e6 into elastic:main Oct 2, 2025
211 checks passed
mergify bot pushed a commit that referenced this pull request Oct 2, 2025
* fix race condition in beat LoadMeta

(cherry picked from commit 89721e6)
mergify bot pushed a commit that referenced this pull request Oct 2, 2025
* fix race condition in beat LoadMeta

(cherry picked from commit 89721e6)
leehinman added a commit that referenced this pull request Oct 2, 2025
* fix race condition in beat LoadMeta

(cherry picked from commit 89721e6)

Co-authored-by: Lee E Hinman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8.x Automated backport to the 8.x branch with mergify backport-9.1 Automated backport to the 9.1 branch backport-9.2 skip-changelog 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.

[beat] LoadMeta has a race condition.
3 participants