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

lightning: remote backend #58789

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Conversation

zeminzhou
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #xxx

Problem Summary:

What changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

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

Signed-off-by: zeminzhou <[email protected]>
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue do-not-merge/needs-tests-checked 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 Jan 8, 2025
Copy link

tiprow bot commented Jan 8, 2025

Hi @zeminzhou. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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 kubernetes-sigs/prow repository.

Signed-off-by: zeminzhou <[email protected]>
Copy link

codecov bot commented Jan 8, 2025

Codecov Report

Attention: Patch coverage is 25.58140% with 832 lines in your changes missing coverage. Please review.

Project coverage is 73.5291%. Comparing base (c199ddf) to head (cd3d941).
Report is 101 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #58789        +/-   ##
================================================
+ Coverage   73.0885%   73.5291%   +0.4405%     
================================================
  Files          1676       1721        +45     
  Lines        463643     493818     +30175     
================================================
+ Hits         338870     363100     +24230     
- Misses       103924     108348      +4424     
- Partials      20849      22370      +1521     
Flag Coverage Δ
integration 45.4801% <5.4561%> (?)
unit 72.1440% <23.2758%> (-0.1423%) ⬇️

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

Components Coverage Δ
dumpling 52.6910% <ø> (ø)
parser ∅ <ø> (∅)
br 42.5734% <ø> (-3.1596%) ⬇️

@ystaticy
Copy link
Contributor

ystaticy commented Jan 8, 2025

Please add UT for remote backend.

@@ -433,13 +434,31 @@ func NewImportControllerWithPauser(
if err != nil {
return nil, err
}
case config.BackendRemote:
Copy link
Contributor

Choose a reason for hiding this comment

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

What error will occur if the user configures the remote backend? Should we prompt the user that this feature is not yet implemented? Additionally, should we add a description in the code comments to avoid confusion for users and developers?

Signed-off-by: zeminzhou <[email protected]>
Signed-off-by: zeminzhou <[email protected]>
Signed-off-by: zeminzhou <[email protected]>
Signed-off-by: zeminzhou <[email protected]>
Copy link

ti-chi-bot bot commented Jan 14, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign gmhdbjd for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Signed-off-by: zeminzhou <[email protected]>
Signed-off-by: zeminzhou <[email protected]>
Signed-off-by: zeminzhou <[email protected]>
Signed-off-by: zeminzhou <[email protected]>
Signed-off-by: zeminzhou <[email protected]>
Signed-off-by: zeminzhou <[email protected]>
@lance6716
Copy link
Contributor

/retest

Copy link

tiprow bot commented Jan 21, 2025

@lance6716: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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 kubernetes-sigs/prow repository.

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

lightning/pkg/importer/get_pre_info.go Outdated Show resolved Hide resolved
lightning/pkg/importer/import.go Show resolved Hide resolved
if err != nil {
return nil, errors.Trace(err)
}
pdHTTPCli = pdhttp.NewClientWithServiceDiscovery(
Copy link
Contributor

Choose a reason for hiding this comment

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

we can add common function to create PD clients. In future we may need to change the construct arguments and forget to modify both backend

pdhttp.WithTLSConfig(tls.TLSConfig()),
).WithBackoffer(retry.InitialBackoffer(time.Second, time.Second, pdutil.PDRequestRetryTime*time.Second))

encodingBuilder = local.NewEncodingBuilder(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the branch of remote backend, but it calls the local package. It makes me think that one nature of local backend is KV encoding in lightning comparing with tidb backend. remote backend also need the local KV encoding functionality, but it has a different way to manage engines. Maybe we can reuse local backend and only add a new type of engines. I'll check this idea when reviewing rest parts

pkg/lightning/backend/remote/chunk.go Show resolved Hide resolved
pkg/lightning/backend/remote/chunk.go Outdated Show resolved Hide resolved
pkg/lightning/backend/remote/chunk.go Outdated Show resolved Hide resolved
pkg/lightning/backend/remote/chunk.go Outdated Show resolved Hide resolved
pkg/lightning/backend/remote/chunk.go Show resolved Hide resolved
pkg/lightning/backend/remote/chunk.go Outdated Show resolved Hide resolved
pkg/lightning/backend/remote/chunk_sender.go Outdated Show resolved Hide resolved
pkg/lightning/backend/remote/chunk_sender.go Outdated Show resolved Hide resolved
pkg/lightning/backend/remote/chunk_sender.go Outdated Show resolved Hide resolved
pkg/lightning/backend/remote/chunk_sender.go Outdated Show resolved Hide resolved
pkg/lightning/backend/remote/chunk_sender.go Show resolved Hide resolved
Signed-off-by: zeminzhou <[email protected]>
Signed-off-by: zeminzhou <[email protected]>
Copy link

ti-chi-bot bot commented Jan 22, 2025

[FORMAT CHECKER NOTIFICATION]

Notice: To remove the do-not-merge/needs-linked-issue label, please provide the linked issue number on one line in the PR body, for example: Issue Number: close #123 or Issue Number: ref #456.

📖 For more info, you can check the "Contribute Code" section in the development guide.


Notice: To remove the do-not-merge/needs-tests-checked label, please finished the tests then check the finished items in description.

For example:

Tests

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

📖 For more info, you can check the "Contribute Code" section in the development guide.

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.

Better to add unit test to reveal the problems first when addressing comments

"github.com/pingcap/errors"
)

type chunkMeta struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe call it chunk? the name chunkMeta makes me think it only contains metadata, but in fact it contains chunkData

usingMem bool
}

func newChunkCache(loadDataTaskID string, writerID uint64, basePath string, usingMem bool) (*chunkCache, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I see usingMem is decided by configuration. Can you explain how to choose the value when generating configuration? Like if source data size is less than 1GB we can use memory

return meta.chunkData, nil
}

path := filepath.Join(c.baseDir, fmt.Sprintf("chunk-%d", chunkID))
Copy link
Contributor

Choose a reason for hiding this comment

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

create a helper function to encode the file path. It can be used by get, put and clean


func (c *chunkCache) put(chunkID uint64, buf []byte) error {
if c.usingMem {
c.chunks[chunkID] = chunkMeta{size: len(buf), chunkData: buf}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not consistent. You also saved the size in put, but it's not used in get

if _, ok := c.chunks[chunkID]; !ok {
return nil
}
delete(c.chunks, chunkID)
Copy link
Contributor

Choose a reason for hiding this comment

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

can directly delete without checking existence

}
}

func (c *chunkSender) putEmptyChunk(ctx context.Context) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the purpose of empty chunk? Please add comments

state := c.state.Load()
lastFlushedChunkID := state.FlushedChunkID + 1
for lastFlushedChunkID <= result.FlushedChunkID {
err := c.chunksCache.clean(lastFlushedChunkID)
Copy link
Contributor

Choose a reason for hiding this comment

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

WIll the remote worker restarts again after we clean the chunk? Please add comments to explain the communication protocol and guarantees

err = json.Unmarshal(data, result)
if err != nil {
return errors.Trace(err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

should check result.Cancled

}
}

state := c.state.Load()
Copy link
Contributor

Choose a reason for hiding this comment

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

check nil

}

// make sure all chunks are flushed
flushedChunkID := result.FlushedChunkIDs[c.id]
Copy link
Contributor

Choose a reason for hiding this comment

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

why the HTTP server will return a map? Why it returns the result of other writer? Please add comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/needs-linked-issue do-not-merge/needs-tests-checked 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants