Skip to content

maintainer: return zero for equal event keys#5650

Open
ekexium wants to merge 1 commit into
pingcap:masterfrom
ekexium:avery/fix-ticdc-5187
Open

maintainer: return zero for equal event keys#5650
ekexium wants to merge 1 commit into
pingcap:masterfrom
ekexium:avery/fix-ticdc-5187

Conversation

@ekexium

@ekexium ekexium commented Jul 14, 2026

Copy link
Copy Markdown
Member

What problem does this PR solve?

Issue Number: close #5187

compareEventKey returned 1 when both event keys were equal, violating the comparator contract expected by callers such as slices.SortFunc.

What is changed and how it works?

Return 0 when both blockTs and isSyncPoint are equal. Add table-driven unit coverage for timestamp ordering, sync-point ordering, and both equality cases.

Check List

Tests

  • Unit test

Command: make unit_test_pkg PKG=./maintainer/...

Questions

Will it cause performance regression or break compatibility?

No.

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

No.

Release note

None

Summary by CodeRabbit

  • Bug Fixes
    • Fixed tie-breaking logic when comparing two event keys with matching sync-point status, ensuring consistent ordering.
    • Kept behavior that equivalent event keys are treated as equal.
  • Tests
    • Added table-driven unit tests covering timestamp ordering, DDL vs sync-point precedence (including reverse order), and sync-point equality cases.

Copilot AI review requested due to automatic review settings July 14, 2026 02:34
@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 Jul 14, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 14, 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 hicqu 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

@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/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 14, 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 updates the compareEventKey function in maintainer/barrier_helper.go to correctly handle cases where both keys are sync points or neither is, returning 0 when they are equal instead of defaulting to 1. Additionally, a comprehensive unit test suite TestCompareEventKey has been added in maintainer/barrier_helper_test.go to verify the comparison logic. There are no review comments, and I have no additional feedback to provide.

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.

Copilot AI 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.

Pull request overview

Fixes maintainer’s compareEventKey comparator to satisfy the expected ordering contract (notably for slices.SortFunc) by returning 0 when two eventKey values are equal.

Changes:

  • Update compareEventKey to explicitly handle both sync-point tie-break directions and return 0 on full equality.
  • Add table-driven unit tests covering timestamp ordering, sync-point ordering, and equality cases.

Validation:

  • Not run here (per PR: make unit_test_pkg PKG=./maintainer/...)

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
maintainer/barrier_helper.go Fix comparator to return 0 for equal keys and fully implement sync-point tie-break ordering.
maintainer/barrier_helper_test.go Add unit tests validating ordering and equality behavior of compareEventKey.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coderabbitai

coderabbitai Bot commented Jul 14, 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: 227ee7dd-6cdf-4d73-a136-eb059c7d8ac8

📥 Commits

Reviewing files that changed from the base of the PR and between 9c25760 and 83116be.

📒 Files selected for processing (2)
  • maintainer/barrier_helper.go
  • maintainer/barrier_helper_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • maintainer/barrier_helper.go

📝 Walkthrough

Walkthrough

compareEventKey now returns 0 when event keys share the same timestamp and sync-point status. A table-driven unit test covers timestamp ordering, DDL versus sync-point precedence, and equality cases.

Changes

Event key comparator

Layer / File(s) Summary
Comparator tie-breaking and coverage
maintainer/barrier_helper.go, maintainer/barrier_helper_test.go
compareEventKey handles both sync-point orderings and returns 0 for equal statuses; table-driven tests validate ordering and equality behavior.

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

Poem

I’m a rabbit with keys in a row,
Sorting the carrots from high to low.
Equal little keys now rest as one,
Tests hop through each case in the sun.
No more leaps when ties are spun!

🚥 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
Title check ✅ Passed The title is concise and accurately describes the main change: returning zero for equal event keys.
Description check ✅ Passed The description follows the template and includes the issue number, change summary, tests, answers, and release note.
Linked Issues check ✅ Passed The implementation matches #5187 by returning 0 for equal keys and adding tests for ordering and equality cases.
Out of Scope Changes check ✅ Passed The PR stays focused on the comparator fix and its unit tests, with no unrelated code changes.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@ekexium
ekexium force-pushed the avery/fix-ticdc-5187 branch from 43ab2f4 to 9c25760 Compare July 14, 2026 08:45
Signed-off-by: Ziqian Qin <eke@fastmail.com>
@ekexium
ekexium force-pushed the avery/fix-ticdc-5187 branch from 9c25760 to 83116be Compare July 14, 2026 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. 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.

maintainer: make compareEventKey return 0 for equal event keys

2 participants