Skip to content

logpuller: extract region request scheduler from subscription client#5665

Open
lidezhu wants to merge 6 commits into
ldz/refactor-puller04from
ldz/refactor-puller05
Open

logpuller: extract region request scheduler from subscription client#5665
lidezhu wants to merge 6 commits into
ldz/refactor-puller04from
ldz/refactor-puller05

Conversation

@lidezhu

@lidezhu lidezhu commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

What problem does this PR solve?

Issue Number: close #xxx

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Questions

Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?

Release note

Please refer to [Release Notes Language Style Guide](https://pingcap.github.io/tidb-dev-guide/contribute-to-tidb/release-notes-style-guide.html) to write a quality release note.

If you don't think this PR needs a release note then fill it with `None`.

@ti-chi-bot

ti-chi-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Jul 17, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign 3aceshowhand for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6c26a267-f183-48e5-9a36-4c093f8b620b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ldz/refactor-puller05

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ti-chi-bot ti-chi-bot Bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jul 17, 2026
@lidezhu
lidezhu marked this pull request as ready for review July 17, 2026 01:58

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the region request scheduling logic in the logpuller package by introducing a dedicated regionRequestScheduler and requestedStore to manage workers connected to TiKV stores, decoupling this responsibility from subscriptionClient. The review feedback suggests adding defensive nil checks for worker.admission in the submit, close, and inflightCount methods of requestedStore to prevent potential nil pointer dereferences during testing or partial initialization.

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.

Comment thread logservice/logpuller/requested_store.go Outdated
Comment on lines +57 to +63
func (s *requestedStore) submit(task *regionPriorityTask) bool {
if len(s.workers) == 0 {
return false
}
index := (s.nextWorker.Add(1) - 1) % uint64(len(s.workers))
return s.workers[index].admission.submit(task)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Add a defensive nil check for worker.admission to prevent potential nil pointer dereferences during testing or if workers are partially initialized.

func (s *requestedStore) submit(task *regionPriorityTask) bool {\n\tif len(s.workers) == 0 {\n\t\treturn false\n\t}\n\tindex := (s.nextWorker.Add(1) - 1) % uint64(len(s.workers))\n\tworker := s.workers[index]\n\tif worker.admission == nil {\n\t\treturn false\n\t}\n\treturn worker.admission.submit(task)\n}
References
  1. Enforce defensive programming by ensuring appropriate nil checks exist before object property accesses to prevent nil pointer dereferences.

Comment thread logservice/logpuller/requested_store.go Outdated
Comment on lines +71 to +75
func (s *requestedStore) close() {
for _, worker := range s.workers {
worker.admission.close()
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Add a defensive nil check for worker.admission in close() to prevent potential nil pointer dereferences during testing or if workers are partially initialized.

func (s *requestedStore) close() {\n\tfor _, worker := range s.workers {\n\t\tif worker.admission != nil {\n\t\t\tworker.admission.close()\n\t\t}\n\t}\n}
References
  1. Enforce defensive programming by ensuring appropriate nil checks exist before object property accesses to prevent nil pointer dereferences.

Comment thread logservice/logpuller/requested_store.go Outdated
Comment on lines +77 to +83
func (s *requestedStore) inflightCount() int {
count := 0
for _, worker := range s.workers {
count += worker.admission.stats().inflight
}
return count
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Add a defensive nil check for worker.admission in inflightCount() to prevent potential nil pointer dereferences during testing or if workers are partially initialized.

func (s *requestedStore) inflightCount() int {\n\tcount := 0\n\tfor _, worker := range s.workers {\n\t\tif worker.admission != nil {\n\t\t\tcount += worker.admission.stats().inflight\n\t\t}\n\t}\n\treturn count\n}
References
  1. Enforce defensive programming by ensuring appropriate nil checks exist before object property accesses to prevent nil pointer dereferences.

@ti-chi-bot ti-chi-bot Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 17, 2026
@ti-chi-bot ti-chi-bot Bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant