Merge pull request #19206 from azat/dist-pull

Tiny changes in DistributedBlockOutputStream
This commit is contained in:
alexey-milovidov 2021-01-18 01:04:50 +03:00 committed by GitHub
commit 1444ccb85e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -145,6 +145,7 @@ void DistributedBlockOutputStream::writeAsync(const Block & block)
if (random_shard_insert)
{
writeAsyncImpl(block, storage.getRandomShardIndex(cluster->getShardsInfo()));
++inserted_blocks;
}
else
{
@ -352,7 +353,12 @@ DistributedBlockOutputStream::runWritingJob(DistributedBlockOutputStream::JobRep
/// Forward user settings
job.local_context = std::make_unique<Context>(context);
/// InterpreterInsertQuery is modifying the AST, but the same AST is also used to insert to remote shards.
/// Copying of the query AST is required to avoid race,
/// in case of INSERT into multiple local shards.
///
/// Since INSERT into local node uses AST,
/// and InterpreterInsertQuery::execute() is modifying it,
/// to resolve tables (in InterpreterInsertQuery::getTable())
auto copy_query_ast = query_ast->clone();
InterpreterInsertQuery interp(copy_query_ast, *job.local_context);
@ -608,7 +614,7 @@ void DistributedBlockOutputStream::writeToShard(const Block & block, const std::
/// tmp directory is used to ensure atomicity of transactions
/// and keep monitor thread out from reading incomplete data
std::string first_file_tmp_path{};
std::string first_file_tmp_path;
auto reservation = storage.getStoragePolicy()->reserveAndCheck(block.bytes());
const auto disk = reservation->getDisk();
@ -649,6 +655,8 @@ void DistributedBlockOutputStream::writeToShard(const Block & block, const std::
NativeBlockOutputStream stream{compress, DBMS_TCP_PROTOCOL_VERSION, block.cloneEmpty()};
/// Prepare the header.
/// See also readDistributedHeader() in DirectoryMonitor (for reading side)
///
/// We wrap the header into a string for compatibility with older versions:
/// a shard will able to read the header partly and ignore other parts based on its version.
WriteBufferFromOwnString header_buf;