Skip to content

fix(mempool): prevent memory leaks in PriorityNonceMempool Remove#25858

Open
songgaoye wants to merge 13 commits intocosmos:mainfrom
songgaoye:fix_pritority_pool_delete
Open

fix(mempool): prevent memory leaks in PriorityNonceMempool Remove#25858
songgaoye wants to merge 13 commits intocosmos:mainfrom
songgaoye:fix_pritority_pool_delete

Conversation

@songgaoye
Copy link
Copy Markdown
Contributor

Description

clean up empty data structures in the Remove function to prevent memory leaks:

  • delete sender indices when the last transaction for a sender is removed
  • delete priority count entries when they reach zero

Closes: #XXXX

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.85%. Comparing base (0886f83) to head (b589a94).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #25858      +/-   ##
==========================================
- Coverage   64.87%   64.85%   -0.03%     
==========================================
  Files         890      874      -16     
  Lines       58581    57603     -978     
==========================================
- Hits        38006    37358     -648     
+ Misses      20575    20245     -330     
Files with missing lines Coverage Δ
types/mempool/priority_nonce.go 90.70% <100.00%> (-1.64%) ⬇️

... and 19 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aljo242
Copy link
Copy Markdown
Contributor

aljo242 commented Feb 3, 2026

Can we test this?

Is there a bug or behavior failure this is addressing?

@songgaoye
Copy link
Copy Markdown
Contributor Author

add unit test TestPriorityNonceMempool_CleanupOnRemove exerecise the cleanup added in PriorityNonceMempool.Remove.

Before the fix, removing the last tx for a sender left an empty skip list in senderIndices and a zero entry in priorityCounts. Those stale structures accumulated over time, effectively leaking memory and preventing IsEmpty from ever succeeding after deletes.

@aljo242
Copy link
Copy Markdown
Contributor

aljo242 commented Feb 11, 2026

@songgaoye lgtm - conflicts

@songgaoye
Copy link
Copy Markdown
Contributor Author

update. please take a look at @aljo242 .

@swift1337 swift1337 requested a review from a team as a code owner April 24, 2026 15:14
@swift1337 swift1337 enabled auto-merge April 24, 2026 15:15
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.

3 participants