Merge pull request #41263 from ClickHouse/vdimir/quorum-log-msg-fix

This commit is contained in:
Vladimir C 2022-09-14 10:54:21 +02:00 committed by GitHub
commit 00d0b37cd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 4 deletions

View File

@ -203,11 +203,11 @@ void ReplicatedMergeTreeSink::consume(Chunk chunk)
} }
block_id = temp_part.part->getZeroLevelPartBlockID(block_dedup_token); block_id = temp_part.part->getZeroLevelPartBlockID(block_dedup_token);
LOG_DEBUG(log, "Wrote block with ID '{}', {} rows on {} replicas", block_id, current_block.block.rows(), replicas_num); LOG_DEBUG(log, "Wrote block with ID '{}', {} rows{}", block_id, current_block.block.rows(), quorumLogMessage(replicas_num));
} }
else else
{ {
LOG_DEBUG(log, "Wrote block with {} rows on {} replicas", current_block.block.rows(), replicas_num); LOG_DEBUG(log, "Wrote block with {} rows{}", current_block.block.rows(), quorumLogMessage(replicas_num));
} }
UInt64 elapsed_ns = watch.elapsed(); UInt64 elapsed_ns = watch.elapsed();
@ -639,7 +639,7 @@ void ReplicatedMergeTreeSink::waitForQuorum(
size_t replicas_num) const size_t replicas_num) const
{ {
/// We are waiting for quorum to be satisfied. /// We are waiting for quorum to be satisfied.
LOG_TRACE(log, "Waiting for quorum '{}' for part {} on {} replicas", quorum_path, part_name, replicas_num); LOG_TRACE(log, "Waiting for quorum '{}' for part {}{}", quorum_path, part_name, quorumLogMessage(replicas_num));
try try
{ {
@ -684,6 +684,13 @@ void ReplicatedMergeTreeSink::waitForQuorum(
LOG_TRACE(log, "Quorum '{}' for part {} satisfied", quorum_path, part_name); LOG_TRACE(log, "Quorum '{}' for part {} satisfied", quorum_path, part_name);
} }
String ReplicatedMergeTreeSink::quorumLogMessage(size_t replicas_num) const
{
if (!isQuorumEnabled())
return "";
return fmt::format(" (quorum {} of {} replicas)", getQuorumSize(replicas_num), replicas_num);
}
size_t ReplicatedMergeTreeSink::getQuorumSize(size_t replicas_num) const size_t ReplicatedMergeTreeSink::getQuorumSize(size_t replicas_num) const
{ {
if (!isQuorumEnabled()) if (!isQuorumEnabled())

View File

@ -96,6 +96,7 @@ private:
size_t getQuorumSize(size_t replicas_num) const; size_t getQuorumSize(size_t replicas_num) const;
bool isQuorumEnabled() const; bool isQuorumEnabled() const;
String quorumLogMessage(size_t replicas_num) const; /// Used in logs for debug purposes
size_t quorum_timeout_ms; size_t quorum_timeout_ms;
size_t max_parts_per_block; size_t max_parts_per_block;

View File

@ -3649,7 +3649,7 @@ void StorageReplicatedMergeTree::updateQuorum(const String & part_name, bool is_
if (quorum_entry.replicas.size() >= quorum_entry.required_number_of_replicas) if (quorum_entry.replicas.size() >= quorum_entry.required_number_of_replicas)
{ {
/// The quorum is reached. Delete the node, and update information about the last part that was successfully written with quorum. /// The quorum is reached. Delete the node, and update information about the last part that was successfully written with quorum.
LOG_TRACE(log, "Got {} (of {}) replicas confirmed quorum {}, going to remove node", LOG_TRACE(log, "Got {} (of {} required) replicas confirmed quorum {}, going to remove node",
quorum_entry.replicas.size(), quorum_entry.required_number_of_replicas, quorum_status_path); quorum_entry.replicas.size(), quorum_entry.required_number_of_replicas, quorum_status_path);
Coordination::Requests ops; Coordination::Requests ops;