Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#5006
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
mengxin9014 authored and ti-chi-bot committed Jun 20, 2022
1 parent 25545c4 commit f4c39a2
Show file tree
Hide file tree
Showing 43 changed files with 676 additions and 861 deletions.
8 changes: 0 additions & 8 deletions dbms/src/Client/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@
#include <Poco/Net/SecureStreamSocket.h>
#endif


namespace CurrentMetrics
{
extern const Metric SendExternalTables;
}

namespace DB
{
namespace ErrorCodes
Expand Down Expand Up @@ -434,8 +428,6 @@ void Connection::sendExternalTablesData(ExternalTablesData & data)
size_t maybe_compressed_out_bytes = maybe_compressed_out ? maybe_compressed_out->count() : 0;
size_t rows = 0;

CurrentMetrics::Increment metric_increment{CurrentMetrics::SendExternalTables};

for (auto & elem : data)
{
elem.first->readPrefix();
Expand Down
18 changes: 9 additions & 9 deletions dbms/src/Client/ConnectionPoolWithFailover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@
#include <Poco/Net/DNS.h>
#include <Poco/Net/NetException.h>


namespace ProfileEvents
{
extern const Event DistributedConnectionMissingTable;
extern const Event DistributedConnectionStaleReplica;
} // namespace ProfileEvents

namespace DB
{
namespace ErrorCodes
Expand All @@ -50,7 +43,7 @@ ConnectionPoolWithFailover::ConnectionPoolWithFailover(
hostname_differences.resize(nested_pools.size());
for (size_t i = 0; i < nested_pools.size(); ++i)
{
ConnectionPool & connection_pool = dynamic_cast<ConnectionPool &>(*nested_pools[i]);
auto & connection_pool = dynamic_cast<ConnectionPool &>(*nested_pools[i]);
hostname_differences[i] = getHostNameDifference(local_hostname, connection_pool.getHost());
}
}
Expand Down Expand Up @@ -187,7 +180,6 @@ ConnectionPoolWithFailover::tryGetEntry(
fail_message = "There is no table " + table_to_check->database + "." + table_to_check->table
+ " on server: " + result.entry->getDescription();
LOG_WARNING(log, fail_message);
ProfileEvents::increment(ProfileEvents::DistributedConnectionMissingTable);

return result;
}
Expand All @@ -212,10 +204,18 @@ ConnectionPoolWithFailover::tryGetEntry(

LOG_TRACE(
log,
<<<<<<< HEAD
"Server " << result.entry->getDescription() << " has unacceptable replica delay "
<< "for table " << table_to_check->database << "." << table_to_check->table
<< ": " << delay);
ProfileEvents::increment(ProfileEvents::DistributedConnectionStaleReplica);
=======
"Server {} has unacceptable replica delay for table {}.{}: {}",
result.entry->getDescription(),
table_to_check->database,
table_to_check->table,
delay);
>>>>>>> 40baecabe6 (Reduce some unnecessary prometheus metrics. (#5006))
}
}
catch (const Exception & e)
Expand Down
10 changes: 0 additions & 10 deletions dbms/src/Common/Arena.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@
#include <memory>
#include <vector>


namespace ProfileEvents
{
extern const Event ArenaAllocChunks;
extern const Event ArenaAllocBytes;
} // namespace ProfileEvents

namespace DB
{
/** Memory pool to append something. For example, short strings.
Expand All @@ -55,9 +48,6 @@ class Arena : private boost::noncopyable

Chunk(size_t size_, Chunk * prev_)
{
ProfileEvents::increment(ProfileEvents::ArenaAllocChunks);
ProfileEvents::increment(ProfileEvents::ArenaAllocBytes, size_);

begin = reinterpret_cast<char *>(Allocator::alloc(size_));
pos = begin;
end = begin + size_;
Expand Down
25 changes: 0 additions & 25 deletions dbms/src/Common/CurrentMetrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,11 @@

/// Available metrics. Add something here as you wish.
#define APPLY_FOR_METRICS(M) \
M(Query) \
M(Merge) \
M(ReplicatedFetch) \
M(ReplicatedSend) \
M(ReplicatedChecks) \
M(BackgroundPoolTask) \
M(DiskSpaceReservedForMerge) \
M(DistributedSend) \
M(QueryPreempted) \
M(TCPConnection) \
M(HTTPConnection) \
M(InterserverConnection) \
M(OpenFileForRead) \
M(OpenFileForWrite) \
M(OpenFileForReadWrite) \
M(SendExternalTables) \
M(QueryThread) \
M(ReadonlyReplica) \
M(LeaderReplica) \
M(MemoryTracking) \
M(MemoryTrackingInBackgroundProcessingPool) \
M(MemoryTrackingForMerges) \
M(LeaderElection) \
M(EphemeralNode) \
M(DelayedInserts) \
M(ContextLockWait) \
M(StorageBufferRows) \
M(StorageBufferBytes) \
M(DictCacheRequests) \
M(Revision) \
M(PSMVCCNumSnapshots) \
M(PSMVCCSnapshotsList) \
M(RWLockWaitingReaders) \
Expand Down
11 changes: 4 additions & 7 deletions dbms/src/Common/PoolWithFailoverBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ extern const int LOGICAL_ERROR;
} // namespace ErrorCodes
} // namespace DB

namespace ProfileEvents
{
extern const Event DistributedConnectionFailTry;
extern const Event DistributedConnectionFailAtAll;
} // namespace ProfileEvents

/// This class provides a pool with fault tolerance. It is used for pooling of connections to replicated DB.
/// Initialized by several PoolBase objects.
/// When a connection is requested, tries to create or choose an alive connection from one of the nested pools.
Expand Down Expand Up @@ -253,15 +247,18 @@ PoolWithFailoverBase<TNestedPool>::getMany(
}
else
{
<<<<<<< HEAD
LOG_WARNING(log, "Connection failed at try №" << (shuffled_pool.error_count + 1) << ", reason: " << fail_message);
ProfileEvents::increment(ProfileEvents::DistributedConnectionFailTry);
=======
LOG_FMT_WARNING(log, "Connection failed at try No.{}, reason: {}", shuffled_pool.error_count + 1, fail_message);
>>>>>>> 40baecabe6 (Reduce some unnecessary prometheus metrics. (#5006))

++shuffled_pool.error_count;

if (shuffled_pool.error_count >= max_tries)
{
++failed_pools_count;
ProfileEvents::increment(ProfileEvents::DistributedConnectionFailAtAll);
}
}
}
Expand Down
95 changes: 95 additions & 0 deletions dbms/src/Common/ProfileEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@


/// Available events. Add something here as you wish.
<<<<<<< HEAD
#define APPLY_FOR_EVENTS(M) \
M(Query) \
M(SelectQuery) \
Expand Down Expand Up @@ -166,6 +167,100 @@
\
M(ChecksumDigestBytes) \
\
=======
#define APPLY_FOR_EVENTS(M) \
M(Query) \
M(FileOpen) \
M(FileOpenFailed) \
M(ReadBufferFromFileDescriptorRead) \
M(ReadBufferFromFileDescriptorReadFailed) \
M(ReadBufferFromFileDescriptorReadBytes) \
M(WriteBufferFromFileDescriptorWrite) \
M(WriteBufferFromFileDescriptorWriteBytes) \
M(ReadBufferAIORead) \
M(ReadBufferAIOReadBytes) \
M(WriteBufferAIOWrite) \
M(WriteBufferAIOWriteBytes) \
\
M(UncompressedCacheHits) \
M(UncompressedCacheMisses) \
M(UncompressedCacheWeightLost) \
M(MarkCacheHits) \
M(MarkCacheMisses) \
\
M(ExternalAggregationCompressedBytes) \
M(ExternalAggregationUncompressedBytes) \
\
M(ContextLock) \
\
M(RWLockAcquiredReadLocks) \
M(RWLockAcquiredWriteLocks) \
M(RWLockReadersWaitMilliseconds) \
M(RWLockWritersWaitMilliseconds) \
\
M(PSMWritePages) \
M(PSMWriteIOCalls) \
M(PSV3MBlobExpansion) \
M(PSV3MBlobReused) \
M(PSMWriteBytes) \
M(PSMBackgroundWriteBytes) \
M(PSMReadPages) \
M(PSMBackgroundReadBytes) \
\
M(PSMReadIOCalls) \
M(PSMReadBytes) \
M(PSMWriteFailed) \
M(PSMReadFailed) \
\
M(PSMVCCApplyOnCurrentBase) \
M(PSMVCCApplyOnCurrentDelta) \
M(PSMVCCApplyOnNewDelta) \
M(PSMVCCCompactOnDelta) \
M(PSMVCCCompactOnDeltaRebaseRejected) \
M(PSMVCCCompactOnBase) \
\
M(DMWriteBytes) \
M(DMWriteBlock) \
M(DMWriteBlockNS) \
M(DMWriteFile) \
M(DMWriteFileNS) \
M(DMDeleteRange) \
M(DMDeleteRangeNS) \
M(DMAppendDeltaPrepare) \
M(DMAppendDeltaPrepareNS) \
M(DMAppendDeltaCommitMemory) \
M(DMAppendDeltaCommitMemoryNS) \
M(DMAppendDeltaCommitDisk) \
M(DMAppendDeltaCommitDiskNS) \
M(DMAppendDeltaCleanUp) \
M(DMAppendDeltaCleanUpNS) \
M(DMPlace) \
M(DMPlaceNS) \
M(DMPlaceUpsert) \
M(DMPlaceUpsertNS) \
M(DMPlaceDeleteRange) \
M(DMPlaceDeleteRangeNS) \
M(DMDeltaMerge) \
M(DMDeltaMergeNS) \
M(DMSegmentSplit) \
M(DMSegmentSplitNS) \
M(DMSegmentGetSplitPoint) \
M(DMSegmentGetSplitPointNS) \
M(DMSegmentMerge) \
M(DMSegmentMergeNS) \
M(DMFlushDeltaCache) \
M(DMFlushDeltaCacheNS) \
M(DMCleanReadRows) \
\
M(FileFSync) \
\
M(DMFileFilterNoFilter) \
M(DMFileFilterAftPKAndPackSet) \
M(DMFileFilterAftRoughSet) \
\
M(ChecksumDigestBytes) \
\
>>>>>>> 40baecabe6 (Reduce some unnecessary prometheus metrics. (#5006))
M(RaftWaitIndexTimeout)

namespace ProfileEvents
Expand Down
Loading

0 comments on commit f4c39a2

Please sign in to comment.