logpuller: send CDC scan priority#5480
Conversation
|
Skipping CI for Draft Pull Request. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR adds scan-priority scheduling in logpuller, threads ChangesScan Priority Scheduling and ChangefeedID Threading
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant RegionEventHandler
participant SubscriptionClient
participant RegionRequestWorker
participant cdcpb.ChangeDataRequest
RegionEventHandler->>SubscriptionClient: maybeEnableRealtimeScanPriority(span, resolvedTs)
SubscriptionClient->>SubscriptionClient: newSubscribedSpan(changefeedID, ...)
SubscriptionClient->>SubscriptionClient: initial priority + effectiveScanTaskPriority
SubscriptionClient->>RegionRequestWorker: scheduleRegionRequest / scheduleRangeRequest
RegionRequestWorker->>cdcpb.ChangeDataRequest: createRegionRequest(ScanPriority)
SubscriptionClient->>SubscriptionClient: doHandleError(retryPriority)
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
There was a problem hiding this comment.
Code Review
This pull request updates the kvproto dependency and introduces support for preserving scan priority across retries when handling congested or busy server errors in logpuller. It adds mapping utilities between TaskType and cdcpb.ScanPriority, stores the scan priority in regionInfo, and ensures it is propagated and maintained during retries. Comprehensive unit tests are also added to verify these mappings and retry behaviors. I have no feedback to provide.
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.
Signed-off-by: hongyunyan <649330952@qq.com>
Signed-off-by: hongyunyan <649330952@qq.com>
|
[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 |
Signed-off-by: hongyunyan <649330952@qq.com>
Signed-off-by: hongyunyan <649330952@qq.com>
Signed-off-by: hongyunyan <649330952@qq.com>
Signed-off-by: hongyunyan <649330952@qq.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
logservice/logpuller/subscription_client_test.go (1)
537-731: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueWell-structured coverage of scan-priority behavior; minor duplication across new tests.
Assertions for
TestInitialScanTaskPriority,TestSubscribeUsesInitialScanTaskPriority,TestRealtimeScanPriorityEnabledAfterSubscriptionCatchesUp, and the retry-upgrade tests all match the priority computation/upgrade logic shown insubscription_client.go(initialScanTaskPriority,maybeEnableRealtimeScanPriority,effectiveScanTaskPriority,doHandleError).The
rawSpan/subscribedSpan/regionInfoconstruction block (Lines 406-417, 480-491, 666-678, 695-707) is duplicated near-verbatim across four test functions. Consider extracting a small helper (e.g.newTestRegionWithScanPriority(t, subID, priority)) to reduce duplication and ease future maintenance.🤖 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/subscription_client_test.go` around lines 537 - 731, The new scan-priority tests repeat the same raw span, subscribed span, and region setup in several places, so factor that shared construction into a small helper to keep the tests maintainable. Extract the repeated setup around TestInitialScanTaskPriority, TestSubscribeUsesInitialScanTaskPriority, TestRealtimeScanPriorityEnabledAfterSubscriptionCatchesUp, and the retry-upgrade tests into a helper such as newTestRegionWithScanPriority or newTestSubscribedSpan, then reuse it while keeping each test focused on its specific priority assertion.
🤖 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/subscription_client_test.go`:
- Around line 537-731: The new scan-priority tests repeat the same raw span,
subscribed span, and region setup in several places, so factor that shared
construction into a small helper to keep the tests maintainable. Extract the
repeated setup around TestInitialScanTaskPriority,
TestSubscribeUsesInitialScanTaskPriority,
TestRealtimeScanPriorityEnabledAfterSubscriptionCatchesUp, and the retry-upgrade
tests into a helper such as newTestRegionWithScanPriority or
newTestSubscribedSpan, then reuse it while keeping each test focused on its
specific priority assertion.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2d06ba2b-1f41-4995-9b2f-4421ea62b717
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (14)
go.modlogservice/eventstore/event_store.gologservice/eventstore/event_store_test.gologservice/logpuller/priority_task.gologservice/logpuller/priority_task_test.gologservice/logpuller/region_event_handler.gologservice/logpuller/region_req_cache_test.gologservice/logpuller/region_request_worker.gologservice/logpuller/region_request_worker_test.gologservice/logpuller/region_state.gologservice/logpuller/subscription_client.gologservice/logpuller/subscription_client_test.gologservice/schemastore/ddl_job_fetcher.gopkg/config/debug.go
Signed-off-by: hongyunyan <649330952@qq.com>
Signed-off-by: hongyunyan <649330952@qq.com>
Signed-off-by: hongyunyan <649330952@qq.com>
Signed-off-by: hongyunyan <649330952@qq.com>
Signed-off-by: hongyunyan <649330952@qq.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
metrics/grafana/ticdc_new_arch.json (1)
22661-22745: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMinor: count-panel Y-axis format inconsistent with similar panels.
Queue Length and Running panels use
"format": "none"for the count axis, whereas a similar counter panel ("Unresolved Region Request Count") uses"format": "short". Purely cosmetic.Also applies to: 22746-22851
🤖 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 `@metrics/grafana/ticdc_new_arch.json` around lines 22661 - 22745, The count panel’s Y-axis formatting is inconsistent with the similar counter panel; in the Grafana panel definition for CDC Scan Scheduler Queue Length (and the matching panel referenced by the review), update the first yaxes entry to use the same count format as the “Unresolved Region Request Count” panel. Keep the change limited to the panel JSON around the graph configuration so the axis formatting is consistent across these related panels.
🤖 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 `@metrics/grafana/ticdc_new_arch.json`:
- Around line 22661-22745: The count panel’s Y-axis formatting is inconsistent
with the similar counter panel; in the Grafana panel definition for CDC Scan
Scheduler Queue Length (and the matching panel referenced by the review), update
the first yaxes entry to use the same count format as the “Unresolved Region
Request Count” panel. Keep the change limited to the panel JSON around the graph
configuration so the axis formatting is consistent across these related panels.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 74ff9c3c-9edc-4e41-9170-adba50fb17c8
📒 Files selected for processing (4)
logservice/logpuller/region_request_worker.gologservice/logpuller/region_request_worker_test.gometrics/grafana/ticdc_new_arch.jsonmetrics/nextgengrafana/ticdc_new_arch_next_gen.json
💤 Files with no reviewable changes (2)
- logservice/logpuller/region_request_worker_test.go
- logservice/logpuller/region_request_worker.go
Signed-off-by: hongyunyan <649330952@qq.com>
Signed-off-by: hongyunyan <649330952@qq.com>
Background
TiCDC creates different kinds of log puller region tasks. Bootstrap scans for newly created changefeeds should not have the same downstream scan priority as repair or retry scans that affect existing changefeed lag.
Motivation
Propagating scan priority through
ChangeDataRequestlets CSE protect high-priority CDC scans while scheduling new changefeed bootstrap scans as low priority.Summary
cdcpb.ScanPriority.ChangeDataRequest.ScanPrioritywhen building CDC requests.github.com/pingcap/kvprototo the protocol branch pseudo-version.Dependencies
Validation
go mod tidymake fmtmake cdcNEXT_GEN=1 make cdcgo test ./logservice/eventstore ./logservice/logpullertools/bin/golangci-lint run --timeout 10m0s --new-from-rev=2258270f041a2267ede73126a033f889f4d51632Summary by CodeRabbit
old-start-ts-scan-low-priority-threshold(default: 30m) to influence initial scan priority.