Skip to content

eventservice: advance scan window for pending syncpoints#5547

Open
asddongmen wants to merge 2 commits into
pingcap:masterfrom
asddongmen:codex/issue-5546-eventservice-syncpoint-scan-window
Open

eventservice: advance scan window for pending syncpoints#5547
asddongmen wants to merge 2 commits into
pingcap:masterfrom
asddongmen:codex/issue-5546-eventservice-syncpoint-scan-window

Conversation

@asddongmen

@asddongmen asddongmen commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

What problem does this PR solve?

Issue Number: close #5546

This PR splits the eventBroker runtime fix from #5542.

When the event service scan window is pinned by another lagging dispatcher, a dispatcher with a pending syncpoint barrier can get an empty scan range and fail to advance far enough to emit the syncpoint. The existing local scan-window advance path handled pending DDL barriers only.

What is changed and how it works?

  • Detect pending syncpoint events before the uncapped scan end ts.
  • Reuse the local scan-window advance path when either a DDL or syncpoint barrier is pending.
  • Ensure the local range crosses nextSyncPointTs when the syncpoint would otherwise remain outside the bounded step.
  • Add focused unit coverage for the pending syncpoint case.

Source PR: #5542

Check List

Tests

  • Unit test

Commands run:

  • git diff --check
  • PATH=/usr/local/go/bin:$PATH GOTOOLCHAIN=auto go test ./pkg/eventservice -run TestGetScanTaskDataRangeEmptyAfterCappingWithPendingSyncPointCrossesSyncPoint -count=1
  • PATH=/usr/local/go/bin:$PATH GOTOOLCHAIN=auto make unit_test_pkg PKG=./pkg/eventservice/...

Questions

Will it cause performance regression or break compatibility?

No. The change only expands an existing local scan-window advance path to cover pending syncpoint barriers, matching the DDL barrier behavior.

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

No.

Release note

None

Summary by CodeRabbit

  • Bug Fixes
    • Improved scan-range handling so pending barrier events are respected when advancing work windows.
    • Prevented scan advancement from skipping over sync-point barriers, helping preserve correct event ordering.
    • Updated logging to reflect pending barrier events more accurately.
  • Tests
    • Added coverage for scan-range behavior when a pending sync-point crosses the current scan window.

@ti-chi-bot ti-chi-bot Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 30, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot Bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/needs-triage-completed labels Jun 30, 2026
@coderabbitai

coderabbitai Bot commented Jun 30, 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

Run ID: e23bbef0-9812-4c13-89b6-48895285475e

📥 Commits

Reviewing files that changed from the base of the PR and between d220ee9 and db2ad80.

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

📝 Walkthrough

Walkthrough

Modifies getScanTaskDataRange in the event broker to detect pending sync-point barrier events alongside pending DDL events, and to locally advance the scan window—capping it just past the next sync-point timestamp when needed. Adds a unit test validating this capping behavior.

Changes

Sync point scan window fix

Layer / File(s) Summary
Detect and handle pending sync-point in scan window advance
pkg/eventservice/event_broker.go
Reads dispatcher's next sync-point timestamp, computes pending sync-point flag within current scan window, combines with pending DDL to trigger local advance of CommitTsEnd, caps advance just past nextSyncPointTs, and updates logging to report both pending DDL and sync-point state.
Test coverage for sync-point crossing
pkg/eventservice/event_broker_test.go
Adds a test enabling sync points that asserts getScanTaskDataRange returns needScan=true with CommitTsEnd equal to nextSyncPointTs + 1.

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

Suggested labels: lgtm, approved

Suggested reviewers: lidezhu, hongyunyan

Poem

A rabbit watched the scan window creep,
stuck while sync points lay asleep 💤
Now barriers nudge the range ahead,
past the sync point, forward instead.
Hop, hop, progress — no more stall,
tests confirm it, one and all! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: advancing the eventservice scan window for pending syncpoints.
Description check ✅ Passed The description includes the issue number, change summary, tests, questions, and release note as required by the template.
Linked Issues check ✅ Passed The changes match #5546 by detecting pending syncpoints, advancing the scan range locally, crossing nextSyncPointTs, and adding unit coverage.
Out of Scope Changes check ✅ Passed The PR stays within scope, touching only the eventBroker scan-window logic and a focused unit test for the syncpoint case.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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.

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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for advancing the scan window when there are pending sync point events, ensuring dispatchers can make forward progress and cross sync points even when the global scan window is pinned. A unit test has been added to verify this behavior. Feedback is provided regarding a potential race condition or inconsistency caused by loading task.nextSyncPoint twice, with a suggestion to reuse the already loaded value.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread pkg/eventservice/event_broker.go Outdated
@asddongmen asddongmen force-pushed the codex/issue-5546-eventservice-syncpoint-scan-window branch from 8545cb5 to c5f3139 Compare June 30, 2026 03:31
@asddongmen

Copy link
Copy Markdown
Collaborator Author

/test all

@asddongmen

Copy link
Copy Markdown
Collaborator Author

/test all

@asddongmen asddongmen self-assigned this Jul 1, 2026
@asddongmen asddongmen marked this pull request as ready for review July 1, 2026 06:28
@ti-chi-bot ti-chi-bot Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 1, 2026
localScanMaxTs := oracle.GoTimeToTS(oracle.GetTimeFromTS(dataRange.CommitTsStart).Add(interval))
if hasPendingSyncPointEventInCurrentRange && nextSyncPointTs >= dataRange.CommitTsStart &&
localScanMaxTs <= nextSyncPointTs {
localScanMaxTs = nextSyncPointTs + 1

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What will happen if localScanMaxTs Ts is less than nextSyncPointTs?

@ti-chi-bot ti-chi-bot Bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jul 1, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 1, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 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 commented Jul 1, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-07-01 18:14:52.466787652 +0000 UTC m=+236034.167167065: ☑️ agreed by lidezhu.

@ti-chi-bot ti-chi-bot Bot added the approved label Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. release-note-none Denotes a PR that doesn't merit a release note. 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.

eventservice: scan window may stuck wheren there are pending syncpoints

3 participants