feat(metrics): track thread pool backlog#358
Conversation
yordis
commented
May 14, 2026
- Operators need visibility into work queued outside the node's named internal queues.
- Thread-pool pressure should appear in the same telemetry surface operators already use for queue health.
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis PR introduces thread pool backlog monitoring to Event Store by adding a new ChangesThread Pool Backlog Monitoring
Sequence DiagramsequenceDiagram
participant VNode as ClusterVNode
participant Monitor as ThreadPoolBacklogMonitor
participant Timer as System.Threading.Timer
participant QueueStats as QueueStatsCollector
participant QueueMon as QueueMonitor.Default
VNode->>Monitor: Start()
Monitor->>QueueStats: Start()
Monitor->>QueueMon: Register()
Monitor->>Timer: Enqueue first work item
loop Sample cycle (while not stopped)
Timer->>Monitor: Execute()
Monitor->>Monitor: Capture pending count
Monitor->>QueueStats: ProcessingStarted()
Monitor->>QueueStats: ReportQueueLength()
Monitor->>QueueStats: ProcessingFinished()
Monitor->>Timer: Re-arm if not stopped
end
VNode->>Monitor: Stop() / Dispose()
Monitor->>Timer: Cancel
Monitor->>QueueMon: Unregister()
Monitor->>QueueStats: Stop()
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR SummaryMedium Risk Overview Refactors Reviewed by Cursor Bugbot for commit 2d98f10. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d460a51. Configure here.
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/EventStore.Core/Bus/QueueStatsCollector.cs`:
- Around line 97-101: ReportQueueLength updates non-atomic peaks
(_lifetimeQueueLengthPeak, _currentQueueLengthPeak) and can race with calls from
ProcessingStarted and GetStatistics; replace the Math.Max read-compare-write
with atomic Interlocked-based updates: use Interlocked.CompareExchange loops (or
Interlocked.Exchange/Read patterns) to update _lifetimeQueueLengthPeak and
_currentQueueLengthPeak only if the new queueLength is greater, leaving
_statisticsLock usage in GetStatistics unchanged; reference ReportQueueLength,
_lifetimeQueueLengthPeak, _currentQueueLengthPeak, ProcessingStarted,
GetStatistics and _statisticsLock when making the change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 50e56702-7fc8-40f7-9f66-1d95a4582e52
📒 Files selected for processing (5)
src/EventStore.ClusterNode/metricsconfig.jsonsrc/EventStore.Core.XUnit.Tests/Metrics/QueueStatsCollectorTests.cssrc/EventStore.Core/Bus/QueueStatsCollector.cssrc/EventStore.Core/ClusterVNode.cssrc/EventStore.Core/Metrics/ThreadPoolBacklogMonitor.cs
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
