Try to fix 30397

This commit is contained in:
Nikolai Kochetov 2021-10-22 19:25:48 +03:00
parent e00d55c08d
commit ee6bc3883f

View File

@ -446,6 +446,7 @@ static void appendBlock(const Block & from, Block & to)
if (!to)
throw Exception("Cannot append to empty block", ErrorCodes::LOGICAL_ERROR);
if (to.rows())
assertBlocksHaveEqualStructure(from, to, "Buffer");
from.checkNumberOfRows();
@ -464,6 +465,12 @@ static void appendBlock(const Block & from, Block & to)
{
MemoryTracker::BlockerInThread temporarily_disable_memory_tracker;
if (to.rows() == 0)
{
to = from;
}
else
{
for (size_t column_no = 0, columns = to.columns(); column_no < columns; ++column_no)
{
const IColumn & col_from = *from.getByPosition(column_no).column.get();
@ -474,6 +481,7 @@ static void appendBlock(const Block & from, Block & to)
to.getByPosition(column_no).column = std::move(last_col);
}
}
}
catch (...)
{
/// Rollback changes.
@ -817,6 +825,8 @@ void StorageBuffer::flushBuffer(Buffer & buffer, bool check_thresholds, bool loc
if (!locked)
lock.emplace(buffer.lockForReading());
block_to_write = buffer.data.cloneEmpty();
rows = buffer.data.rows();
bytes = buffer.data.bytes();
if (buffer.first_write_time)