Roll back dedup cache entry when inbound queue insertion fails - #8697
zhangchiqing wants to merge 1 commit into
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (9)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe change adds queue-full inbound drop metrics, implements the metric across collectors and mocks, and removes receive-cache entries when queue insertion fails so retransmissions can be accepted. ChangesQueue-full inbound message handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The rollback and metric contracts are consistently implemented and covered by regression tests; no merge-blocking risk is established. Sequence Diagram(s)sequenceDiagram
participant Network as processNetworkMessage
participant ReceiveCache
participant InboundQueue
participant Metrics
Network->>ReceiveCache: Add event ID
Network->>InboundQueue: Insert inbound message
InboundQueue-->>Network: queue.ErrQueueFull
Network->>ReceiveCache: Remove event ID
Network->>Metrics: QueueFullInboundMessagesDropped
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 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 |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Problem
processNetworkMessageadds an incoming message's event ID to the dedup (receive) cache before inserting it into the inbound queue. If the queue is full, insertion fails but the cache entry is never rolled back. Since the event ID is a hash of channel and payload only (no sender), a later retransmission of the same payload — from any publisher — is dropped as a duplicate and never reaches its engine. The entry eventually ages out via LRU eviction, so the effect is bounded, but the message is incorrectly treated as seen until then.Queue-full drops are also currently only visible as a Warn log; there is no metric.
Changes
ReceiveCache.Remove: new method so a dedup entry can be rolled back.processNetworkMessage: on queue insertion failure, remove the event ID from the dedup cache. The goroutine that successfully added the entry exclusively owns it until removal (concurrent duplicates getfalsefromAddand drop), so the rollback cannot remove another goroutine's entry.QueueFullInboundMessagesDroppedmetric (channel/protocol/message-type labels, cluster topics normalized) emitted on queue-full drops, making inbound back-pressure observable.Tests
network/cache:TestRemovecovers the newReceiveCache.Remove.network/underlay: regression test asserting that after a queue-full drop, the event ID does not remain in the dedup cache, the metric is emitted, and a retransmission of the same payload from a different publisher is accepted. Verified to fail at the rollback assertion without the fix; passes with-race.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
New Features
Bug Fixes
Tests