fix(topic): add read-ahead buffer flow control to TopicListener#2234
fix(topic): add read-ahead buffer flow control to TopicListener#2234kprokopenko wants to merge 5 commits into
Conversation
Centralize BufferSize accounting in streamListener (like topic reader) so partition workers release credits instead of sending per-partition ReadRequests. Co-authored-by: Cursor <cursoragent@cursor.com>
github.com/ydb-platform/ydb-go-sdk/v3/topic/topicoptionscompatible changesWithListenerBufferSizeBytes: added summaryInferred base version: v3.143.0 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2234 +/- ##
==========================================
+ Coverage 75.43% 75.48% +0.05%
==========================================
Files 445 445
Lines 45996 46043 +47
==========================================
+ Hits 34698 34757 +59
+ Misses 9343 9332 -11
+ Partials 1955 1954 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Cover queued batch drain on handler error, metadata validation failures, freeBytes coalescing, end-to-end credit return, and send error handling. Co-authored-by: Cursor <cursoragent@cursor.com>
Add tests for newStreamListener seed, StopPartition routing, shutdown free-buffer branches, and WithListenerBufferSizeBytes option. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
AI Review Summary
Verdict: ✅ No critical issues found
Critical issues
No critical issues found.
Other findings
- Minor | High: Missing zero-size guard in
freeBufferFromBatch— can send pointlessReadRequest{BytesSize: 0}to the server —internal/topic/topiclistenerinternal/stream_listener.go:554 - Minor | Medium:
sendDataRequestinsendMessagesLoopfreeBytes case goes throughsendMessage, causing a spurioushasNewMessagesToSendsignal and redundant empty flush on the next select iteration —internal/topic/topiclistenerinternal/stream_listener.go:283 - Nit | Low:
WithListenerBufferSizeBytesaccepts zero/negative values silently; validation happens later inValidate()but the godoc doesn't mention the constraint —topic/topicoptions/topicoptions_listener.go:19
This review was generated automatically. Critical issues require attention; other findings are advisory.
If this comment was useful, please give it a 👍 — it helps us improve the review bot.
|
Analysis performed by claude, claude-opus-4-6. |
- Skip zero-size ReadRequest in freeBufferFromBatch when nothing was charged. - Enqueue the coalesced ReadRequest without signaling hasNewMessagesToSend in the freeBytes case, avoiding a stale signal and a redundant empty flush. - Document that WithListenerBufferSizeBytes requires a positive value. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
TopicListener, matching the topic reader model: one sharedBufferSizelimit across all partitions viafreeBytesandsendMessagesLoop.FreeBufferFromBatch(including on handler errors and queued batches on shutdown) instead of sending per-partitionReadRequestmessages.topicoptions.WithListenerBufferSizeBytesoption (default 1 MiB, same as topic reader).Test plan
go test -race ./internal/topic/topiclistenerinternal/... ./internal/xsync/...golangci-lint run ./...go test -race ./...Made with Cursor