Skip to content

worker(dm): isolate source errors in query status snapshots - #12883

Merged
ti-chi-bot[bot] merged 2 commits into
pingcap:masterfrom
GMHDBJD:fix/dm-query-status-source-errors
Oct 13, 2026
Merged

ti-chi-bot[bot] merged 2 commits into
pingcap:masterfrom
GMHDBJD:fix/dm-query-status-source-errors

Conversation

@GMHDBJD

@GMHDBJD GMHDBJD commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #12882

When a worker already has a saved source error and the upstream connection remains
unavailable, each QueryStatus call appends another error to the saved result.
Repeated polling can grow the response beyond the gRPC receive limit, making even
queries for a nonexistent task fail.

What is changed and how it works?

  • Keep getSourceStatus unchanged. In QueryStatus, clone an existing
    ProcessResult only when appending the current upstream error. This follows
    the result-copying pattern already used by getAllSubTaskStatus and avoids
    changing the saved result or an earlier response.
  • Add a regression test for both nil and existing saved results. It exercises
    repeated and concurrent queries, checks stable response content/size, and
    verifies that the saved status and earlier response remain unchanged.
  • Keep the wire format, existing error reporting, and gRPC receive limit
    unchanged. This PR fixes the source-error accumulation; it does not change the
    OpenAPI handling of unrelated worker RPC failures.

Check List

Tests

  • Unit test
    • make dm_unit_test_pkg PKG=github.com/pingcap/tiflow/dm/worker (full package, race detector and failpoints enabled)
    • go test -race ./dm/worker -run '^TestQueryStatusDoesNotAccumulateSourceErrors$' -count=10
    • The regression test fails on the original implementation: the second query
      contains three errors instead of the expected two.
  • Manual test
    • go vet ./dm/worker
    • make fmt
    • git diff --check

Questions

Will it cause performance regression or break compatibility?

No wire-format or configuration compatibility change. Only queries that append
an upstream error to an existing result copy that small result. The normal path
and the nil-result path remain unchanged, while error-list growth and shared
mutation are avoided.

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

No.

Release note

Fix an issue where repeated DM status queries could accumulate source errors and exceed the gRPC message size limit when the upstream connection was unavailable.

Summary by CodeRabbit

  • Bug Fixes
    • Status queries now return consistent results across repeated and concurrent requests without accumulating duplicate source errors.
    • Previously returned status results remain unchanged when later queries are made.

Deep-copy the saved source status while holding the server lock so repeated and concurrent queries cannot append errors to the shared result. Cover nil and existing saved errors, stable response size, and unchanged earlier snapshots.
@GMHDBJD GMHDBJD added the area/dm Issues or PRs related to DM. label Oct 12, 2026
@ti-chi-bot ti-chi-bot Bot added do-not-merge/needs-triage-completed 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. labels Oct 12, 2026
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5d48bb1f-07fc-4bc1-89cc-39d27433dfc6

📥 Commits

Reviewing files that changed from the base of the PR and between f2c8a6f and 1073468.


📒 Files selected for processing (1)
  • dm/worker/server.go

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.



📝 Walkthrough
📝 Walkthrough

Walkthrough

QueryStatus now clones a saved source result before appending the current source error. Tests check that repeated and concurrent queries do not accumulate errors or change the saved status and earlier responses.

Changes

Status snapshot isolation

Layer / File(s) Summary
Clone source result and verify query stability
dm/worker/server.go, dm/worker/server_test.go
QueryStatus clones the saved source result before appending the current source error. Tests cover repeated and concurrent queries with and without a pre-existing source error, and verify that saved status and earlier responses remain unchanged.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium


Merge Risk: ⚪ Minimal · up to 10734

Repeated status queries now avoid accumulating source errors while preserving saved status; no actionable merge risk remains.

Security Architecture Review

Security architecture risk: ⚪ Minimal · up to 10734

The change prevents status polling from growing saved error responses. It does not expand caller authority, downstream access, or the RPC contract. No material security risk was found introduced or worsened by this change.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed mutation is limited to error-result assembly for the worker's existing source-status response. The comparison shows no new asset selector, service access, privilege, or cross-worker reachability.

Trust Boundaries and Controls

  • observed — Caller-controlled task names continue through the existing worker QueryStatus call. Cloning changes response ownership, not request authorization or transport controls; existing authentication policy is not established by this method.

Resilience and Maintainability Implications

  • inferred — Copying the saved result before augmentation removes the polling-driven accumulation mechanism during repeated upstream failures. This improves containment of status-response growth without claiming a general response-size bound or an atomic snapshot across failure and recovery.

Pre-merge checks | Passed 4 | Failed 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Issue #12882 requires repeated and concurrent QueryStatus responses to include the saved and current source errors without mutating saved status, earlier responses, or response size. `dm/worker/serv…
Out of Scope Changes check Passed The changes are limited to the issue-specific clone in dm/worker/server.go and its regression test in dm/worker/server_test.go. The changes do not alter the wire format, gRPC receive limit, or unr…
Title check Passed The title clearly and concisely describes the main change: isolating source errors in DM worker query status snapshots.
Description check Passed The description includes the issue number, problem statement, implementation details, regression tests, compatibility assessment, documentation assessment, and release note.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🧪 Generate unit tests (beta)
  • Create a new PR

🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

A rabbit checks each status call,
No saved error grows at all.
Cloned results keep their place,
Old replies retain their face.
Eight quick queries pass in view,
The saved source stays true.

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

@ti-chi-bot ti-chi-bot Bot added needs-cherry-pick-release-nextgen-202603 Should cherry pick this PR to release-nextgen-202603 branch. needs-cherry-pick-release-nextgen-202609 Should cherry pick this PR to release-nextgen-202609 branch. and removed do-not-merge/needs-triage-completed labels Oct 12, 2026
Keep the source status getter unchanged. Clone the saved ProcessResult
only when QueryStatus is about to append the current upstream error,
following the existing result-copying pattern in getAllSubTaskStatus.
@GMHDBJD

GMHDBJD commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@ti-chi-bot ti-chi-bot Bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Oct 13, 2026
@wuhuizuo

Copy link
Copy Markdown
Contributor

/retest

@ti-chi-bot

ti-chi-bot Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, joechenrh

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

@ti-chi-bot ti-chi-bot Bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Oct 13, 2026
@ti-chi-bot

ti-chi-bot Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

[LGTM Timeline notifier]

Timeline:

  • 2026-10-13 02:16:56.732463347 +0000 UTC m=+697426.479694196: ☑️ agreed by joechenrh.
  • 2026-10-13 02:59:16.249050515 +0000 UTC m=+699965.996281354: ☑️ agreed by D3Hunter.

ti-chi-bot Bot pushed a commit to PingCAP-QE/ci that referenced this pull request Oct 13, 2026
…5361)

### What is changed

Revert #4909: remove the `GOPROXY=direct` prefix from the
`error-log-review` presubmit jobs, so the go command resolves the tool
and its dependencies through the default Go module proxy again.

Files (5):
- `prow-jobs/pingcap/ticdc/latest-presubmits.yaml`
- `prow-jobs/pingcap/tiflash/latest-presubmits.yaml`
- `prow-jobs/pingcap/tiflow/latest-presubmits.yaml`
- `prow-jobs/tikv/pd/latest-presubmits.yaml`
- `prow-jobs/tikv/tikv/latest-presubmits.yaml`

### Why

`GOPROXY=direct` makes the go command resolve every dependency from its
origin host instead of a module proxy. On 2026-10-13 (~02:00–02:35 UTC)
`gopkg.in` returned a transient `502 Proxy Error`, which broke all of
these presubmits with:

```
config.go:9:2: unrecognized import path "gopkg.in/yaml.v3":
reading https://gopkg.in/yaml.v3?go-get=1: 502 Proxy Error
```

Example failed run:
https://prow.tidb.net/view/gs/prow-tidb-logs/pr-logs/pull/pingcap_tiflow/12883/pull-error-log-review/2109830078522200064

Failing runs in that window: pingcap/tiflow#12883, pingcap/ticdc#6466,
tikv/pd#11337, tikv/pd#11338, tikv/pd#11349; a later run at 02:36 UTC
passed. The error-log-review presubmits are non-optional, so this
blocked Tide merge.

#4909 added `GOPROXY=direct` so that `go run ...@main` always resolves
the latest commit immediately, bypassing module-proxy branch-query
caching. Reverting trades that freshness for reliability: right after a
push to main, `@main` may briefly resolve to a stale pseudo-version,
which is acceptable for this presubmit.

### Validation

- `git revert 99b33ce` applies cleanly
(auto-merge, no conflicts).
- `prow-jobs/kustomization.yaml` uses `disableNameSuffixHash: true`, so
no hash regeneration is needed.
@wuhuizuo

Copy link
Copy Markdown
Contributor

/retest

@ti-chi-bot
ti-chi-bot Bot merged commit 1c2d873 into pingcap:master Oct 13, 2026
32 checks passed
@ti-chi-bot

Copy link
Copy Markdown
Member

In response to a cherrypick label: new pull request created to branch release-nextgen-202603: #12889.

@ti-chi-bot

Copy link
Copy Markdown
Member

In response to a cherrypick label: new pull request created to branch release-nextgen-202609: #12890.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved area/dm Issues or PRs related to DM. lgtm needs-cherry-pick-release-nextgen-202603 Should cherry pick this PR to release-nextgen-202603 branch. needs-cherry-pick-release-nextgen-202609 Should cherry pick this PR to release-nextgen-202609 branch. 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.

dm: QueryStatus accumulates saved source errors and exceeds gRPC limit

5 participants