Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix #192] fix unified sorter #194

Merged
merged 6 commits into from
Aug 4, 2022
Merged

Conversation

zeminzhou
Copy link
Contributor

Signed-off-by: zeminzhou [email protected]

What problem does this PR solve?

fix issue #192

Issue Number: close #192

Problem Description: TBD
The unified sort use heap sort which is unstable algorithm, which can swap two equial events.

What is changed and how does it work?

Add new field for RawKV to help sorter.

Code changes

  • Has exported function/method change
  • Has exported variable/fields change
  • Has interface methods change

Check List for Tests

This PR has been tested by at least one of the following methods:

  • Unit test

Signed-off-by: zeminzhou <[email protected]>
@zeminzhou zeminzhou requested review from pingyu and haojinming August 3, 2022 13:59
Signed-off-by: zeminzhou <[email protected]>
Signed-off-by: zeminzhou <[email protected]>
Copy link
Collaborator

@pingyu pingyu left a comment

Choose a reason for hiding this comment

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

Rest LGTM.

@@ -87,11 +87,13 @@ type RawKVEntry struct {
// Additional debug info
RegionID uint64 `msg:"region_id"`
KeySpanID uint64 `msg:"keyspan_id"`
// For sort
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// For sort
// For providing additional sequence number.
// To keep `RawKVEntries` from the same region in order during unstable sorting of `sorter`.
// The sequence number is generated by auto-increment in `puller` node of `processor.pipeline`.

@@ -69,6 +74,8 @@ func ComparePolymorphicEvents(i, j *PolymorphicEvent) bool {
} else if j.IsResolved() {
return true
}

return i.Sequence() < j.Sequence()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggest to add unit test for ComparePolymorphicEvents.

Signed-off-by: zeminzhou <[email protected]>
Signed-off-by: zeminzhou <[email protected]>
Signed-off-by: zeminzhou <[email protected]>
Copy link
Collaborator

@pingyu pingyu left a comment

Choose a reason for hiding this comment

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

LGTM~

@pingyu
Copy link
Collaborator

pingyu commented Aug 4, 2022

@haojinming PTAL~

@pingyu pingyu merged commit 86810be into tikv:main Aug 4, 2022
@zeminzhou zeminzhou deleted the fix-unified-sorter branch August 23, 2022 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The order of the two events may be swapped by unified sort
3 participants