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

Fix blobstore truncate size may not right #5127

Merged
merged 19 commits into from
Jun 14, 2022

Conversation

jiaqizho
Copy link
Contributor

@jiaqizho jiaqizho commented Jun 10, 2022

What problem does this PR solve?

Issue Number: close #5076 , close #5134

Problem Summary:

  • DB::Exception: No enough data in file /data0/db/page/log/blobfile_6, read bytes: 0 , expected bytes: 43
  • In getGcStats, BlobStore will call the getRightMargin to get the last free space and truncate the file.
  • But getRightMargin will return a invalid value if last free space is not align to end.
  • For example:
    • Space limit is 100. So current space is [0, 100]
    • mark a span {offset=90, size=10} as used, then the free range in SpaceMap is [0, 90).
    • Then we should get 100 when we call getRightMargin
    • But it return 0. Because in getRightMargin, we will get the last free space, and return it start.

What is changed and how it works?

  • Fix the getRightMargin
  • Change the log level when we do truncate.

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

None

@jiaqizho jiaqizho added the needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. label Jun 10, 2022
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jun 10, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • JaySon-Huang
  • flowbehappy

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 the release-note-none Denotes a PR that doesn't merit a release note. label Jun 10, 2022
@ti-chi-bot ti-chi-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 10, 2022
dbms/src/Storages/Page/V3/BlobStore.cpp Outdated Show resolved Hide resolved
dbms/src/Storages/Page/V3/BlobStore.cpp Outdated Show resolved Hide resolved
dbms/src/Storages/Page/V3/BlobStore.cpp Outdated Show resolved Hide resolved
dbms/src/Storages/Page/V3/spacemap/SpaceMap.h Outdated Show resolved Hide resolved
dbms/src/Storages/Page/V3/spacemap/SpaceMapSTDMap.h Outdated Show resolved Hide resolved
dbms/src/Storages/Page/V3/spacemap/SpaceMapRBTree.cpp Outdated Show resolved Hide resolved
Signed-off-by: JaySon-Huang <tshent@qq.com>
@flowbehappy
Copy link
Contributor

And I think we can also add more info to this exception below. Like read_offset.
No enough data in file /data0/db/page/log/blobfile_6, read bytes: 0 , expected bytes: 4

@JaySon-Huang
Copy link
Contributor

And I think we can also add more info to this exception below. Like read_offset. No enough data in file /data0/db/page/log/blobfile_6, read bytes: 0 , expected bytes: 4

@flowbehappy Already added and merged into master in this PR: https://github.com/pingcap/tiflash/pull/5094/files

@JaySon-Huang
Copy link
Contributor

PTAL at this jiaqizho#1
I want to merge a one line change into this PR for more friendly log searching #5134

jiaqizho and others added 3 commits June 13, 2022 15:07
Co-authored-by: JaySon <tshent@qq.com>
Make log more friendly for TiDB Cloud es log service
@ti-chi-bot ti-chi-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 13, 2022
Copy link
Contributor

@JaySon-Huang JaySon-Huang left a comment

Choose a reason for hiding this comment

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

polish some comments.

dbms/src/Storages/Page/V3/spacemap/SpaceMapSTDMap.h Outdated Show resolved Hide resolved
dbms/src/Storages/Page/V3/spacemap/SpaceMapRBTree.cpp Outdated Show resolved Hide resolved
dbms/src/Storages/Page/V3/spacemap/SpaceMap.h Outdated Show resolved Hide resolved
jiaqizho and others added 2 commits June 13, 2022 17:49
Co-authored-by: JaySon <tshent@qq.com>
Co-authored-by: JaySon <tshent@qq.com>
jiaqizho and others added 3 commits June 13, 2022 17:50
Copy link
Contributor

@JaySon-Huang JaySon-Huang 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 ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jun 14, 2022
@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 Jun 14, 2022
@jiaqizho
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

@jiaqizho: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and 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.

If you have any questions about the PR merge process, please refer to pr process.

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

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

Commit hash: fcdfb46

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jun 14, 2022
@sre-bot
Copy link
Collaborator

sre-bot commented Jun 14, 2022

Coverage for changed files

Filename                        Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
BlobStore.cpp                       584               155    73.46%          56                 2    96.43%        1206               260    78.44%         368               134    63.59%
PageDirectory.cpp                   571                77    86.51%          32                 0   100.00%        1153               155    86.56%         434                93    78.57%
spacemap/SpaceMap.h                   8                 3    62.50%           4                 1    75.00%          20                 7    65.00%           8                 2    75.00%
spacemap/SpaceMapBig.h               31                11    64.52%          11                 4    63.64%          70                43    38.57%          14                 7    50.00%
spacemap/SpaceMapRBTree.cpp         346                91    73.70%          18                 0   100.00%         572               108    81.12%         202                62    69.31%
spacemap/SpaceMapRBTree.h             2                 0   100.00%           2                 0   100.00%           5                 0   100.00%           0                 0         -
spacemap/SpaceMapSTDMap.h           161                18    88.82%          11                 0   100.00%         264                17    93.56%         102                18    82.35%
tests/gtest_free_map.cpp           2506               408    83.72%          14                 0   100.00%         298                 0   100.00%         814               407    50.00%
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                              4209               763    81.87%         148                 7    95.27%        3588               590    83.56%        1942               723    62.77%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18325      9640             47.39%    205785  96550        53.08%

full coverage report (for internal network access only)

@ti-chi-bot
Copy link
Member

@jiaqizho: 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.

@sre-bot
Copy link
Collaborator

sre-bot commented Jun 14, 2022

Coverage for changed files

Filename                        Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
BlobStore.cpp                       584               155    73.46%          56                 2    96.43%        1206               260    78.44%         368               134    63.59%
PageDirectory.cpp                   571                76    86.69%          32                 0   100.00%        1153               152    86.82%         434                92    78.80%
spacemap/SpaceMap.h                   8                 3    62.50%           4                 1    75.00%          20                 7    65.00%           8                 2    75.00%
spacemap/SpaceMapBig.h               31                11    64.52%          11                 4    63.64%          70                43    38.57%          14                 7    50.00%
spacemap/SpaceMapRBTree.cpp         346                91    73.70%          18                 0   100.00%         572               108    81.12%         202                62    69.31%
spacemap/SpaceMapRBTree.h             2                 0   100.00%           2                 0   100.00%           5                 0   100.00%           0                 0         -
spacemap/SpaceMapSTDMap.h           161                18    88.82%          11                 0   100.00%         264                17    93.56%         102                18    82.35%
tests/gtest_free_map.cpp           2506               408    83.72%          14                 0   100.00%         298                 0   100.00%         814               407    50.00%
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                              4209               762    81.90%         148                 7    95.27%        3588               587    83.64%        1942               722    62.82%

Coverage summary

Functions  MissedFunctions  Executed  Lines   MissedLines  Cover
18324      9637             47.41%    205772  96537        53.09%

full coverage report (for internal network access only)

@ti-chi-bot ti-chi-bot merged commit 94aa029 into pingcap:master Jun 14, 2022
ti-chi-bot pushed a commit to ti-chi-bot/tiflash that referenced this pull request Jun 14, 2022
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #5147.

ti-chi-bot added a commit that referenced this pull request Aug 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 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.

Make the log more friendly for TiDB Cloud log service No enough data in blob file
5 participants