Skip to content

Commit

Permalink
improve log message
Browse files Browse the repository at this point in the history
  • Loading branch information
lidezhu committed Feb 7, 2022
1 parent 040bd08 commit dbe1fb5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
7 changes: 5 additions & 2 deletions dbms/src/DataStreams/ConcatBlockInputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ class ConcatBlockInputStream : public IProfilingBlockInputStream
{
public:
ConcatBlockInputStream(BlockInputStreams inputs_, const LogWithPrefixPtr & log_)
: log(getMPPTaskLog(log_, "Concat"))
: log(getMPPTaskLog(log_, getNameImpl()))
{
children.insert(children.end(), inputs_.begin(), inputs_.end());
current_stream = children.begin();
}

String getName() const override { return "Concat"; }
String getName() const override { return getNameImpl(); }

// Add this function because static analysis forbids calling virtual function in constructor
inline String getNameImpl() const { return "Concat"; }

Block getHeader() const override { return children.at(0)->getHeader(); }

Expand Down
6 changes: 4 additions & 2 deletions dbms/src/Storages/DeltaMerge/DMSegmentThreadInputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ class DMSegmentThreadInputStream : public IProfilingBlockInputStream
, expected_block_size(expected_block_size_)
, is_raw(is_raw_)
, do_range_filter_for_raw(do_range_filter_for_raw_)
, log(getMPPTaskLog(log_, "DeltaMergeSegmentThread"))
, log(getMPPTaskLog(log_, getNameImpl()))
{
}

String getName() const override { return "DeltaMergeSegmentThread"; }
String getName() const override { return getNameImpl(); }
// Add this function because static analysis forbids calling virtual function in constructor
inline String getNameImpl() const { return "DeltaMergeSegmentThread"; }
Block getHeader() const override { return header; }

protected:
Expand Down
10 changes: 7 additions & 3 deletions dbms/src/Storages/DeltaMerge/Delta/ColumnFilePersistedSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ void ColumnFilePersistedSet::checkColumnFiles(const ColumnFilePersistedLevels &

if (unlikely(new_rows != rows || new_deletes != deletes))
{
LOG_ERROR(log,
"Rows and deletes check failed. Current packs: " << columnFilesToString(flattenColumnFileLevels(new_column_file_levels)) << ", new packs: " << columnFilesToString(flattenColumnFileLevels(new_column_file_levels)));
LOG_FMT_ERROR(log, "{}: Rows and deletes check failed. Actual: rows[{}], deletes[{}]. Expected: rows[{}], deletes[{}]. Current column files: {}, new column files: {}.", __PRETTY_FUNCTION__, new_rows, new_deletes, rows.load(), deletes.load(), columnFilesToString(flattenColumnFileLevels(persisted_files_levels)), columnFilesToString(flattenColumnFileLevels(new_column_file_levels)));
throw Exception("Rows and deletes check failed.", ErrorCodes::LOGICAL_ERROR);
}
}
Expand Down Expand Up @@ -438,6 +437,8 @@ ColumnFileSetSnapshotPtr ColumnFilePersistedSet::createSnapshot(const DMContext

size_t total_rows = 0;
size_t total_deletes = 0;
// The read direction is from the last level to the first level,
// and in each level we read from the begin to the end.
for (auto level_it = persisted_files_levels.rbegin(); level_it != persisted_files_levels.rend(); level_it++)
{
for (const auto & file : *level_it)
Expand All @@ -458,7 +459,10 @@ ColumnFileSetSnapshotPtr ColumnFilePersistedSet::createSnapshot(const DMContext
}

if (unlikely(total_rows != rows || total_deletes != deletes))
throw Exception("Rows and deletes check failed!", ErrorCodes::LOGICAL_ERROR);
{
LOG_FMT_ERROR(log, "{}: Rows and deletes check failed. Actual: rows[{}], deletes[{}]. Expected: rows[{}], deletes[{}].", __PRETTY_FUNCTION__, total_rows, total_deletes, rows.load(), deletes.load());
throw Exception("Rows and deletes check failed.", ErrorCodes::LOGICAL_ERROR);
}

return snap;
}
Expand Down
10 changes: 8 additions & 2 deletions dbms/src/Storages/DeltaMerge/Delta/MemTableSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ ColumnFileSetSnapshotPtr MemTableSet::createSnapshot()
}

if (unlikely(total_rows != rows || total_deletes != deletes))
throw Exception("Rows and deletes check failed!", ErrorCodes::LOGICAL_ERROR);
{
LOG_FMT_ERROR(log, "{}: Rows and deletes check failed. Actual: rows[{}], deletes[{}]. Expected: rows[{}], deletes[{}].", __PRETTY_FUNCTION__, total_rows, total_deletes, rows.load(), deletes.load());
throw Exception("Rows and deletes check failed.", ErrorCodes::LOGICAL_ERROR);
}

return snap;
}
Expand Down Expand Up @@ -154,7 +157,10 @@ ColumnFileFlushTaskPtr MemTableSet::buildFlushTask(DMContext & context, size_t r
cur_deletes_offset += column_file->getDeletes();
}
if (unlikely(flush_task->getFlushRows() != rows || flush_task->getFlushDeletes() != deletes))
throw Exception("Rows and deletes check failed", ErrorCodes::LOGICAL_ERROR);
{
LOG_FMT_ERROR(log, "{}: Rows and deletes check failed. Actual: rows[{}], deletes[{}]. Expected: rows[{}], deletes[{}].", __PRETTY_FUNCTION__, flush_task->getFlushRows(), flush_task->getFlushDeletes(), rows.load(), deletes.load());
throw Exception("Rows and deletes check failed.", ErrorCodes::LOGICAL_ERROR);
}

return flush_task;
}
Expand Down

0 comments on commit dbe1fb5

Please sign in to comment.