Skip to content

Fix slot memory accounting after IDMP expiry - #15887

Merged
sggeorgiev merged 6 commits into
redis:unstablefrom
perfloop-oss:perfloop-pr-open-cvnnzekvej
Oct 28, 2026
Merged

sggeorgiev merged 6 commits into
redis:unstablefrom
perfloop-oss:perfloop-pr-open-cvnnzekvej

Conversation

@perfloop-agent

@perfloop-agent perfloop-agent commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

The IDMP expiry cron now reconciles a stream's slot memory charge after expired entries and producer trees are removed. When it removes the last producer, the expiry index can release its key reference, so the update uses the key retained by the stream object.

The regression is in the existing tests/unit/cluster/slot-stats.tcl suite. With memory tracking enabled at startup, it checks the keeper-only slot baseline after deleting streams with fully drained and partially expired IDMP histories. The strict Werror/TLS build, slot-stats unit, diskless-replication expiry cases, and focused AddressSanitizer regression pass. The comparison script and temporary test hooks are not included in the pull request.

This condition holds with this change and does not hold at 6b8be852fc961301ec96d38f68dda08a0b0fedf9: In cluster mode with cluster-slot-stats-enabled mem at startup, after IDMP cron expiry and deletion of the stream key, CLUSTER SLOT-STATS memory-bytes for its hash slot equals the pre-stream baseline for both drained and partially expired producer histories..

This repairs the per-slot CLUSTER SLOT-STATS accounting counter; it does not establish a physical heap leak.

The required 32-bit build was not run in this environment; upstream CI must confirm it.


Generated by Perfloop. Human sponsor: Tomás Senart.


Note

Medium Risk
Touches cron-driven stream IDMP cleanup and cluster per-slot memory counters; behavior is gated on memory tracking and uses careful key lifetime handling after dict deletes.

Overview
Fixes cluster slot memory accounting when the IDMP expiry cron removes expired producer state from streams.

The cron now records the stream kvobj size before pruning, and when expiry actually changes the object it calls updateSlotAllocSize so CLUSTER SLOT-STATS memory-bytes matches freed IDMP data. It no longer continues immediately after dropping the last producer from the expiry index, so that reconciliation still runs. The slot update uses kvobjGetKey(kv) because removing the stream from stream_idmp_keys can free the iterator’s key pointer.

Adds a cluster unit test (with DEBUG ALLOCSIZE-SLOTS-ASSERT) that checks slot memory after fully drained and partially expired IDMP histories, then DEL on the stream, against a keeper-only baseline.

Reviewed by Cursor Bugbot for commit 11915ee. Bugbot is set up for automated code reviews on this repo. Configure here.

@CLAassistant

CLAassistant commented Sep 29, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@tsenart

tsenart commented Oct 14, 2026

Copy link
Copy Markdown

Hi, I'm Tomás, I build Perfloop. I approved this contribution and will handle review feedback here.

We've had performance PRs merged in ClickHouse, Prometheus, Ruff/ty, parquet-go, RoaringBitmap, and more. This one fixes slot memory accounting after IDMP expiry. Happy to reshape anything to fit how you'd like it.

@sundb
sundb requested a review from sggeorgiev October 15, 2026 02:49
@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.28%. Comparing base (20bb2cf) to head (11915ee).
⚠️ Report is 55 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable   #15887      +/-   ##
============================================
+ Coverage     77.50%   78.28%   +0.78%     
============================================
  Files           146      155       +9     
  Lines         88000    90190    +2190     
============================================
+ Hits          68203    70606    +2403     
+ Misses        19797    19584     -213     
Files with missing lines Coverage Δ
src/t_stream.c 93.31% <ø> (-0.53%) ⬇️

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

Comment thread src/t_stream.c Resolved
Signed-off-by: Perfloop Agent <[email protected]>
Signed-off-by: Tomás Senart <[email protected]>
Comment thread src/t_stream.c Resolved
Removing the last producer already sets modified, so the empty-tree path reaches the slot-size update without the extra assignment. The regression now asserts the producer counts before expiry.

Signed-off-by: Perfloop Agent <[email protected]>
Signed-off-by: Tomás Senart <[email protected]>
Comment thread tests/unit/cluster/slot-stats.tcl Resolved
Signed-off-by: Perfloop Agent <[email protected]>
Co-authored-by: Tomás Senart <[email protected]>
Comment thread tests/unit/cluster/slot-stats.tcl Resolved
Comment thread tests/unit/cluster/slot-stats.tcl Resolved
@tsenart

tsenart commented Oct 28, 2026

Copy link
Copy Markdown

Hi @sundb! Thanks for your reviews. Anything else you'd like us to do to wrap up this PR?

@sggeorgiev
sggeorgiev merged commit c2aa399 into redis:unstable Oct 28, 2026
19 checks passed
@sundb sundb added the release-notes indication that this issue needs to be mentioned in the release notes label Oct 29, 2026
@sundb

sundb commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

@sggeorgiev do we need to backport this fix to old versions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes indication that this issue needs to be mentioned in the release notes

Projects

Development

Successfully merging this pull request may close these issues.

5 participants