Skip to content

api(ticdc): return task_status for changefeeds in warning state - #12759

Open
shreyasp-db wants to merge 1 commit into
pingcap:masterfrom
shreyasp-db:fix/changefeed-query-task-status-warning
Open

api(ticdc): return task_status for changefeeds in warning state#12759
shreyasp-db wants to merge 1 commit into
pingcap:masterfrom
shreyasp-db:fix/changefeed-query-task-status-warning

Conversation

@shreyasp-db

Copy link
Copy Markdown

What problem does this PR solve?

Issue Number: none

The changefeed query/detail OpenAPI endpoints normally return task_status, e.g. (as seen via cdc cli changefeed query -c <CHANGEFEED_ID>, which is just one client of this API):

"task_status": [
  {
    "capture_id": "d4ecb27f-bb40-4655-bf72-192852e4ef80",
    "table_ids": [3508, 3520, 3523, 3529, 3531]
  }
]

However, when a changefeed is in the warning state, task_status is not returned — which is often exactly when this per-capture table assignment is most needed for debugging. This affects every caller of the query API (the GET /api/v1/changefeeds/{id}, GET /api/v2/changefeeds/{id}, and meta-info endpoints), not just the cdc cli.

The changefeed detail handlers gate the task_status population on an exact info.State == model.StateNormal check, so GetAllTaskStatuses is skipped for any other state, including warning.

What is changed and how it works?

A changefeed in the warning state is still running (its processors are active), so its task statuses remain meaningful. FeedState.IsRunning() already encodes this exact semantic (StateNormal || StateWarning).

This PR replaces the exact StateNormal check with
FeedState.IsRunning() in the three changefeed-detail handlers:

  • cdc/api/v1/api.gogetChangefeed
  • cdc/api/v2/changefeed.gogetChangeFeed
  • cdc/api/v2/changefeed.gogetChangeFeedMetaInfo

Check List

Tests

  • Unit test

Extended TestGetChangeFeed (cdc/api/v2) with a table-driven check asserting task_status is returned for normal and warning states and omitted for stopped.

Questions

Will it cause performance regression or break compatibility?

No. It adds one GetAllTaskStatuses call for changefeeds in the warning state (the same call already made for normal), and only widens the set of states for which task_status is populated — no field or format changes.

Do you need to update user documentation, design documentation or monitoring documentation?

No.

Release note

Fix the changefeed query API not returning `task_status` for changefeeds in the warning state.

The changefeed detail handlers populate task_status only when the
changefeed is in the normal state, so `cdc cli changefeed query` omits
the per-capture table assignment for changefeeds in the warning state --
which is often exactly when this information is most needed for
debugging.

A changefeed in the warning state is still running (its processors are
active), so its task statuses remain meaningful. Gate the task_status
population on FeedState.IsRunning() (normal OR warning) instead of an
exact StateNormal check.
@ti-chi-bot

ti-chi-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

[FORMAT CHECKER NOTIFICATION]

Notice: To remove the do-not-merge/needs-linked-issue label, please provide the linked issue number on one line in the PR body, for example: Issue Number: close #123 or Issue Number: ref #456.

📖 For more info, you can check the "Contribute Code" section in the development guide.

@ti-chi-bot ti-chi-bot Bot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jul 16, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

[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 niubell, yudongusa 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

@ti-chi-bot ti-chi-bot Bot added contribution This PR is from a community contributor. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. labels Jul 16, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Welcome @shreyasp-db!

It looks like this is your first PR to pingcap/tiflow 🎉.

I'm the bot to help you request reviewers, add labels and more, See available commands.

We want to make sure your contribution gets all the attention it needs!



Thank you, and welcome to pingcap/tiflow. 😃

@ti-chi-bot

ti-chi-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Hi @shreyasp-db. Thanks for your PR.

I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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 the needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. label Jul 16, 2026
@pingcap-cla-assistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@ti-chi-bot ti-chi-bot Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 16, 2026
@gemini-code-assist

Copy link
Copy Markdown

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@dveeden

dveeden commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

/ok-to-test

@ti-chi-bot ti-chi-bot Bot added ok-to-test Indicates a PR is ready to be tested. and removed needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution This PR is from a community contributor. do-not-merge/needs-linked-issue first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. ok-to-test Indicates a PR is ready to be tested. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants