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(both): a separate library for DML row change #4376

Merged
merged 13 commits into from
Feb 8, 2022

Conversation

lance6716
Copy link
Contributor

@lance6716 lance6716 commented Jan 18, 2022

What problem does this PR solve?

Issue Number: ref #3242

What is changed and how it works?

provide a representation for DML (row change), and some conversion of it. Also fix some wrong behaviour of original code (such as we should decide generated column from target table structure)

next PR I'll let DM adopt this library, and future plans are

  • CDC adopt this library
  • propose a DML worker which include reduce/causality/executeSQL functionality

Check List

Tests

Code changes

  • Has exported function/method change
  • Has exported variable/fields change

Side effects

Related changes

Release note

 `None`.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jan 18, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • GMHDBJD
  • amyangfei

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 do-not-merge/needs-linked-issue 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. release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/needs-linked-issue release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Jan 18, 2022
@lance6716 lance6716 added area/dm Issues or PRs related to DM. area/ticdc Issues or PRs related to TiCDC. labels Jan 18, 2022
@lance6716
Copy link
Contributor Author

/cc @GMHDBJD @amyangfei @liuzix

@lance6716 lance6716 changed the title pkg(both): a seperate library for DML row change pkg(both): a separate library for DML row change Jan 18, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jan 18, 2022

Codecov Report

Merging #4376 (0117a7a) into master (ab62e6b) will decrease coverage by 0.1013%.
The diff coverage is 45.0581%.

Flag Coverage Δ
cdc 59.2862% <54.6042%> (-0.3298%) ⬇️
dm 52.1033% <40.9688%> (+0.0377%) ⬆️

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

@@               Coverage Diff                @@
##             master      #4376        +/-   ##
================================================
- Coverage   55.5183%   55.4169%   -0.1014%     
================================================
  Files           495        498         +3     
  Lines         61151      61649       +498     
================================================
+ Hits          33950      34164       +214     
- Misses        23789      24063       +274     
- Partials       3412       3422        +10     

@lance6716
Copy link
Contributor Author

/cc @glorv

@ti-chi-bot ti-chi-bot requested a review from glorv January 18, 2022 08:02
pkg/sqlmodel/multivalue.go Outdated Show resolved Hide resolved
pkg/sqlmodel/multivalue.go Show resolved Hide resolved
if tiCtx != nil {
ret.tiSessionCtx = tiCtx
} else {
ret.tiSessionCtx = utils.NewSessionCtx(nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you check the cost of NewSessionCtx?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to use a global variable

Comment on lines 328 to 329
variables.Rng.SetSeed1(0)
variables.Rng.SetSeed2(0)
Copy link
Contributor

Choose a reason for hiding this comment

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

What are these two lines used for?

Copy link
Contributor Author

@lance6716 lance6716 Jan 20, 2022

Choose a reason for hiding this comment

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

Removed now. Originally I'm use different session context instance for each RowChange, their random seed fields are different so can't pass DeepEquals

@lance6716
Copy link
Contributor Author

I think this library can provide different Causality function like RowCausality, TableCausality 🤔

type CausalityKeyFunc func (change *RowChange) []string

Will add it in future PR because I want to reduce divergence with #4313

"github.com/pingcap/tiflow/pkg/quotes"
)

// SameTypeTargetAndColumns check whether two row changes have same type, target and columns, so they can be merged to a
Copy link
Member

Choose a reason for hiding this comment

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

Please keep line width within 80 chars.

r.identityInfo = schema.GetDownStreamTI(r.targetTableInfo, r.sourceTableInfo)
}

func getColsAndValuesOfIdx(columns []*timodel.ColumnInfo, indexColumns *timodel.IndexInfo, data []interface{}) ([]*timodel.ColumnInfo, []interface{}) {
Copy link
Member

Choose a reason for hiding this comment

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

Please keep line width within 80 chars.

Copy link
Member

@overvenus overvenus Jan 21, 2022

Choose a reason for hiding this comment

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

1 table = 4 spaces.

@lance6716
Copy link
Contributor Author

ping @glorv

@lance6716
Copy link
Contributor Author

ping @amyangfei @liuzix @GMHDBJD

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

@GMHDBJD GMHDBJD left a comment

Choose a reason for hiding this comment

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

LGTM

@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 Feb 7, 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: d58b935

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

/check-issue-triage-complete

@lance6716
Copy link
Contributor Author

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

@lance6716
Copy link
Contributor Author

/hold

test failed

@ti-chi-bot ti-chi-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 7, 2022
@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Feb 7, 2022
@lance6716
Copy link
Contributor Author

after DPanic takes effect, I found a problem f2c4bcb

PTAL @GMHDBJD and /merge if looks good

@lance6716
Copy link
Contributor Author

/run-dm-integration-test

@lance6716
Copy link
Contributor Author

/unhold
/merge

@ti-chi-bot ti-chi-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 8, 2022
@ti-chi-bot
Copy link
Member

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

Commit hash: f2c4bcb

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

/run-kafka-integration-test

@ti-chi-bot ti-chi-bot merged commit 3c410c5 into pingcap:master Feb 8, 2022
@lance6716 lance6716 deleted the dmlmodel 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. area/ticdc Issues or PRs related to TiCDC. 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.

8 participants