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

DM: support inject at dml when open GTID #4848

Closed
wants to merge 5 commits into from
Closed

DM: support inject at dml when open GTID #4848

wants to merge 5 commits into from

Conversation

WizardXiao
Copy link
Contributor

@WizardXiao WizardXiao commented Mar 11, 2022

What problem does this PR solve?

Issue Number: ref #4260

What is changed and how it works?

  1. As inject handle will add the original dml to the last event to be inject, we check weather dml was executed will not check position but gtid and suffix when open gitd, but the last event's suffix will set to be 0, and it will be ignore.
  2. Change the location saved table checkpoint or global checkpoint to be a cloned location which suffix is 0, so when check the last event's location will not ignore it, because it will be equal and dml will execute.
  3. Change the compare when flush checkpoint to just use compare position, because there is no suffix and the gtid may be equal when handle error.

Check List

Tests

  • Unit test
  • Integration test

Release note

None

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has not been approved.

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 Denotes a PR that will be considered when it comes time to generate release notes. label Mar 11, 2022
@WizardXiao WizardXiao added the area/dm Issues or PRs related to DM. label Mar 11, 2022
@ti-chi-bot ti-chi-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 11, 2022
@WizardXiao WizardXiao added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 11, 2022
@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Mar 11, 2022
@WizardXiao
Copy link
Contributor Author

/run-all-tests

@WizardXiao WizardXiao added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 11, 2022
Copy link
Contributor

@buchuitoudegou buchuitoudegou left a comment

Choose a reason for hiding this comment

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

typos😀

@@ -177,6 +177,8 @@ func (h *Holder) MatchAndApply(startLocation, endLocation binlog.Location, curre
h.mu.Lock()
defer h.mu.Unlock()

h.logger.Info("try to match and apply a operator", zap.Stringer("startlocation", startLocation), zap.Stringer("endlocation", endLocation), zap.Any("currentEvent", currentEvent))
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
h.logger.Info("try to match and apply a operator", zap.Stringer("startlocation", startLocation), zap.Stringer("endlocation", endLocation), zap.Any("currentEvent", currentEvent))
h.logger.Info("try to match and apply an operator", zap.Stringer("startlocation", startLocation), zap.Stringer("endlocation", endLocation), zap.Any("currentEvent", currentEvent))

@@ -215,7 +217,7 @@ func (h *Holder) MatchAndApply(startLocation, endLocation binlog.Location, curre
}
}

h.logger.Info("match and apply a operator", zap.Stringer("startlocation", startLocation), zap.Stringer("endlocation", endLocation), zap.Stringer("operator", operator))
h.logger.Info("match and apply a operator", zap.Stringer("startlocation", startLocation), zap.Stringer("endlocation", endLocation), zap.Any("currentEvent", currentEvent), zap.Stringer("operator", operator))
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
h.logger.Info("match and apply a operator", zap.Stringer("startlocation", startLocation), zap.Stringer("endlocation", endLocation), zap.Any("currentEvent", currentEvent), zap.Stringer("operator", operator))
h.logger.Info("match and apply an operator", zap.Stringer("startlocation", startLocation), zap.Stringer("endlocation", endLocation), zap.Any("currentEvent", currentEvent), zap.Stringer("operator", operator))

@WizardXiao
Copy link
Contributor Author

/run-all-tests

@WizardXiao WizardXiao added status/ptal Could you please take a look? and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Mar 15, 2022
@@ -274,6 +274,13 @@ func (l Location) Clone() Location {
return l.CloneWithFlavor("")
}

// Clone clones a same location, but reset suffix to 0.
Copy link
Contributor

Choose a reason for hiding this comment

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

please left a todo location whit suffix is hadr do understand, let's refine this logic later

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, suffix logic is hard to understand and it is used in compare location too much. i think i will refine it in other pr.


return binlog.CompareLocation(pos, b.flushedPoint.location, b.enableGTID) > 0
// locations in savedPoint have no suffix and may have same giid like handle-error, we can use position to check them
return binlog.CompareLocation(pos, b.flushedPoint.location, false) > 0
Copy link
Contributor

Choose a reason for hiding this comment

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

seems change the logic in binlog.CompareLocation is more reasonable ?, hardcode to enable gtid to false is too tricky

Copy link
Contributor Author

@WizardXiao WizardXiao Mar 15, 2022

Choose a reason for hiding this comment

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

binlog.CompareLocation is called in many places and i think we may fix it when we refine suffix. outOfDateBy is used to check between table checkpoint and global checkpoint for flush, this kind of point should have right position, so we can use position to check.
bwt, i will add more tests about inject, but first of all, it should not affect other integration tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

add more tests about inject

will you doing this in thie pr or, is this pr ready for review?

Copy link
Contributor Author

@WizardXiao WizardXiao Mar 15, 2022

Choose a reason for hiding this comment

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

not yet. after some tests, it will be more complex when use sharding ddl.

@WizardXiao
Copy link
Contributor Author

need fix inject command when it was called in sharding.

@WizardXiao WizardXiao added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. and removed status/ptal Could you please take a look? labels Mar 15, 2022
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 26, 2022
@ti-chi-bot
Copy link
Member

@WizardXiao: PR needs rebase.

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 kubernetes/test-infra repository.

@lance6716 lance6716 mentioned this pull request Jun 13, 2022
6 tasks
@WizardXiao WizardXiao closed this by deleting the head repository Mar 15, 2023
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. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants