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

changefeed (ticdc): fix data lost when pause and resume changefeed while executing DDL. #7683

Merged
merged 2 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion cdc/owner/changefeed.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,12 @@ LOOP:
return errors.Trace(err)
}

// we must clean cached ddl and tables in changefeed initialization
// otherwise, the changefeed will loss tables that are needed to be replicated
// ref: https://github.com/pingcap/tiflow/issues/7682
c.ddlEventCache = nil
c.currentTables = nil

cancelCtx, cancel := cdcContext.WithCancel(ctx)
c.cancel = cancel

Expand Down Expand Up @@ -609,7 +615,9 @@ func (c *changefeed) releaseResources(ctx cdcContext.Context) {
log.Info("changefeed closed",
zap.String("namespace", c.id.Namespace),
zap.String("changefeed", c.id.ID),
zap.Stringer("info", c.state.Info), zap.Bool("isRemoved", c.isRemoved))
zap.Any("status", c.state.Status),
zap.Stringer("info", c.state.Info),
zap.Bool("isRemoved", c.isRemoved))
}

func (c *changefeed) cleanupMetrics() {
Expand Down
4 changes: 2 additions & 2 deletions tests/integration_tests/batch_update_to_no_batch/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function run() {
# pause changefeed
run_cdc_cli changefeed pause -c ${changefeed_id}
# update changefeed to no batch dml mode
run_cdc_cli changefeed update -c ${changefeed_id} --sink-uri="mysql://root@127.0.0.1:3306/?batch-dml-enable=true" --no-confirm
run_cdc_cli changefeed update -c ${changefeed_id} --sink-uri="mysql://root@127.0.0.1:3306/?batch-dml-enable=false" --no-confirm
# resume changefeed
run_cdc_cli changefeed resume -c ${changefeed_id}

Expand All @@ -53,7 +53,7 @@ function run() {
# pause changefeed
run_cdc_cli changefeed pause -c ${changefeed_id}
# update changefeed to no batch dml mode
run_cdc_cli changefeed update -c ${changefeed_id} --sink-uri="mysql://root@127.0.0.1:3306/?batch-dml-enable=false" --no-confirm
run_cdc_cli changefeed update -c ${changefeed_id} --sink-uri="mysql://root@127.0.0.1:3306/?batch-dml-enable=true" --no-confirm
# resume changefeed
run_cdc_cli changefeed resume -c ${changefeed_id}

Expand Down