Skip to content

eventservice: keep transaction cursor inside scan window - #6040

Open
asddongmen wants to merge 1 commit into
pingcap:masterfrom
asddongmen:fix-transaction-cursor-scan-window
Open

eventservice: keep transaction cursor inside scan window#6040
asddongmen wants to merge 1 commit into
pingcap:masterfrom
asddongmen:fix-transaction-cursor-scan-window

Conversation

@asddongmen

@asddongmen asddongmen commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

What problem does this PR solve?

Issue Number: ref #6022

An interrupted EventService scan can publish a transaction cursor (commitTs=C, startTs=S). If the adaptive scan window later shrinks below C, the existing code skips the now-empty range even though a nonzero TxnStartTs also prevents signal resolved-ts, so the dispatcher must wait for the window to reach C again.

This is a narrow liveness corner case. It is not intended to attribute the previously observed low-CPU periodic throughput issue to this path.

What is changed and how it works?

Treat either a row position or transaction start-ts as a resume cursor. When scan-window capping moves the end below the cursor commit-ts, normalize the effective range to [C,C].

For TxnStartTs=S, EventStore scans from (C,S+1) to the end of commit-ts C, so only later transactions sharing C are resumed. Ordinary empty ranges without a cursor, DDL/syncpoint handling, and large-transaction behavior are unchanged.

A focused unit test covers the transaction-cursor case after the scan window shrinks behind C.

Check List

Tests

  • Unit test

Questions

Will it cause performance regression or break compatibility?

No compatibility change. An extra scan is possible only for a valid resume cursor that the old path skipped; the scan is required to make progress.

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

No.

Release note

Fix a corner case where a shrinking scan window can stall a dispatcher with a transaction resume cursor.

Summary by CodeRabbit

  • Bug Fixes
    • Improved scan-range resume handling for transaction-start and row-position cursors.
    • Preserved valid scan requests when adaptive window limits shrink the range.
    • Ensured collapsed ranges retain matching start and end positions instead of being discarded.

@ti-chi-bot ti-chi-bot Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/needs-triage-completed labels Aug 19, 2026
@ti-chi-bot

ti-chi-bot Bot commented Aug 19, 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 lidezhu 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 the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 19, 2026
@asddongmen

Copy link
Copy Markdown
Collaborator Author

/run-check-issue-triage-complete

@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 107eee2a-da15-4a85-a4cc-7d56e7a5e82b

📥 Commits

Reviewing files that changed from the base of the PR and between b813e76 and f06b1e9.

📒 Files selected for processing (2)
  • pkg/eventservice/event_broker.go
  • pkg/eventservice/event_broker_test.go

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


📝 Walkthrough

Walkthrough

The event broker now preserves transaction-start and row-position cursors when adaptive window capping shrinks a scan range. The regression test verifies a scan request with matching commit timestamps and the original transaction cursor.

Changes

Scan-range resume handling

Layer / File(s) Summary
Resume-range correction and regression coverage
pkg/eventservice/event_broker.go, pkg/eventservice/event_broker_test.go
The broker recognizes both supported resume cursor types and restores a shrunken range to the transaction commit timestamp. The test verifies the scan request, transaction cursor, and empty row position.

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

Merge Risk: ⚪ Minimal · up to f06b1

This localized fix keeps transaction resume cursors within the scan window to prevent a narrow dispatcher stall; no actionable merge-blocking risk remains after normal checks and review.

Suggested labels: lgtm, approved

Suggested reviewers: lidezhu

Poem

A rabbit checked the scan with care,
And kept both cursors safely there.
The window shrank, the range held true,
Commit times matched as they should do.
“Hop approved!” the rabbit said.

🚥 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 The description covers the issue, implementation, tests, compatibility, documentation, and release note requirements.
Title check ✅ Passed The title clearly and concisely describes the main change to preserve a transaction cursor within the scan window.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

Command failed


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.

@asddongmen

Copy link
Copy Markdown
Collaborator Author

/test all

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/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant