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 range properties codec and kv/stats reader #45796

Merged
merged 19 commits into from
Aug 7, 2023

Conversation

tangenta
Copy link
Contributor

@tangenta tangenta commented Aug 3, 2023

What problem does this PR solve?

Issue Number: ref #45719

Problem Summary:

What is changed and how it works?

  • Add kv reader and stats reader.
  • Add codec for range properties.

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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 3, 2023
@tiprow
Copy link

tiprow bot commented Aug 3, 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.

@tangenta
Copy link
Contributor Author

tangenta commented Aug 3, 2023

/hold wait for #45724.

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 3, 2023
@codecov
Copy link

codecov bot commented Aug 3, 2023

Codecov Report

Merging #45796 (3663f96) into master (de30804) will increase coverage by 0.0512%.
Report is 7 commits behind head on master.
The diff coverage is 41.7391%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #45796        +/-   ##
================================================
+ Coverage   73.3404%   73.3916%   +0.0512%     
================================================
  Files          1274       1280         +6     
  Lines        393217     394448      +1231     
================================================
+ Hits         288387     289492      +1105     
- Misses        86445      86522        +77     
- Partials      18385      18434        +49     
Flag Coverage Δ
integration 78.1388% <ø> (?)
unit 73.3835% <41.7391%> (+0.0430%) ⬆️

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

Components Coverage Δ
dumpling 54.0444% <ø> (ø)
parser 85.0467% <ø> (+0.0108%) ⬆️
br 52.1111% <41.7391%> (+0.0675%) ⬆️

@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 4, 2023
@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 4, 2023
@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 4, 2023
br/pkg/lightning/backend/external/codec.go Show resolved Hide resolved

func (r *kvReader) nextKV() (key, val []byte, err error) {
if r.byteReader.eof() {
return nil, nil, 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 we return the error directly to caller?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Let me remove the eof flag.

}
propLen := int(binary.BigEndian.Uint32(*lenBytes))
if cap(r.propBytes) < propLen {
r.propBytes = make([]byte, propLen)
Copy link
Contributor

Choose a reason for hiding this comment

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

r.propBytes is not used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

}
r.byteReader.reset()
lenBytes, err := r.byteReader.readNBytes(4)
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

it may return EOF here.

Copy link
Contributor

@lance6716 lance6716 Aug 4, 2023

Choose a reason for hiding this comment

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

should convert to UnexpectedEOF except for the first readNBytes

@tangenta
Copy link
Contributor Author

tangenta commented Aug 4, 2023

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 4, 2023
// noEOF converts the EOF error to io.ErrUnexpectedEOF.
func noEOF(err error) error {
if err == io.EOF {
return io.ErrUnexpectedEOF
Copy link
Member

Choose a reason for hiding this comment

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

The error is not traced

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we can have more clues when this is reported(even if it is traced).

Copy link
Member

Choose a reason for hiding this comment

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

At least we can know the stack.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update.

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Aug 7, 2023
Comment on lines +29 to +36
sr, err := openStoreReaderAndSeek(ctx, store, name, 0)
if err != nil {
return nil, err
}
br, err := newByteReader(ctx, sr, bufSize)
if err != nil {
return nil, err
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same with kv_reader.go: 30-34

Copy link
Contributor Author

Choose a reason for hiding this comment

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

initFileOffset is different. I think it is simple enough.

}, nil
}

func (r *kvReader) nextKV() (key, val []byte, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

kvReader and statReader's only have different nextxxx function, can we merge the code into one? just pass a function into the next function.

var k, v
next(func() {
 k, v = 
})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Merging them into one is a bad idea because one may mistakenly call nextProps() after nextKV(), which is nonsense.

@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 7, 2023
@ti-chi-bot ti-chi-bot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 7, 2023
@lance6716
Copy link
Contributor

/lgtm

@ti-chi-bot
Copy link

ti-chi-bot bot commented Aug 7, 2023

@lance6716: Your lgtm message is repeated, so it is ignored.

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 kubernetes/test-infra repository.

@wjhuang2016
Copy link
Member

/lgtm

@ti-chi-bot ti-chi-bot bot added the lgtm label Aug 7, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Aug 7, 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 removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Aug 7, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Aug 7, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-08-07 03:45:57.72528423 +0000 UTC m=+675441.667632762: ☑️ agreed by lance6716.
  • 2023-08-07 10:02:03.164446798 +0000 UTC m=+7400.798292206: ☑️ agreed by wjhuang2016.

@ti-chi-bot ti-chi-bot bot merged commit 7212a5f into pingcap:master Aug 7, 2023
10 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants