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

pkg/gtid: remove gtid.Set interface #5246

Merged
merged 11 commits into from
May 23, 2022

Conversation

lance6716
Copy link
Contributor

@lance6716 lance6716 commented Apr 22, 2022

What problem does this PR solve?

Issue Number: close #4287

What is changed and how it works?

compared with mysql.GTIDSet, gtid.Set has two more methods.

Check List

Tests

  • Unit test

Code changes

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

Related changes

  • Need to cherry-pick to the release branch

Release note

 `None`.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Apr 22, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • Ehco1996
  • lichunzhu

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added the release-note-none Denotes a PR that doesn't merit a release note. label Apr 22, 2022
@lance6716 lance6716 added the area/dm Issues or PRs related to DM. label Apr 22, 2022
@ti-chi-bot ti-chi-bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Apr 22, 2022
@lance6716
Copy link
Contributor Author

lance6716 commented Apr 22, 2022

I'll write a better copy-on-write API for GTID set after binlog streamer refactor (binlog streamer is the only writer for location under the syncer, things will be more simple then).

Signed-off-by: lance6716 <[email protected]>
@lance6716
Copy link
Contributor Author

/run-dm-integration-test

@lance6716 lance6716 changed the title [DNM] pkg/gtid: remove gtid.Set interface pkg/gtid: remove gtid.Set interface Apr 22, 2022
@lance6716 lance6716 changed the title pkg/gtid: remove gtid.Set interface [WIP]pkg/gtid: remove gtid.Set interface Apr 22, 2022
@ti-chi-bot ti-chi-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 22, 2022
@lance6716
Copy link
Contributor Author

/run-dm-integration-test

@lance6716 lance6716 changed the title [WIP]pkg/gtid: remove gtid.Set interface pkg/gtid: remove gtid.Set interface Apr 24, 2022
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 24, 2022
@lance6716
Copy link
Contributor Author

/run-dm-integration-test

@codecov-commenter
Copy link

codecov-commenter commented Apr 24, 2022

Codecov Report

Merging #5246 (4c6889a) into master (687e248) will decrease coverage by 0.1939%.
The diff coverage is 52.0242%.

Flag Coverage Δ
cdc 60.8658% <52.0242%> (+0.2671%) ⬆️
dm 52.0171% <ø> (-0.4525%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@@               Coverage Diff                @@
##             master      #5246        +/-   ##
================================================
- Coverage   56.1240%   55.9300%   -0.1940%     
================================================
  Files           522        520         -2     
  Lines         65325      67858      +2533     
================================================
+ Hits          36663      37953      +1290     
- Misses        25094      26184      +1090     
- Partials       3568       3721       +153     

@lance6716 lance6716 requested review from lichunzhu and GMHDBJD April 24, 2022 06:04
Copy link
Contributor

@lichunzhu lichunzhu left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 328 to 348
return cmp <= 0
}
// not supposed to happen, for safety here.
if location1.gtidSet != nil && location1.gtidSet.String() != "" {
if cmp > 0 {
return false
}
// should not happen
if cmp < 0 {
return true
}
// empty GTIDSet, then compare by position
log.L().Warn("both gtidSets are empty, will compare by position", zap.Stringer("location1", location1), zap.Stringer("location2", location2))
log.L().Warn("given gtidSets is empty, will compare by position", zap.Stringer("location", location))
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: use switch here?

return ""
}
var buf strings.Builder
buf.WriteString(fmt.Sprintf("location(%s)", b.location))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
buf.WriteString(fmt.Sprintf("location(%s)", b.location))
fmt.Fprintf(&buf, "location(%s)", b.location)

var buf strings.Builder
buf.WriteString(fmt.Sprintf("location(%s)", b.location))
if b.ti != nil {
buf.WriteString(fmt.Sprintf(", tableInfo(ID: %d, Name:%s, ColNum: %d, IdxNum: %d, PKIsHandle: %t)", b.ti.ID, b.ti.Name, len(b.ti.Columns), len(b.ti.Indices), b.ti.PKIsHandle))
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@@ -183,7 +192,7 @@ func (b *binlogPoint) String() string {
b.RLock()
defer b.RUnlock()

return fmt.Sprintf("%v(flushed %v)", b.savedPoint, b.flushedPoint)
return fmt.Sprintf("%s(flushed %s)", b.savedPoint.String(), b.flushedPoint.String())
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 25, 2022
Copy link
Contributor

@Ehco1996 Ehco1996 left a comment

Choose a reason for hiding this comment

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

lgtm

dm/pkg/binlog/position.go Show resolved Hide resolved
@lance6716 lance6716 changed the base branch from master to refactor-syncer April 28, 2022 03:22
@purelind
Copy link
Collaborator

/run-dm-integration-test

@purelind
Copy link
Collaborator

/run-verify

@purelind
Copy link
Collaborator

/run-dm-compatibility-tests

@purelind
Copy link
Collaborator

/run-dm-integration-tests

@purelind
Copy link
Collaborator

/run-dm-compatibility-tests
/run-dm-integration-tests

@lance6716
Copy link
Contributor Author

ptal @Ehco1996 @GMHDBJD

@lance6716 lance6716 changed the base branch from refactor-syncer to master May 23, 2022 02:25
@lance6716
Copy link
Contributor Author

I think this change will reduce efforts on other PRs which are related to GTID, so I change the base branch to master. cc @Ehco1996 @lichunzhu @GMHDBJD

will resolve conflict later.

@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 23, 2022
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 23, 2022
@lance6716
Copy link
Contributor Author

/run-dm-integration-test

@lance6716
Copy link
Contributor Author

/run-dm-integration-test

@lance6716
Copy link
Contributor Author

/run-verify

Copy link
Contributor

@Ehco1996 Ehco1996 left a comment

Choose a reason for hiding this comment

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

LGTM ~ nice work

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels May 23, 2022
@lance6716
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: e680bc8

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label May 23, 2022
@lance6716
Copy link
Contributor Author

/run-dm-integration-test

@ti-chi-bot
Copy link
Member

@lance6716: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot merged commit 066e082 into pingcap:master May 23, 2022
@lance6716 lance6716 deleted the refactor-gtidset branch October 13, 2022 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dm Issues or PRs related to DM. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refine code
6 participants