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

cdc: add changefeed epoch to prevent unexpected state #8268

Merged
merged 16 commits into from
Feb 19, 2023

Conversation

overvenus
Copy link
Member

What problem does this PR solve?

Issue Number: close #7657
Also close #8242

What is changed and how it works?

Add changefeed epoch, so we can distinguish messages after changefeed restart.

Check List

Tests

  • Unit test

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

Fix an issue that may cause data lost or checkpoint stuck when changefeed restarting.

@overvenus overvenus added the area/ticdc Issues or PRs related to TiCDC. label Feb 15, 2023
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Feb 15, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • 3AceShowHand
  • zhaoxinyu

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 needs-cherry-pick-release-5.0 Should cherry pick this PR to release-5.0 branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. needs-cherry-pick-release-5.1 Should cherry pick this PR to release-5.1 branch. needs-cherry-pick-release-5.2 Should cherry pick this PR to release-5.2 branch. needs-cherry-pick-release-5.3 Should cherry pick this PR to release-5.3 branch. needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Feb 15, 2023
@overvenus
Copy link
Member Author

/run-all-tests

cdc/model/changefeed.go Outdated Show resolved Hide resolved
@overvenus
Copy link
Member Author

/run-all-tests

@overvenus
Copy link
Member Author

/run-all-tests

@@ -146,6 +146,8 @@ type ChangeFeedInfo struct {
Error *RunningError `json:"error"`

CreatorVersion string `json:"creator-version"`
// Epoch is the epoch of a changefeed, changes on every restart.
Copy link
Contributor

Choose a reason for hiding this comment

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

how about refine this comment, what an epoch stand for ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is epoch similar to term?

@@ -583,6 +584,7 @@ LOOP:
c.initialized = true
log.Info("changefeed initialized",
zap.String("namespace", c.state.ID.Namespace),
zap.Uint64("changefeedEpoch", epoch),
Copy link
Contributor

Choose a reason for hiding this comment

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

reorder the fields, changefeed first, and rename this to epoch should be ok.

@@ -370,6 +359,18 @@ func (m *feedStateManager) patchState(feedState model.FeedState) {
info.AdminJobType = adminJobType
changed = true
}
if updateEpoch {
previous := info.Epoch
ctx, cancel := context.WithTimeout(context.TODO(), 5*time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is context.TODO() ok here ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Tried, it will change a lot of unrelated code, I'll add a TODO here.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Feb 17, 2023
@overvenus
Copy link
Member Author

/run-all-tests

@overvenus
Copy link
Member Author

/run-all-tests

@overvenus
Copy link
Member Author

/run-verify

@ti-chi-bot
Copy link
Member

@overvenus: 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

trigger some heavy tests which will not run always when PR updated.

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
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-5.4: #8297.

ti-chi-bot pushed a commit to ti-chi-bot/tiflow that referenced this pull request Feb 19, 2023
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.1: #8298.

ti-chi-bot pushed a commit to ti-chi-bot/tiflow that referenced this pull request Feb 19, 2023
ti-chi-bot pushed a commit to ti-chi-bot/tiflow that referenced this pull request Feb 19, 2023
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #8299.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-5.0: #8300.

ti-chi-bot pushed a commit to ti-chi-bot/tiflow that referenced this pull request Feb 19, 2023
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-5.1: #8301.

ti-chi-bot pushed a commit to ti-chi-bot/tiflow that referenced this pull request Feb 19, 2023
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-5.2: #8302.

ti-chi-bot pushed a commit to ti-chi-bot/tiflow that referenced this pull request Feb 19, 2023
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-5.3: #8303.

ti-chi-bot pushed a commit to ti-chi-bot/tiflow that referenced this pull request Feb 19, 2023
overvenus added a commit to ti-chi-bot/tiflow that referenced this pull request Apr 6, 2023
ti-chi-bot pushed a commit that referenced this pull request Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ticdc Issues or PRs related to TiCDC. needs-cherry-pick-release-5.0 Should cherry pick this PR to release-5.0 branch. needs-cherry-pick-release-5.1 Should cherry pick this PR to release-5.1 branch. needs-cherry-pick-release-5.2 Should cherry pick this PR to release-5.2 branch. needs-cherry-pick-release-5.3 Should cherry pick this PR to release-5.3 branch. needs-cherry-pick-release-5.4 Should cherry pick this PR to release-5.4 branch. needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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
4 participants