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

br/lightning: add kv writer for external backend #46042

Merged
merged 10 commits into from
Aug 15, 2023

Conversation

tangenta
Copy link
Contributor

What problem does this PR solve?

Issue Number: ref #45719

Problem Summary:

What is changed and how it works?

Check List

Tests

  • 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

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 14, 2023
@tiprow
Copy link

tiprow bot commented Aug 14, 2023

Hi @tangenta. 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/test-infra repository.

@codecov
Copy link

codecov bot commented Aug 14, 2023

Codecov Report

Merging #46042 (365bf3d) into master (5a30540) will decrease coverage by 2.0863%.
The diff coverage is 69.2307%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #46042        +/-   ##
================================================
- Coverage   74.7681%   72.6818%   -2.0863%     
================================================
  Files          1293       1300         +7     
  Lines        398341     400221      +1880     
================================================
- Hits         297832     290888      -6944     
- Misses        81150      90850      +9700     
+ Partials      19359      18483       -876     
Flag Coverage Δ
integration 25.6747% <ø> (-20.5882%) ⬇️
unit 73.3556% <69.2307%> (+0.0013%) ⬆️

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

Components Coverage Δ
dumpling 54.0444% <ø> (ø)
parser 85.0656% <ø> (ø)
br 47.7694% <69.2307%> (-16.7317%) ⬇️

br/pkg/lightning/backend/external/writer.go Outdated Show resolved Hide resolved
if err != nil {
logutil.BgLogger().Error("close data writer failed", zap.Error(err))
}
err = statWriter.Close(w.ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

the two closing is not atomic. what if TiDB node crashes between them and how will we find the dirty files when scanning s3? Do we treat the creating of stat file as the commit point of writing files to s3?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we should add the validation check when TiDB reading from s3.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or maybe the framework will choose another filenamePrefix for the writer, and only expose the successful filenamePrefixs to following reader?

br/pkg/lightning/backend/external/writer.go Outdated 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

br/pkg/lightning/backend/external/writer.go Outdated Show resolved Hide resolved
br/pkg/lightning/backend/external/writer.go Outdated Show resolved Hide resolved
br/pkg/lightning/backend/external/writer.go Outdated Show resolved Hide resolved
br/pkg/lightning/backend/external/writer.go Outdated Show resolved Hide resolved
br/pkg/lightning/backend/external/writer.go Show resolved Hide resolved
br/pkg/lightning/backend/external/writer.go Outdated Show resolved Hide resolved
br/pkg/lightning/backend/external/writer.go Outdated Show resolved Hide resolved
br/pkg/lightning/backend/external/writer_test.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Aug 14, 2023
@hawkingrei
Copy link
Member

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Aug 14, 2023
@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 14, 2023
// Close closes the writer.
func (w *Writer) Close(ctx context.Context) (backend.ChunkFlushStatus, error) {
if w.closed {
return status(true), nil
Copy link
Member

Choose a reason for hiding this comment

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

What's the situation w.closed is true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Normally, it should be closed only once.

Copy link
Member

Choose a reason for hiding this comment

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

So, if it's a bug that w.closed is true, we can print an error log.

require.NoError(t, err)
keyCnt += p.keys
}
require.Equal(t, uint64(kvCnt), keyCnt)
Copy link
Member

Choose a reason for hiding this comment

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

How about adding the test for two or three flush() and checking the data and stat file names?

@ti-chi-bot
Copy link

ti-chi-bot bot commented Aug 15, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lance6716, wjhuang2016

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

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [lance6716,wjhuang2016]

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

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 15, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Aug 15, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-08-14 07:01:29.502961916 +0000 UTC m=+528054.051977888: ☑️ agreed by lance6716.
  • 2023-08-15 08:45:47.847760847 +0000 UTC m=+620712.396776834: ☑️ agreed by wjhuang2016.

@ti-chi-bot ti-chi-bot bot merged commit d426bcd into pingcap:master Aug 15, 2023
4 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test Indicates a PR is ready to be tested. 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.

4 participants