router: cleanup pending entries once exporter and client are connected#164
Conversation
|
Warning Rate limit exceeded
⌛ 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. 📝 WalkthroughWalkthroughThe RouterService.Stream method now ensures pending entry cleanup in both code paths: deleting immediately when a second peer connects, and scheduling deferred cleanup when the first peer connects. This guarantees removal of pending map entries that previously could persist longer than intended. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@controller/internal/service/router_service.go`:
- Around line 102-103: There is a race where the deferred cleanup
unconditionally calls s.pending.Delete(streamName) and can remove a newer entry;
fix by making the cleanup identity-checked so we only delete if the map still
holds the same streamContext instance (the one stored as sctx). Replace the
unconditional s.pending.Delete(streamName) in the peer cleanup/defer with either
a conditional check that reads the current value and deletes only if it equals
sctx, or (since we target Go 1.24) call s.pending.CompareAndDelete(streamName,
sctx) in the defer; ensure you reference the stored streamContext variable (sctx
/ streamContext) when performing the compare-and-delete to avoid removing newer
entries.
Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
7d82d7b to
e674da7
Compare
address #161
Summary by CodeRabbit
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.