Skip to content

fix(obs): prune automatic heap dumps before counting the dump - #1363

Merged
jarvis9443 merged 2 commits into
mainfrom
fix/heap-profile-prune-before-count
Oct 27, 2026
Merged

jarvis9443 merged 2 commits into
mainfrom
fix/heap-profile-prune-before-count

Conversation

@jarvis9443

Copy link
Copy Markdown
Contributor

The automatic heap-dump thread incremented aisix_heap_profile_dumps_total{trigger="auto",result="ok"} before it pruned the dump directory down to keep. Anyone who watches the counter and then lists the directory can land between the two and see keep + 1 files. That is exactly what memory-observability-e2e does, and it went red on main intermittently (keep: 2 leaves the two newest of three: expected [ …(3) ] to have a length of 2 but got 3).

The fix moves prune ahead of the success counter (and the log line), so the metric only counts a dump once retention has been applied. No test change: the existing e2e case is the regression test. With a 1.5s sleep inserted between the counter and the prune on the old ordering it fails with the same assertion every time; with the new ordering it passes, including with the same sleep placed between the prune and the counter.

The manual /debug/pprof/heap dump is the only other dump site. It streams the profile in the response, writes no file and prunes nothing, so it has no equivalent window.

No behavior change beyond ordering: the same files are kept and the same counter values are reached.

🤖 Generated with Claude Code

The auto-dump thread recorded aisix_heap_profile_dumps_total{trigger=auto,result=ok}
before applying the keep retention, so anyone who saw the counter move could
still list keep+1 files in the dump directory. Prune first, then count.
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 1 billable file and costs up to $0.25.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 6 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available. Your 54 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 12243a4c-a8c1-4387-a085-02ed137663b5
Commits

Reviewing files that changed from the base of the PR and between 23b3288 and 338c67b.

Files selected for processing: 1
  • crates/aisix-obs/src/heap_profile.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@jarvis9443
jarvis9443 merged commit 7841666 into main Oct 27, 2026
19 checks passed
@jarvis9443
jarvis9443 deleted the fix/heap-profile-prune-before-count branch October 27, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant