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

simulator(dm): implement some core components #4838

Merged
merged 9 commits into from
Apr 25, 2022

Conversation

dsdashun
Copy link
Contributor

What problem does this PR solve?

Issue Number: ref #4835

What is changed and how it works?

Implemented some core components of the simulator:

  • modification candidate pool (MCP)
  • random SQL generator based on unique keys

Check List

Tests

  • Unit test

Code changes

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

Side effects

  • Increased code complexity

Related changes

N/A

Release note

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Mar 10, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • Ehco1996
  • 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. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 10, 2022
@dsdashun dsdashun added the area/dm Issues or PRs related to DM. label Mar 10, 2022
@dsdashun
Copy link
Contributor Author

/run-verify

@codecov-commenter
Copy link

codecov-commenter commented Mar 10, 2022

Codecov Report

Merging #4838 (699c0db) into master (687e248) will decrease coverage by 0.0336%.
The diff coverage is 51.3988%.

Flag Coverage Δ
cdc 60.8452% <51.3988%> (+0.2466%) ⬆️
dm 52.3731% <ø> (-0.0965%) ⬇️

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

@@               Coverage Diff                @@
##             master      #4838        +/-   ##
================================================
- Coverage   56.1240%   56.0903%   -0.0337%     
================================================
  Files           522        523         +1     
  Lines         65325      68436      +3111     
================================================
+ Hits          36663      38386      +1723     
- Misses        25094      26287      +1193     
- Partials       3568       3763       +195     

Copy link
Contributor

@lance6716 lance6716 left a comment

Choose a reason for hiding this comment

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

will review later

dm/simulator/internal/mcp/mcp.go Outdated Show resolved Hide resolved
dm/simulator/internal/mcp/mcp.go Show resolved Hide resolved
dm/simulator/internal/mcp/mcp.go Outdated Show resolved Hide resolved
dm/simulator/internal/mcp/mcp_test.go Show resolved Hide resolved
dm/simulator/internal/mcp/mcp_test.go Outdated Show resolved Hide resolved
dm/simulator/internal/mcp/uk.go Show resolved Hide resolved
dm/simulator/internal/mcp/mcp.go Outdated Show resolved Hide resolved
dm/simulator/internal/mcp/mcp.go Outdated Show resolved Hide resolved
dm/simulator/internal/mcp/mcp.go Outdated Show resolved Hide resolved
dm/simulator/internal/mcp/mcp.go Outdated Show resolved Hide resolved
dm/simulator/internal/sqlgen/impl.go Outdated Show resolved Hide resolved
dm/simulator/internal/sqlgen/impl_test.go Outdated Show resolved Hide resolved
dm/simulator/internal/mcp/mcp_test.go Show resolved Hide resolved
}
}

func (s *testMCPSuite) TestMCPAddDeleteInParallel() {
Copy link
Contributor

Choose a reason for hiding this comment

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

since operations on MCP is serialized(always locked), i think this test is not needed, but it's ok to keep it.

dm/simulator/internal/mcp/mcp.go Outdated Show resolved Hide resolved
}

// NextUK randomly picks a unique key in the MCP.
func (mcp *ModificationCandidatePool) NextUK() *UniqueKey {
Copy link
Contributor

Choose a reason for hiding this comment

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

we may need to allocate some uks in batch if the performance is not satisfied

Copy link
Contributor

Choose a reason for hiding this comment

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

Considering that we have introduced tikv/pd dep, maybe we can reuse pd.GenerateTSO

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.

How about add a sqlgen demo?

* Refined MCP and SQLGen implementations according to the PR comments
* Also refined tests
@dsdashun
Copy link
Contributor Author

/run-verify

Copy link
Contributor

@lance6716 lance6716 left a comment

Choose a reason for hiding this comment

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

will review sqlgen soon

dm/simulator/internal/mcp/mcp_test.go Show resolved Hide resolved
dm/simulator/internal/mcp/uk.go Outdated Show resolved Hide resolved
dm/simulator/internal/mcp/uk.go Outdated Show resolved Hide resolved
dm/simulator/internal/mcp/uk_test.go Outdated Show resolved Hide resolved
dm/simulator/internal/mcp/errors.go Show resolved Hide resolved
}

// NextUK randomly picks a unique key in the MCP.
func (mcp *ModificationCandidatePool) NextUK() *UniqueKey {
Copy link
Contributor

Choose a reason for hiding this comment

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

Considering that we have introduced tikv/pd dep, maybe we can reuse pd.GenerateTSO

dm/simulator/internal/mcp/mcp.go Show resolved Hide resolved
dm/simulator/internal/mcp/uk.go Show resolved Hide resolved
dm/simulator/internal/sqlgen/sqlgen.go Show resolved Hide resolved
Copy link
Contributor

@lance6716 lance6716 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/simulator/internal/sqlgen/impl.go Outdated Show resolved Hide resolved
dm/simulator/internal/sqlgen/impl.go Show resolved Hide resolved
@lance6716
Copy link
Contributor

ping @dsdashun

@lance6716
Copy link
Contributor

What should we do about this PR @dsdashun

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

@Ehco1996 Ehco1996 left a comment

Choose a reason for hiding this comment

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

LGTM

)

// SQLGenerator contains all the operations for generating SQLs.
type SQLGenerator interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

need a GenCreateTableSQL func to make sqlgen more friendly

maybe do this later

@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 Apr 22, 2022
@dsdashun
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

@dsdashun: /merge is only allowed for the committers, you can assign this pull request to the committer in list by filling /assign @committer in the comment to help merge this pull request.

In response to this:

/merge

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

/hold

I think we can merge it after the v6.1 LTS release

@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 Apr 22, 2022
@D3Hunter
Copy link
Contributor

/hold

I think we can merge it after the v6.1 LTS release

seems doesn't matter, this module is quite standalone

@lance6716
Copy link
Contributor

/unhold
just learned that code freeze for v6.1 is 5/19

@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 Apr 24, 2022
@lance6716
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 08b991d

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 24, 2022
@ti-chi-bot
Copy link
Member

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

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 ti-chi-bot merged commit 06f54d0 into pingcap:master Apr 25, 2022
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. 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.

7 participants