Skip to content

PageStorage: Fix invalid offset after restart#6237

Merged
ti-chi-bot merged 23 commits into
pingcap:masterfrom
JaySon-Huang:fix_ps_gc
Nov 3, 2022
Merged

PageStorage: Fix invalid offset after restart#6237
ti-chi-bot merged 23 commits into
pingcap:masterfrom
JaySon-Huang:fix_ps_gc

Conversation

@JaySon-Huang
Copy link
Copy Markdown
Contributor

@JaySon-Huang JaySon-Huang commented Nov 2, 2022

What problem does this PR solve?

Issue Number: close #6218

Problem Summary:
Introduce by #6168

The fix can not properly handle the following situation
image

What is changed and how it works?

  • Better handle WriteBatch{ put X, ref Y->X, delete X} inside one WriteBatch (PageDirectory::apply)
    • Previously, we use the same version.sequence inside one WriteBatch
    • Now we increase the version.sequence inside one WriteBatch, and atomically increase the PageDirectory.sequence at last
  • Check whether the page is deleted or not when preparing full GC
    • If the page itself is deleted (even still being ref by another id), then we won't rewrite it
    • If the page is a reference to another id, and is not deleted, we will rewrite the data with ref-id in full GC
      • If the ref-page is not deleted before full GC commits new entry, we will rewrite the ref-page into a normal page with { upsert-entry } and decrease the ref-count of origin-id
      • If the ref-page is deleted before full GC commits new entry, we will rewrite the ref-page into a normal page with { upsert-entry, delete_ver}

image

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
    Run chbenchmark with warehouse 100 and tiflash random kill. TiFlash can restart normally.
  • 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

@ti-chi-bot
Copy link
Copy Markdown
Member

ti-chi-bot commented Nov 2, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • flowbehappy
  • lidezhu

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.

Details

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 Nov 2, 2022
@JaySon-Huang
Copy link
Copy Markdown
Contributor Author

/run-all-tests

@JaySon-Huang
Copy link
Copy Markdown
Contributor Author

/run-all-tests

@JaySon-Huang
Copy link
Copy Markdown
Contributor Author

/run-all-tests

@JaySon-Huang
Copy link
Copy Markdown
Contributor Author

/cc @lidezhu @flowbehappy @hehechen

Comment thread dbms/src/Storages/Page/V3/PageDirectory.cpp
Comment thread dbms/src/Storages/Page/V3/PageDirectory.cpp
Comment thread dbms/src/Storages/Page/V3/PageDirectory.cpp
Comment thread dbms/src/Storages/Page/V3/PageDirectoryFactory.cpp
@JaySon-Huang
Copy link
Copy Markdown
Contributor Author

/run-all-tests

@JaySon-Huang
Copy link
Copy Markdown
Contributor Author

/run-all-tests

Comment thread dbms/src/Storages/Page/V3/tests/gtest_page_directory.cpp Outdated
Comment thread dbms/src/Storages/Page/V3/PageDirectory.cpp Outdated
Copy link
Copy Markdown
Contributor

@lidezhu lidezhu 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 Nov 3, 2022
JaySon-Huang and others added 2 commits November 3, 2022 14:28
Co-authored-by: lidezhu <47731263+lidezhu@users.noreply.github.com>
@JaySon-Huang
Copy link
Copy Markdown
Contributor Author

/run-all-tests

Comment thread dbms/src/Storages/Page/V3/PageDirectory.h
Comment thread dbms/src/Storages/Page/V3/PageDirectory.cpp Outdated
Comment thread dbms/src/Storages/Page/V3/PageDirectory.cpp Outdated
Comment thread dbms/src/Storages/Page/V3/PageDirectory.cpp
@flowbehappy flowbehappy self-requested a review November 3, 2022 13:58
Copy link
Copy Markdown
Contributor

@flowbehappy flowbehappy 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 status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Nov 3, 2022
@JaySon-Huang
Copy link
Copy Markdown
Contributor Author

/merge

@ti-chi-bot
Copy link
Copy Markdown
Member

@JaySon-Huang: 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.

Details

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

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

DetailsCommit hash: d1cad72

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

@JaySon-Huang: 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.

Details

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 ti-chi-bot merged commit 91fcbea into pingcap:master Nov 3, 2022
@JaySon-Huang JaySon-Huang deleted the fix_ps_gc branch November 3, 2022 14:51
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.

TiFlash can't start for the error of Can't find BlobStat

4 participants