Paolo/txpool metrics#1619
Open
paologalligit wants to merge 2 commits into
Open
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
libotony
reviewed
May 25, 2026
| executable bool // don't touch this value, will be updated by the pool | ||
| // executable is updated by the pool. Accessed concurrently from wash, Remove and | ||
| // metric helpers | ||
| executable atomic.Bool |
Member
There was a problem hiding this comment.
My understading is executable does not have a race condition as it is well managed in the pool, it's fine for the metrics handler to have a snapshot of this value, no need to mark it atomic.
Member
Author
There was a problem hiding this comment.
There's a tiny chance of a race condition in:
wash(): while runningExecutable()it writeso.payer = &payerando.cost = prepaid.- if
packerpacked that tx, then it callsRemove(): it callsRemoveByHash, which readstxObj.Payer()andtxObj.Cost()under the map lock, but theTxObjectfields aren't covered by that lock.
It looks a very rare case, but probably it should be addressed. I can revert the atomic bool and introduce this fix in a follow-up PR, if you prefere
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This updates txpool metrics so
txpool_current_tx_countrepresents the current pool contents bysource,type, andstatus, instead of mixing add/remove deltas with synthetic sources likewashedorn/a.Txs now track their source explicitly —
local,remote, orfill— and their status (executable/non_executable) is reflected on the gauge label.Wash removals decrement the current-count gauge using the removed tx's real labels and also increment a separate
txpool_washed_tx_count{source,type}counter.TxObject.executableis nowatomic.Boolso the metric helper can read it safely from concurrentRemoveandwashpaths.The internal
wash()return surface is collapsed to a singleremoved int; the per-type breakdown now lives only on the counter.NOTE — Backward-incompatible changes
Dashboards / alerts:
txpool_current_tx_countgains a newstatuslabel (executable|non_executable). Existing grafana queries that sums or groups the gauge must usesum without(status)to reproduce the old totals; otherwise series will double-count or appear as separate rows.source="washed"andsource="n/a"are no longer emitted ontxpool_current_tx_count. Any panel or alert filtering on those values will go silent. The per-source/per-type wash rate now lives on the newtxpool_washed_tx_count{source,type}counter — switch wash dashboards torate(txpool_washed_tx_count[...]).source="fill"instead ofsource="remote".Checklist: