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

PageStorage: Fix empty page cause TiFlash failed to start #9283

Merged
merged 7 commits into from
Aug 5, 2024

Conversation

JaySon-Huang
Copy link
Contributor

@JaySon-Huang JaySon-Huang commented Aug 2, 2024

What problem does this PR solve?

Issue Number: close #9282

Problem Summary:

By dumping the entries from PageStorage WAL, we can locate that two entries cause this issue:

[PageDirectoryFactory.cpp:225] ["{type:VAR_ENT, page_id:0x020102000000009CA4430A08, ori_id:0x.0, version:108969363.0, entry:PageEntry{file: 551, offset: 0x15376, size: 0, checksum: 0x0, tag: 0, field_offsets: [], checkpoint_info: invalid}, being_ref_count:1}"] [thread_id=1]
[PageDirectoryFactory.cpp:225] ["{type:PUT    , page_id:0x020102000000018204A17C03, ori_id:0x.0, version:127726467.0, entry:PageEntry{file: 551, offset: 0x15373, size: 15, checksum: 0x12D46C1C0D5B51FE, tag: 0, field_offsets: [], checkpoint_info: invalid}, being_ref_count:1}"] [thread_id=1]

The first entry is a page with data.size == 0, placed at blob_id=551, offset=0x15376. And later another page is placed at blob_id=551, offset=0x15373 with data.size == 15.
The first page split the free block into smaller pieces free blocks.
The second page will cover the place of the first page. And our code can not handle this situation with "empty page data".

What is changed and how it works?

  • For handling the existing empty pages, we won't let it split the free block into small pieces:
    • when STDMapSpaceMap::markUsedImpl accept a block of length == 0, it will directly return true instead of splitting the free block into smaller pieces.
  • For newly created empty pages, we store them at the front of BlobFile to avoid further issues:
    • BlobStats::BlobStat::getPosFromStat and STDMapSpaceMap::searchInsertOffset accepts a block of length == 0, it will return insert_offset == 0, which we can "store the empty pages" at the front of the BlobFile for newly created empty pages.
  • In BlobStore::read(...), we ensure that reading empty pages won't cause NPE or other unexpected exceptions
PageStorage: Fix empty page cause TiFlash failed to start

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

Fix an issue that TiFlash write node may fail to restart under disaggregated arch

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue 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. do-not-merge/needs-triage-completed and removed do-not-merge/needs-linked-issue labels Aug 2, 2024
return (offset < start) || (offset > end) || (offset + size - 1 > end);
return (offset < start)
|| (offset > end)
// check whether it can be changed to `(offset + size > end)`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We will test it later, now just keep the same behavior

@JaySon-Huang JaySon-Huang changed the title PageStorage: Fix empty page PageStorage: Fix empty page cause TiFlash failed to start Aug 2, 2024
@JaySon-Huang JaySon-Huang changed the title PageStorage: Fix empty page cause TiFlash failed to start [WIP] PageStorage: Fix empty page cause TiFlash failed to start Aug 2, 2024
@ti-chi-bot ti-chi-bot bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 2, 2024
@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 2, 2024
@JaySon-Huang JaySon-Huang changed the title [WIP] PageStorage: Fix empty page cause TiFlash failed to start PageStorage: Fix empty page cause TiFlash failed to start Aug 5, 2024
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 5, 2024
@JaySon-Huang
Copy link
Contributor Author

/retest

@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Aug 5, 2024
@purelind
Copy link
Collaborator

purelind commented Aug 5, 2024

/retest

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Aug 5, 2024
Copy link
Member

@CalvinNeo CalvinNeo left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

ti-chi-bot bot commented Aug 5, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CalvinNeo, JinheLin

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:

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 5, 2024
Copy link
Contributor

ti-chi-bot bot commented Aug 5, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-08-05 03:29:33.70887058 +0000 UTC m=+236303.575969669: ☑️ agreed by JinheLin.
  • 2024-08-05 04:01:01.964005981 +0000 UTC m=+238191.831105069: ☑️ agreed by CalvinNeo.

@ti-chi-bot ti-chi-bot bot merged commit dc20fe9 into pingcap:master Aug 5, 2024
5 checks passed
@JaySon-Huang JaySon-Huang deleted the fix_empty_page branch August 5, 2024 04:05
@ti-chi-bot ti-chi-bot added needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. labels Aug 5, 2024
ti-chi-bot pushed a commit to ti-chi-bot/tiflash that referenced this pull request Aug 5, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #9285.

ti-chi-bot pushed a commit to ti-chi-bot/tiflash that referenced this pull request Aug 5, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #9286.

ti-chi-bot bot pushed a commit that referenced this pull request Aug 5, 2024
)

close #9282

PageStorage: Fix empty page cause TiFlash failed to start

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>

Co-authored-by: JaySon <tshent@qq.com>
Co-authored-by: JaySon-Huang <tshent@qq.com>
ti-chi-bot bot pushed a commit that referenced this pull request Aug 5, 2024
)

close #9282

PageStorage: Fix empty page cause TiFlash failed to start

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>

Co-authored-by: JaySon <tshent@qq.com>
Co-authored-by: JaySon-Huang <tshent@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

TiFlash may failed to start deployed under disagg arch
5 participants