Skip to content

Fix flaky testMmapResourcesReleasedOnClose by using /proc/self/maps instead of filesystem free space#142516

Merged
ChrisHegarty merged 2 commits intoelastic:mainfrom
ChrisHegarty:sharedBytes_mmap_test_fix
Feb 16, 2026
Merged

Fix flaky testMmapResourcesReleasedOnClose by using /proc/self/maps instead of filesystem free space#142516
ChrisHegarty merged 2 commits intoelastic:mainfrom
ChrisHegarty:sharedBytes_mmap_test_fix

Conversation

@ChrisHegarty
Copy link
Contributor

The test verified that mmap'd SharedBytes instances release their mapped memory on close by measuring filesystem free space before and after 100 create/close iterations. This was inherently flaky because getUsableSpace() reflects the entire filesystem and is affected by concurrent activity from parallel test workers, OS indexing, and other processes.

Replace the free-space assertion with a deterministic check of /proc/self/maps on Linux, which directly inspects the process's memory-mapped regions for leaked entries. Restrict the test to Linux since that is where /proc/self/maps is available and where CI runs.

The failing test is new. Introduced by #142460
closes #142488

@ChrisHegarty ChrisHegarty requested a review from fcofdez February 14, 2026 12:20
@ChrisHegarty ChrisHegarty added >test Issues or PRs that are addressing/adding tests Team:Distributed Meta label for distributed team. :Distributed/Searchable Snapshots Searchable snapshots / frozen indices. labels Feb 14, 2026
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (Team:Distributed)

Copy link
Contributor

@fcofdez fcofdez left a comment

Choose a reason for hiding this comment

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

LGTM

@ChrisHegarty ChrisHegarty merged commit d3a56c5 into elastic:main Feb 16, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed/Searchable Snapshots Searchable snapshots / frozen indices. Team:Distributed Meta label for distributed team. >test Issues or PRs that are addressing/adding tests v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CI] SharedBytesTests testMmapResourcesReleasedOnClose failing

3 participants