From dbab34e21fc55d249dfa6b4c16cc92a1b6892fb3 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sat, 2 Mar 2019 04:05:36 +0300 Subject: [PATCH] Fixed error #4526 --- dbms/src/Storages/MergeTree/MergeTreeReaderStream.cpp | 8 +++++--- .../MergeTree/MergeTreeSequentialBlockInputStream.cpp | 11 +++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/dbms/src/Storages/MergeTree/MergeTreeReaderStream.cpp b/dbms/src/Storages/MergeTree/MergeTreeReaderStream.cpp index c6feffc6420..9091228d80a 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeReaderStream.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeReaderStream.cpp @@ -29,6 +29,8 @@ MergeTreeReaderStream::MergeTreeReaderStream( size_t max_mark_range_bytes = 0; size_t sum_mark_range_bytes = 0; + /// Care should be taken to not load marks when the part is empty (marks_count == 0). + for (const auto & mark_range : all_mark_ranges) { size_t left_mark = mark_range.begin; @@ -54,7 +56,7 @@ MergeTreeReaderStream::MergeTreeReaderStream( || (right_mark + 1 == marks_count && getMark(right_mark).offset_in_compressed_file == getMark(mark_range.end).offset_in_compressed_file)) { - mark_range_bytes = file_size - getMark(left_mark).offset_in_compressed_file; + mark_range_bytes = file_size - (left_mark < marks_count ? getMark(left_mark).offset_in_compressed_file : 0); } else { @@ -119,8 +121,8 @@ void MergeTreeReaderStream::loadMarks() size_t expected_file_size = sizeof(MarkInCompressedFile) * marks_count; if (expected_file_size != file_size) throw Exception( - "bad size of marks file `" + mrk_path + "':" + std::to_string(file_size) + ", must be: " + std::to_string(expected_file_size), - ErrorCodes::CORRUPTED_DATA); + "Bad size of marks file '" + mrk_path + "': " + std::to_string(file_size) + ", must be: " + std::to_string(expected_file_size), + ErrorCodes::CORRUPTED_DATA); auto res = std::make_shared(marks_count); diff --git a/dbms/src/Storages/MergeTree/MergeTreeSequentialBlockInputStream.cpp b/dbms/src/Storages/MergeTree/MergeTreeSequentialBlockInputStream.cpp index aecd822bca2..2cfbe5f5539 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeSequentialBlockInputStream.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeSequentialBlockInputStream.cpp @@ -23,9 +23,16 @@ MergeTreeSequentialBlockInputStream::MergeTreeSequentialBlockInputStream( , mark_cache(storage.global_context.getMarkCache()) { if (!quiet) - LOG_TRACE(log, "Reading " << data_part->marks_count << " marks from part " << data_part->name + { + std::stringstream message; + message << "Reading " << data_part->marks_count << " marks from part " << data_part->name << ", totaly " << data_part->rows_count - << " rows starting from the beginning of the part"); + << " rows starting from the beginning of the part, columns: "; + for (size_t i = 0, size = columns_to_read.size(); i < size; ++i) + message << (i == 0 ? "" : ", ") << columns_to_read[i]; + + LOG_TRACE(log, message.rdbuf()); + } addTotalRowsApprox(data_part->rows_count);