Skip to content

add request head to getGCState#234

Merged
ti-chi-bot[bot] merged 2 commits intotikv:masterfrom
CalvinNeo:add-header
Apr 22, 2026
Merged

add request head to getGCState#234
ti-chi-bot[bot] merged 2 commits intotikv:masterfrom
CalvinNeo:add-header

Conversation

@CalvinNeo
Copy link
Copy Markdown
Member

@CalvinNeo CalvinNeo commented Apr 21, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced request header initialization to ensure proper identification of request sources and cluster context.

a
Signed-off-by: Calvin Neo <calvinneo1995@gmail.com>
@ti-chi-bot ti-chi-bot Bot added dco-signoff: yes Indicates the PR's author has signed the dco. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 21, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

📝 Walkthrough

Walkthrough

The Client::getGCState(KeyspaceID) method was refactored to construct the request header via a local pointer, enabling explicit assignment of cluster_id and caller_id fields to "tiflash" before attaching it to the request, rather than directly using the unmodified requestHeader() result.

Changes

Cohort / File(s) Summary
Request Header Initialization
src/pd/Client.cc
Modified Client::getGCState(KeyspaceID) to use a local header pointer for explicit configuration of cluster_id and caller_id fields prior to request attachment.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A header now takes shape with care,
With cluster_id and caller declared fair,
In TiFlash's name, the request takes flight,
One tiny method, perfected right! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'add request head to getGCState' accurately describes the main change: adding a request header to the getGCState method with explicit cluster_id and caller_id fields.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/pd/Client.cc (1)

371-374: Attach the allocated header before mutating request-specific fields.

Line 371 holds an owning raw pointer until Line 374. Attach it immediately, then mutate the request-owned header; this also removes the redundant cluster_id assignment because requestHeader() already sets it.

♻️ Proposed refactor
-    auto * header = requestHeader();
-    header->set_cluster_id(cluster_id);
-    header->set_caller_id("tiflash");
-    request.set_allocated_header(header);
+    request.set_allocated_header(requestHeader());
+    request.mutable_header()->set_caller_id("tiflash");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pd/Client.cc` around lines 371 - 374, Obtain the header via
requestHeader(), immediately call request.set_allocated_header(header) to
transfer ownership, then mutate request-owned fields (e.g., call
header->set_caller_id("tiflash")); remove the redundant
header->set_cluster_id(cluster_id) because requestHeader() already initializes
cluster_id. This ensures no lingering owning raw pointer and that mutations
happen on the request-owned header.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/pd/Client.cc`:
- Around line 371-374: Obtain the header via requestHeader(), immediately call
request.set_allocated_header(header) to transfer ownership, then mutate
request-owned fields (e.g., call header->set_caller_id("tiflash")); remove the
redundant header->set_cluster_id(cluster_id) because requestHeader() already
initializes cluster_id. This ensures no lingering owning raw pointer and that
mutations happen on the request-owned header.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7f6a6114-803a-43c8-9014-715142d3f993

📥 Commits

Reviewing files that changed from the base of the PR and between 88ca06e and 8291521.

📒 Files selected for processing (1)
  • src/pd/Client.cc

@ti-chi-bot ti-chi-bot Bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Apr 21, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 21, 2026

@JaySon-Huang: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot Bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Apr 21, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 21, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-04-21 13:54:41.192069697 +0000 UTC m=+2087686.397429754: ☑️ agreed by gengliqi.
  • 2026-04-21 15:07:37.03305849 +0000 UTC m=+2092062.238418557: ☑️ agreed by 3pointer.

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 22, 2026

@wfxr: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 22, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 3pointer, cfzjywxk, gengliqi, JaySon-Huang, wfxr

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

The pull request process is described 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

@CalvinNeo
Copy link
Copy Markdown
Member Author

/merge

@CalvinNeo
Copy link
Copy Markdown
Member Author

/retest

@gengliqi
Copy link
Copy Markdown
Member

/merge

@ti-chi-bot ti-chi-bot Bot merged commit eaa9f5d into tikv:master Apr 22, 2026
6 of 7 checks passed
CalvinNeo added a commit to CalvinNeo/client-c that referenced this pull request Apr 22, 2026
Signed-off-by: Calvin Neo <calvinneo1995@gmail.com>
ti-chi-bot Bot pushed a commit that referenced this pull request Apr 22, 2026
 

Signed-off-by: Calvin Neo <calvinneo1995@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved dco-signoff: yes Indicates the PR's author has signed the dco. lgtm size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants