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 large write cause tiflash crash (release-6.5) #7345

Merged
merged 3 commits into from
Apr 24, 2023

Conversation

JaySon-Huang
Copy link
Contributor

Manual cherry-pick of #7335


What problem does this PR solve?

Issue Number: close #7316

Problem Summary:

The root cause is BlobStore<Trait>::handleLargeWrite get a buffer from MemoryWriteBuffer and access the memory by write.size, which exceed the memory bound. MemoryWriteBuffer actually is composed by a list of chunks

BufferBase::Buffer data_buf = write.read_buffer->buffer();
digest.update(data_buf.begin(), write.size);
entry.checksum = digest.checksum();
UInt64 field_begin, field_end;
for (size_t i = 0; i < write.offsets.size(); ++i)
{
ChecksumClass field_digest;
field_begin = write.offsets[i].first;
field_end = (i == write.offsets.size() - 1) ? write.size : write.offsets[i + 1].first;
field_digest.update(data_buf.begin() + field_begin, field_end - field_begin);
write.offsets[i].second = field_digest.checksum();
}
if (!write.offsets.empty())
{
// we can swap from WriteBatch instead of copying
entry.field_offsets.swap(write.offsets);
}
try
{
auto blob_file = getBlobFile(blob_id);
blob_file->write(data_buf.begin(), offset_in_file, write.size, write_limiter);

What is changed and how it works?

The write batch data size is large, we do NOT copy the data into a temporary buffer in order to make the memory usage of tiflash more smooth. Instead, we process the data in ReadBuffer in a streaming manner.

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 a crash issue when tiflash persists the data of a large Region

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Apr 23, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • Lloyd-Pottiger
  • 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.

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 bot added do-not-merge/cherry-pick-not-approved release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Apr 23, 2023
@JaySon-Huang JaySon-Huang changed the title Fix large write cause tiflash crash (release-6.5) (#7335) Fix large write cause tiflash crash (release-6.5) Apr 23, 2023
@JaySon-Huang
Copy link
Contributor Author

/run-all-tests

@JaySon-Huang
Copy link
Contributor Author

/run-all-tests

@JaySon-Huang
Copy link
Contributor Author

/run-all-tests

@Lloyd-Pottiger
Copy link
Contributor

/run-integration-test

@ti-chi-bot ti-chi-bot bot added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 24, 2023
@VelocityLight VelocityLight added cherry-pick-approved Cherry pick PR approved by release team. do-not-merge/cherry-pick-not-approved and removed do-not-merge/cherry-pick-not-approved cherry-pick-approved Cherry pick PR approved by release team. labels Apr 24, 2023
@JaySon-Huang
Copy link
Contributor Author

/run-all-tests

@VelocityLight VelocityLight added cherry-pick-approved Cherry pick PR approved by release team. do-not-merge/cherry-pick-not-approved and removed do-not-merge/cherry-pick-not-approved cherry-pick-approved Cherry pick PR approved by release team. labels Apr 24, 2023
@JaySon-Huang JaySon-Huang mentioned this pull request Apr 24, 2023
12 tasks
@VelocityLight VelocityLight added cherry-pick-approved Cherry pick PR approved by release team. do-not-merge/cherry-pick-not-approved and removed do-not-merge/cherry-pick-not-approved cherry-pick-approved Cherry pick PR approved by release team. labels Apr 24, 2023
@ti-chi-bot ti-chi-bot bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Apr 24, 2023
@JaySon-Huang
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Apr 24, 2023

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

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
Contributor

ti-chi-bot bot commented Apr 24, 2023

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

Commit hash: 61cec2d

@ti-chi-bot ti-chi-bot bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 24, 2023
@ti-chi-bot ti-chi-bot bot merged commit 7a8bd1d into pingcap:release-6.5 Apr 24, 2023
@JaySon-Huang JaySon-Huang deleted the fix_large_write_6.5 branch April 24, 2023 07:28
@JaySon-Huang
Copy link
Contributor Author

/cherry-pick release-6.5-20230425-v6.5.2

@ti-chi-bot
Copy link
Member

@JaySon-Huang: new pull request created to branch release-6.5-20230425-v6.5.2: #7377.

In response to this:

/cherry-pick release-6.5-20230425-v6.5.2

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 removed the cherry-pick-approved Cherry pick PR approved by release team. label Jun 14, 2023
@ti-chi-bot ti-chi-bot added the cherry-pick-approved Cherry pick PR approved by release team. label Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick-approved Cherry pick PR approved by release team. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

5 participants