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

syncer(dm): fix log error caused by "COMMIT" in QueryEvent #7726

Merged
merged 21 commits into from
Dec 1, 2022
Merged

syncer(dm): fix log error caused by "COMMIT" in QueryEvent #7726

merged 21 commits into from
Dec 1, 2022

Conversation

liumengya94
Copy link
Contributor

@liumengya94 liumengya94 commented Nov 28, 2022

What problem does this PR solve?

Issue Number: ref #7525

What is changed and how it works?

fix log error and save checkpoint for COMMIT QueryEvent

Check List

Tests

  • Integration 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

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Nov 28, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • D3Hunter
  • lance6716

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 release-note-none Denotes a PR that doesn't merit a release note. needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 28, 2022
@codecov-commenter
Copy link

codecov-commenter commented Nov 28, 2022

Codecov Report

Merging #7726 (fc7999b) into master (b0f5a0b) will increase coverage by 4.9960%.
The diff coverage is 50.6480%.

Additional details and impacted files
Flag Coverage Δ
cdc 66.2097% <45.4326%> (?)
dm 52.3405% <76.0233%> (+0.1935%) ⬆️
engine 64.3319% <ø> (+0.0474%) ⬆️

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

@@               Coverage Diff                @@
##             master      #7726        +/-   ##
================================================
+ Coverage   55.0067%   60.0027%   +4.9960%     
================================================
  Files           415        813       +398     
  Lines         52739      94049     +41310     
================================================
+ Hits          29010      56432     +27422     
- Misses        20957      32723     +11766     
- Partials       2772       4894      +2122     

@liumengya94
Copy link
Contributor Author

/run-dm-integration-test

@liumengya94
Copy link
Contributor Author

/cc @lance6716

@ti-chi-bot ti-chi-bot requested a review from lance6716 November 29, 2022 03:28
dm/syncer/syncer.go Show resolved Hide resolved
@@ -2272,7 +2272,18 @@ func (s *Syncer) Run(ctx context.Context) (err error) {
}
case *replication.QueryEvent:
originSQL = strings.TrimSpace(string(ev.Query))
err2 = s.ddlWorker.HandleQueryEvent(ev, ec, originSQL)
if originSQL == "COMMIT" {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe use a fallthrough to run into the case *replication.XIDEvent: branch

@ti-chi-bot ti-chi-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 29, 2022
}
}

s.tctx.L().Debug("", zap.String("event", "XID"), zap.Stringer("last location", lastTxnEndLocation), log.WrapStringerField("location", endLocation))

job := newXIDJob(endLocation, startLocation, endLocation)
_, err2 = s.handleJobFunc(job)
_, err = s.handleJobFunc(job)
return needContinue, err
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
return needContinue, err
return false, err

use explicit value for better understanding

case *replication.QueryEvent:
originSQL = strings.TrimSpace(string(ev.Query))
if originSQL == "COMMIT" {
needContinue, _ := funCommit()
Copy link
Contributor

Choose a reason for hiding this comment

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

don't call funCommit twice

cleanup_data start_task
prepare_data_MyISAM

cp $cur/conf/source1.yaml $WORK_DIR/source1.yaml
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to copy them if you won't change the file content

@lance6716 lance6716 changed the title fix log error caused by "COMMIT" in QueryEvent syncer(dm): fix log error caused by "COMMIT" in QueryEvent Nov 29, 2022
@liumengya94
Copy link
Contributor Author

/run-all-tests

@liumengya94
Copy link
Contributor Author

/cc @D3Hunter

@ti-chi-bot ti-chi-bot requested a review from D3Hunter November 29, 2022 14:32
dm/syncer/syncer.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 30, 2022
Copy link
Contributor

@D3Hunter D3Hunter 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

dm/syncer/syncer.go Outdated Show resolved Hide resolved
echo "check data"
check_sync_diff $WORK_DIR $cur/conf/diff_config.toml

check_log_not_contains $WORK_DIR/worker1/log/dm-worker.log "originSQL: COMMIT"
Copy link
Contributor

Choose a reason for hiding this comment

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

where does this log printed previously?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in trackOriginDDL, "COMMIT" QueryEvent is identified as ddl, and print log in parseOneStmt

stmt, err := parseOneStmt(qec)

qec.tctx.L().Info("parse ddl", zap.String("event", "query"), zap.Stringer("query event context", qec))

[2022/11/28 14:48:30.512 +08:00] [INFO] [ddl.go:934] ["parse ddl"] [task=test] [unit="binlog replication"] [event=query] ["query event context"="{schema: , originSQL: COMMIT, startLocation: position: (mysql-bin|000001.000001, 4407), gtid-set: e266a895-6e51-11ed-b110-0242ac110002:1-16, endLocation: position: (mysql-bin|000001.000001, 4476), gtid-set: e266a895-6e51-11ed-b110-0242ac110002:1-16, lastLocation: position: (mysql-bin|000001.000001, 4476), gtid-set: e266a895-6e51-11ed-b110-0242ac110002:1-16, re-sync: , needHandleDDLs: , trackInfos: }"]

@liumengya94
Copy link
Contributor Author

/run-all-tests

@liumengya94
Copy link
Contributor Author

/run-dm-integration-test

1 similar comment
@liumengya94
Copy link
Contributor Author

/run-dm-integration-test

@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 Nov 30, 2022
@liumengya94
Copy link
Contributor Author

/run-all-tests

@lance6716
Copy link
Contributor

/run-dm-integration-test

@lance6716
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 030d73c

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

/run-all-tests

1 similar comment
@purelind
Copy link
Collaborator

purelind commented Dec 1, 2022

/run-all-tests

@lance6716
Copy link
Contributor

/run-dm-integration-test
/run-verify

@lance6716
Copy link
Contributor

/run-dm-integration-test

@ti-chi-bot
Copy link
Member

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

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.

@lance6716
Copy link
Contributor

/run-all-tests

@ti-chi-bot ti-chi-bot merged commit bc176c3 into pingcap:master Dec 1, 2022
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #7773.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. 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. 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.

6 participants