logpuller: split subscription runtime helpers from subscription client#5603
logpuller: split subscription runtime helpers from subscription client#5603lidezhu wants to merge 8 commits into
Conversation
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
📝 WalkthroughWalkthroughThe subscriptionClient in logpuller is restructured: dynstream event delivery, region failure handling, and subscribed-span lifecycle management (resolve-lock checking, slow-region logging, metrics) are extracted into three new components—regionEventSink, regionFailureHandler, and spanRegistry—with subscription_client.go and its tests updated to delegate to them. ChangesSubscription client decomposition
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 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 |
There was a problem hiding this comment.
Code Review
This pull request refactors the logpuller package by modularizing subscriptionClient and extracting its responsibilities into dedicated components: regionEventSink for managing event streams, regionFailureHandler for error dispatching, and spanRegistry for tracking subscribed spans. Additionally, a pullerMemoryQuota is introduced to handle memory backpressure. Feedback on these changes highlights a missing memoryQuota field and initialization in subscriptionClient that would cause compilation errors and nil pointer dereferences. The review also recommends cleaning up unused fields and methods in errCache, and refactoring the sync.Cond synchronization in regionEventSink to a safer, channel-based signaling mechanism to prevent goroutine leaks during context cancellation.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
logservice/logpuller/span_registry.go (1)
274-312: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win
logSlowRegionsholdsRLockacrossIterAll+ logging for all spans.Unlike
runResolveLockChecker(which snapshots intospanAndTsCacheand releases the lock before doing work), this loop performsrangeLock.IterAll(nil)and emitslog.Infofor every span while still holdingr.RLock(). With many spans this can stallAdd/Remove(i.e.Subscribe/Unsubscribe) for the duration of the scan. Consider snapshotting the spans (or their attrs) under the read lock and logging outside it, mirroring the resolve-lock checker.🤖 Prompt for 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. In `@logservice/logpuller/span_registry.go` around lines 274 - 312, The `logSlowRegions` loop in `spanRegistry` is holding `r.RLock()` while calling `rangeLock.IterAll(nil)` and emitting multiple `log.Info` entries, which can block `Subscribe`/`Unsubscribe` for the full scan. Update `logSlowRegions` to snapshot the needed span/attr data under the read lock, then release the lock before doing the time checks and logging, following the same pattern used by `runResolveLockChecker` and its `spanAndTsCache`.
🤖 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.
Nitpick comments:
In `@logservice/logpuller/span_registry.go`:
- Around line 274-312: The `logSlowRegions` loop in `spanRegistry` is holding
`r.RLock()` while calling `rangeLock.IterAll(nil)` and emitting multiple
`log.Info` entries, which can block `Subscribe`/`Unsubscribe` for the full scan.
Update `logSlowRegions` to snapshot the needed span/attr data under the read
lock, then release the lock before doing the time checks and logging, following
the same pattern used by `runResolveLockChecker` and its `spanAndTsCache`.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 069e02a2-3506-4694-8d51-b16be08fedd8
📒 Files selected for processing (7)
logservice/logpuller/region_event_handler.gologservice/logpuller/region_event_sink.gologservice/logpuller/region_failure_handler.gologservice/logpuller/region_request_worker_test.gologservice/logpuller/span_registry.gologservice/logpuller/subscription_client.gologservice/logpuller/subscription_client_test.go
|
/gemini summary |
Summary of ChangesThis pull request refactors the log puller's subscription client to improve modularity and maintainability. By decomposing the monolithic subscription client into specialized components, the system gains better separation of concerns regarding event processing, error recovery, and span lifecycle management. These changes facilitate more robust handling of region events and failures while simplifying the codebase for future development. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Activity
|
|
/test all |
What problem does this PR solve?
Issue Number: close #5604
What is changed and how it works?
This pull request refactors the log puller's subscription client to improve modularity and maintainability. By decomposing the monolithic subscription client into specialized components, the system gains better separation of concerns regarding event processing, error recovery, and span lifecycle management. These changes facilitate more robust handling of region events and failures while simplifying the codebase for future development.
Highlights
regionEventSink,regionFailureHandler, andspanRegistry.Check List
Tests
Questions
Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?
Release note
Summary by CodeRabbit
New Features
Bug Fixes
Refactor