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

ddl/ingest: add the management infra for lightning struct #37521

Merged
merged 22 commits into from
Sep 6, 2022

Conversation

tangenta
Copy link
Contributor

@tangenta tangenta commented Aug 31, 2022

What problem does this PR solve?

Issue Number: ref #35983

What is changed and how it works?

This PR encapsulate the lightning structs such as Backend, Engine and Writer, so that it could be easily used by onCreateIndex().

image

Check List

Tests

It is not easy to write unit tests because it needs the cluster environment.

The integration test has been added in #37320. We will switch the add index process after the whole development is finished & merged.

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@tangenta tangenta requested a review from a team as a code owner August 31, 2022 13:02
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Aug 31, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • xiongjiwei
  • zimulala

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 Aug 31, 2022
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Aug 31, 2022

@@ -318,6 +318,15 @@ func TidbOptInt64(opt string, defaultVal int64) int64 {
return val
}

// TidbOptUint64 converts a string to an uint64.
func TidbOptUint64(opt string, defaultVal uint64) uint64 {
Copy link
Contributor

Choose a reason for hiding this comment

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

s/TidbOptUint64/TiDBOptUint64

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is consistent with TidbOptInt64, TidbOptInt and tidbOptFloat64, should I rename the others?

ddl/lightning/backend.go Outdated Show resolved Hide resolved
ddl/lightning/backend.go Outdated Show resolved Hide resolved
ddl/lightning/message.go Outdated Show resolved Hide resolved
// Calculate lightning concurrency degree and set memory usage
// and pre-allocate memory usage for worker.
m.MemRoot.RefreshConsumption()
ok := m.MemRoot.TestConsume(int64(bc.cfg.TikvImporter.LocalWriterMemCacheSize))
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can rename this function TestConsume, like checkConsume or other names. The name confused me a little bit, thinking it was code for testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is suggested by @xiongjiwei ... let me change it to CheckConsume.

ddl/lightning/engine_mgr.go Outdated Show resolved Hide resolved
ddl/lightning/engine_mgr.go Outdated Show resolved Hide resolved
ei.Clean()
m.Delete(indexID)
m.MemRoot.ReleaseWithTag(encodeEngineTag(jobID, indexID))
m.MemRoot.Release(StructSizeWriterCtx * int64(ei.writerCount))
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see Consume StructSizeWriterCtx in Register, so why do we need to release it here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. b1bfdba

ddl/lightning/mem_root.go Show resolved Hide resolved
ddl/lightning/env.go Outdated Show resolved Hide resolved
ddl/lightning/env.go Outdated Show resolved Hide resolved
ddl/lightning/message.go Outdated Show resolved Hide resolved
ddl/lightning/config.go Outdated Show resolved Hide resolved
}
}

type glueLit struct{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add comments for glueLit.
Besides, do we need to implement this struct's functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do we need to implement this struct's functions?

No, it is a noop struct.

ddl/lightning/config.go Outdated Show resolved Hide resolved
ddl/lightning/config.go Outdated Show resolved Hide resolved
if !exist {
return
}
bc.EngMgr.UnregisterAll(jobID)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see where EngMgr.Register is called. Has it not been called yet or am I reading it wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The engineInfo is initialized in writePhysicalTableRecord. It will be used in the next PR:

https://github.com/pingcap/tidb/pull/36767/files#diff-1bbc7833321782b3a22a842b6237974b6a60cb07b49b246b85552ab5e915ed6eR757

ddl/lightning/engine.go Outdated Show resolved Hide resolved
ddl/lightning/engine.go Outdated Show resolved Hide resolved
@@ -0,0 +1,115 @@
// Copyright 2022 PingCAP, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add some UT for this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. BTW genRLimit is a wrapper for system call, it is meaningless to test it..

@ti-chi-bot ti-chi-bot added the status/LGT2 Indicates that a PR has LGTM 2. label Sep 5, 2022
@tangenta
Copy link
Contributor Author

tangenta commented Sep 5, 2022

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 9d02ffb

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

tangenta commented Sep 5, 2022

/hold cc @pingcap/tidb-configuration-reviewer

@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 Sep 5, 2022
@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Sep 5, 2022
@tangenta tangenta changed the title ddl/lightning: add the management infra for lightning struct ddl/ingest: add the management infra for lightning struct Sep 5, 2022
Copy link
Collaborator

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

@Benjamin2037: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments.

In response to this:

LGTM

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.

ddl/ingest/BUILD.bazel Outdated Show resolved Hide resolved
ddl/ingest/BUILD.bazel Outdated Show resolved Hide resolved
ddl/ingest/BUILD.bazel Outdated Show resolved Hide resolved
ddl/ingest/BUILD.bazel Outdated Show resolved Hide resolved
Copy link
Member

@bb7133 bb7133 left a comment

Choose a reason for hiding this comment

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

LGTM

@bb7133
Copy link
Member

bb7133 commented Sep 5, 2022

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 51f1095

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

bb7133 commented Sep 5, 2022

/hold

@tangenta
Copy link
Contributor Author

tangenta commented Sep 6, 2022

/unhold

@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 Sep 6, 2022
@ti-chi-bot ti-chi-bot merged commit 878ac8e into pingcap:master Sep 6, 2022
@sre-bot
Copy link
Contributor

sre-bot commented Sep 6, 2022

TiDB MergeCI notify

CI Name Result Duration Compare with Parent commit
idc-jenkins-ci/integration-cdc-test 🟢 all 37 tests passed 26 min Existing passed
idc-jenkins-ci-tidb/common-test 🟢 all 11 tests passed 12 min Existing passed
idc-jenkins-ci-tidb/integration-common-test 🟢 all 17 tests passed 11 min Existing passed
idc-jenkins-ci-tidb/tics-test 🟢 all 1 tests passed 6 min 59 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-2 🟢 all 28 tests passed 4 min 59 sec Existing passed
idc-jenkins-ci-tidb/integration-ddl-test 🟢 all 6 tests passed 4 min 45 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-1 🟢 all 26 tests passed 4 min 22 sec Existing passed
idc-jenkins-ci-tidb/mybatis-test 🟢 all 1 tests passed 3 min 11 sec Existing passed
idc-jenkins-ci-tidb/integration-compatibility-test 🟢 all 1 tests passed 3 min 0 sec Existing passed
idc-jenkins-ci-tidb/plugin-test 🟢 build success, plugin test success 4min Existing passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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