提交 3bee98c6 编写于 作者: A Azat Khuzhin

Fix lifetime_bytes/lifetime_rows for Buffer direct block write

上级 32a45d0d
......@@ -279,7 +279,7 @@ Pipes StorageBuffer::read(
}
static void appendBlock(StorageBuffer::LifeTimeWrites &writes, const Block & from, Block & to)
static void appendBlock(const Block & from, Block & to)
{
if (!to)
throw Exception("Cannot append to empty block", ErrorCodes::LOGICAL_ERROR);
......@@ -295,9 +295,6 @@ static void appendBlock(StorageBuffer::LifeTimeWrites &writes, const Block & fro
CurrentMetrics::add(CurrentMetrics::StorageBufferRows, rows);
CurrentMetrics::add(CurrentMetrics::StorageBufferBytes, bytes);
writes.rows += rows;
writes.bytes += bytes;
size_t old_rows = to.rows();
auto temporarily_disable_memory_tracker = getCurrentMemoryTrackerActionLock();
......@@ -371,6 +368,9 @@ public:
size_t bytes = block.bytes();
storage.writes.rows += rows;
storage.writes.bytes += bytes;
/// If the block already exceeds the maximum limit, then we skip the buffer.
if (rows > storage.max_thresholds.rows || bytes > storage.max_thresholds.bytes)
{
......@@ -449,7 +449,7 @@ private:
if (!buffer.first_write_time)
buffer.first_write_time = current_time;
appendBlock(storage.writes, sorted_block, buffer.data);
appendBlock(sorted_block, buffer.data);
}
};
......
......@@ -51,12 +51,6 @@ public:
size_t rows; /// The number of rows in the block.
size_t bytes; /// The number of (uncompressed) bytes in the block.
};
/// Lifetime
struct LifeTimeWrites
{
std::atomic<size_t> rows = 0;
std::atomic<size_t> bytes = 0;
};
std::string getName() const override { return "Buffer"; }
......@@ -125,7 +119,12 @@ private:
StorageID destination_id;
bool allow_materialized;
LifeTimeWrites writes;
/// Lifetime
struct LifeTimeWrites
{
std::atomic<size_t> rows = 0;
std::atomic<size_t> bytes = 0;
} writes;
Poco::Logger * log;
......
......@@ -38,3 +38,4 @@ Check lifetime_bytes/lifetime_rows for Buffer
100 50
200 100
200 100
402 201
......@@ -107,5 +107,7 @@ INSERT INTO check_system_tables SELECT * FROM numbers_mt(50);
SELECT lifetime_bytes, lifetime_rows FROM system.tables WHERE name = 'check_system_tables';
OPTIMIZE TABLE check_system_tables; -- flush
SELECT lifetime_bytes, lifetime_rows FROM system.tables WHERE name = 'check_system_tables';
INSERT INTO check_system_tables SELECT * FROM numbers_mt(101); -- direct block write (due to min_rows exceeded)
SELECT lifetime_bytes, lifetime_rows FROM system.tables WHERE name = 'check_system_tables';
DROP TABLE check_system_tables;
DROP TABLE check_system_tables_null;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册