Skip to content

dispatcher: avoid blocking resend workers on a full status buffer (#6743) - #6787

Merged
ti-chi-bot[bot] merged 3 commits into
pingcap:release-nextgen-202609from
ti-chi-bot:cherry-pick-6743-to-release-nextgen-202609
Nov 23, 2026
Merged

ti-chi-bot[bot] merged 3 commits into
pingcap:release-nextgen-202609from
ti-chi-bot:cherry-pick-6743-to-release-nextgen-202609

Conversation

@ti-chi-bot

@ti-chi-bot ti-chi-bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

This is an automated cherry-pick of #6743

What problem does this PR solve?

Issue Number: close #6719

A DB DDL barrier can ignore a moving dispatcher's WAITING report while it is still scheduling. Current master asks that dispatcher to retry, but a retry can block a shared thread-pool worker indefinitely when the block-status buffer is full. Cancellation cannot interrupt that blocked send, so other dispatchers' retries can be starved. This fixes the reproducible retry-path failure mode; the exact retry failure in the reported production incident remains unproven.

What is changed and how it works?

  • Make periodic and fast block-status retries use a nonblocking offer. When the buffer is full, one lazy sender per buffer waits to place the retry into the original queue. Each resend task keeps at most one pending retry; cancellation removes it. An already pending WAITING status remains deduplicated.
  • Keep the initial status offer and queue ordering unchanged.
  • Add tests for full-buffer WAITING/NONE retries, competing producers, cancellation, sender shutdown, ignored-status fast retry, one-worker availability, and DB DDL barrier progress after a moving dispatcher's WAITING report is ignored.

Check List

Tests

  • Unit test: targeted retry tests passed ten runs with -race; targeted maintainer tests passed. dispatcher and dispatchermanager package tests passed with two existing partial-flush tests skipped. TestRedoBatchDMLEventsPartialFlush times out at the same assertion on unmodified PR base.

Questions

Will it cause performance regression or break compatibility?

No wire-protocol or compatibility change. Initial status delivery is unchanged. A full buffer starts one lazy sender goroutine per buffer and keeps at most one pending entry per active resend task.

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

No. This is an internal retry-path fix.

Release note

Prevent changefeed from stuck when there is a database level DDL.

Summary by CodeRabbit

  • Bug Fixes
    • Improved delivery of status updates when dispatch queues are full, preserving retry order and allowing pending retries to progress as capacity becomes available.
    • Canceled retries are now removed from the pending queue, and pending work is stopped cleanly when the buffer closes.
    • Improved recovery of waiting status updates when dispatcher activity changes.

Use one cancelable retry sender per block status buffer so a retry waits for admission without occupying a shared resend worker. Keep one pending entry per status and send it through the original ordered queue.

Cover competing producers, duplicate WAITING reports, cancellation, shutdown, and ignored-status fast retry.
@ti-chi-bot ti-chi-bot added lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. type/cherry-pick-for-release-nextgen-202609 labels Nov 3, 2026
@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Block status retries that encounter a full buffer can wait for capacity instead of blocking a resend task. The change adds retry cancellation and buffer shutdown handling, with tests for retry delivery and a DB barrier scenario involving a dispatcher move.

Changes: Retry Delivery

Layer / File(s) Summary
Buffer retry queue
downstreamadapter/dispatcher/block_status_buffer.go
BlockStatusBuffer stores retries in FIFO order when its bounded queue cannot accept them. A sender waits for capacity. The buffer deduplicates pending waiting statuses and supports retry cancellation and closure.
Resend task and buffer wiring
downstreamadapter/dispatcher/helper.go, downstreamadapter/dispatcher/basic_dispatcher_info.go
BasicDispatcher delegates retry offers and cancellation to the shared buffer. ResendTask uses the retry offer, returns the next scheduled time when an offer is rejected, and runs cancellation cleanup once. SharedInfo.Close closes the buffer.
Retry and barrier regression tests
downstreamadapter/dispatcher/block_status_buffer_test.go, maintainer/barrier_test.go
Tests cover retry ordering, producer progress, cancellation, closure, and resend worker availability. The barrier test covers a DB-scoped WAITING status that is ignored before a dispatcher move completes and handled again afterward.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant ResendTask
  participant BasicDispatcher
  participant BlockStatusBuffer
  ResendTask->>BasicDispatcher: Offer retry status
  BasicDispatcher->>BlockStatusBuffer: Queue retry or retain it
  BlockStatusBuffer-->>ResendTask: Return whether retry was accepted
  ResendTask->>BasicDispatcher: Cancel retry status
  BasicDispatcher->>BlockStatusBuffer: Remove pending retry
Loading

Possibly related PRs

  • pingcap/ticdc#6743: This is the original change that PR #6787 cherry-picks, including the retry sender and cancellation behavior.
  • pingcap/ticdc#6786: This is a release-8.5 cherry-pick of the same retry-path change.

Suggested reviewers: hongyunyan, 3aceshowhand

Merge Risk: Minimal · up to 594ab

Block-status retries on a full buffer no longer occupy shared resend workers. They wait through a per-buffer sender that preserves queue ordering, deduplicates WAITING reports, and stops on cancel or close. No concrete defect was found, so merge risk is low after normal CI.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: resend workers no longer block on a full block-status buffer. It also names the affected component (dispatcher). The title includes the PR number (#6743), which is acc…
Description check Passed The description follows the repository template. It includes the problem statement, the issue link line (close #6719), a change summary, test results, answers to the performance and compatibility ques…
Linked Issues check Passed The only linked issue, #6719, is closed. It supplies historical context only, so no active directly linked targets remain. Its acceptance criteria are not PR requirements. No linked-issue coding requi…
Out of Scope Changes check Passed The PR states its own objective: keep periodic and fast block-status retries off shared resend workers when the status buffer is full. The changed files all serve that objective. downstreamadapter/dis…
Full details: Title check

Explanation

The title names the main change: resend workers no longer block on a full block-status buffer. It also names the affected component (dispatcher). The title includes the PR number (#6743), which is acceptable but adds noise. The title matches the changeset, which adds a nonblocking offer and a deferred sender for retries.

Full details: Description check

Explanation

The description follows the repository template. It includes the problem statement, the issue link line (close #6719), a change summary, test results, answers to the performance and compatibility questions, the documentation question, and a release note. It also notes that the production incident link is unproven, which is an accurate caveat. The description is a cherry-pick note and says the release note is user-facing. The Check List has the Unit test item checked with results. The description does not list the Integration test or Manual test items, which the template treats as optional alternatives. The template's 'Issue Number' line is present. The description is mostly complete.

Full details: Linked Issues check

Explanation

The only linked issue, #6719, is closed. It supplies historical context only, so no active directly linked targets remain. Its acceptance criteria are not PR requirements. No linked-issue coding requirements apply, so this check passes. The PR description states that the retry-path failure is reproducible but not proven to be the production failure. This assessment does not treat the fix as proof of resolving the incident.

Full details: Out of Scope Changes check

Explanation

The PR states its own objective: keep periodic and fast block-status retries off shared resend workers when the status buffer is full. The changed files all serve that objective. downstreamadapter/dispatcher/block_status_buffer.go adds a retry queue, one lazy sender per buffer, deduplication, cancellation, and shutdown. downstreamadapter/dispatcher/helper.go routes retries through offerRetryBlockStatus with a cancellation channel. downstreamadapter/dispatcher/basic_dispatcher_info.go adds enqueue and cancel methods and closes the buffer in SharedInfo.Close. The block_status_buffer_test.go additions cover this behavior. maintainer/barrier_test.go adds a DB barrier regression test for a WAITING report that is ignored after a dispatcher move. This test supports the PR's described progress behavior. No changed file was found to be unrelated to the block-status retry path. This assessment used the PR summary and raw change summary, not a full diff read. The per-hunk content was not inspected, so the verdict depends on the summary's accuracy.

Finishing Touches

Generate unit tests (beta)

  • 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 queued a status neat,
While buffer space was scarce,
It waited for the queue to clear,
Then sent the retry there.
If canceled, it left the line,
And hopped away on time.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2e3bd4a0-eb62-4cbf-a7b9-53328db78597
Commits

Reviewing files that changed from the base of the PR and between 9574c1f and 594abb5.

Files selected for processing: 5

  • downstreamadapter/dispatcher/basic_dispatcher_info.go
  • downstreamadapter/dispatcher/block_status_buffer.go
  • downstreamadapter/dispatcher/block_status_buffer_test.go
  • downstreamadapter/dispatcher/helper.go
  • maintainer/barrier_test.go

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

@ti-chi-bot ti-chi-bot Bot added the approved label Nov 11, 2026
@asddongmen

Copy link
Copy Markdown
Collaborator

/test all

@asddongmen

Copy link
Copy Markdown
Collaborator

/test pull-cdc-mysql-integration-heavy-next-gen

@asddongmen

Copy link
Copy Markdown
Collaborator

/test pull-cdc-kafka-integration-heavy-next-gen

@ti-chi-bot ti-chi-bot Bot added cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels Nov 16, 2026
@ti-chi-bot

ti-chi-bot Bot commented Nov 16, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: asddongmen, lidezhu

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 merged commit 10dfd9f into pingcap:release-nextgen-202609 Nov 23, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved cherry-pick-approved Cherry pick PR approved by release team. lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. type/cherry-pick-for-release-nextgen-202609

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants