Skip to content

fix(server): memory leak in segment rotation#2686

Merged
spetz merged 1 commit intomasterfrom
fix_segment_leak
Feb 5, 2026
Merged

fix(server): memory leak in segment rotation#2686
spetz merged 1 commit intomasterfrom
fix_segment_leak

Conversation

@spetz
Copy link
Contributor

@spetz spetz commented Feb 5, 2026

Segment rotation accumulated memory indefinitely because sealed segments retained their 16MB index buffers and kept file writers open. Under heavy write load with frequent rotations, this caused memory to balloon from ~100MB to 20GB+.

The fix clears index buffers for sealed segments (when cache_indexes != All) and closes their writers immediately after sealing. Writers are never needed post-seal, and this also releases io_uring/kernel file handle resources.

@spetz spetz changed the title fix(server): memory leak in segment rotation, clear indexes and close… fix(server): memory leak in segment rotation Feb 5, 2026
@spetz spetz added performance Change impacts performance server iggy-servere related change rust Pull requests that update Rust code labels Feb 5, 2026
@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.78%. Comparing base (ff2da26) to head (2f67133).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2686      +/-   ##
==========================================
+ Coverage   69.69%   69.78%   +0.09%     
==========================================
  Files         568      568              
  Lines       55229    55238       +9     
  Branches    55229    55238       +9     
==========================================
+ Hits        38492    38550      +58     
+ Misses      14859    14809      -50     
- Partials     1878     1879       +1     
Flag Coverage Δ
rust 69.78% <100.00%> (+0.09%) ⬆️

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

Files with missing lines Coverage Δ
core/server/src/shard/system/segments.rs 86.66% <100.00%> (+8.09%) ⬆️

... and 7 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.

@hubcio
Copy link
Contributor

hubcio commented Feb 5, 2026

Nice. Please modify the segment rotation scenario to include probing for memory used by iggy-server when test ends so we will avoid this problem in future. Set it to some arbitrary value like 200MB.

mmodzelewski
mmodzelewski previously approved these changes Feb 5, 2026
@spetz spetz merged commit d98176a into master Feb 5, 2026
58 checks passed
@spetz spetz deleted the fix_segment_leak branch February 5, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Change impacts performance rust Pull requests that update Rust code server iggy-servere related change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants