Skip to content

Conversation

@ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #10341

What problem does this PR solve?

Issue Number: close #10340

Problem Summary:

When there are multiple NULL rows of Strings-like column or vector-like column, TiFlash may save some "empty blocks" into the DMFile. And it happen to be the "empty blocks" are stored at the end of the DMFile.

When TiFlash try to read data from disk, DMFileReader::readFromDisk will first call FramedChecksumReadBuffer::doSeek and seek to the "empty block" at the file end. The working_buffer will be release because we read to the end of the file. When TiFlash try to seek to the next "empty block", pos move forward the released working_buffer, leading to reading random data and cause random failure.

type_on_disk->deserializeBinaryBulkWithMultipleStreams( //
*mutable_col,
[&](const IDataType::SubstreamPath & substream_path) {
const auto substream_name = DMFile::getFileNameBase(cd.id, substream_path);
auto & sub_stream = column_streams.at(substream_name);
sub_stream->buf->seek(
sub_stream->getOffsetInFile(start_pack_id),
sub_stream->getOffsetInDecompressedBlock(start_pack_id));
return sub_stream->buf.get();
},
read_rows,
top_stream->avg_size_hint,
true,
{});

if (target_frame == current_frame)
{
pos = working_buffer.begin() + target_offset;
return offset;
}

What is changed and how it works?

1. In `FramedChecksumReadBuffer::doSeek`, add guard check for `working_buffer` size and `target_offset`. If the working_buffer is cleared, then re-seek the working buffer according to the offset and load data from the underlying file again.
2. In order to support the behavior above, `S3RandomAccessFile::seekImpl` support seek backward, which is implemented by reopening the file again
3. Add retry when reading from S3 meet errno=115, EINPROGRESS

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 possible read fail when column data contains lots of "NULL" values.

Lloyd-Pottiger and others added 7 commits August 20, 2025 08:04
Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
@ti-chi-bot ti-chi-bot added 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. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR. labels Aug 20, 2025
@ti-chi-bot ti-chi-bot mentioned this pull request Aug 20, 2025
12 tasks
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Aug 20, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Aug 20, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JaySon-Huang, Lloyd-Pottiger

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [JaySon-Huang,Lloyd-Pottiger]

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 20, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Aug 20, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-08-20 08:28:01.878946203 +0000 UTC m=+428489.822121719: ☑️ agreed by JaySon-Huang.
  • 2025-08-20 09:53:47.816844221 +0000 UTC m=+433635.760019757: ☑️ agreed by Lloyd-Pottiger.

@ti-chi-bot ti-chi-bot bot added cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels Aug 20, 2025
@ti-chi-bot ti-chi-bot bot merged commit 9b157de into pingcap:release-8.5 Aug 20, 2025
4 checks passed
@ti-chi-bot ti-chi-bot bot deleted the cherry-pick-10341-to-release-8.5 branch August 20, 2025 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved cherry-pick-approved Cherry pick PR approved by release team. lgtm 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. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants