Skip to content

[Release-7.3] Cherrypick Add connection counters (#12292) #12296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion fdbrpc/FlowTransport.actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ class TransportData {
countConnEstablished.init("Net2.CountConnEstablished"_sr);
countConnClosedWithError.init("Net2.CountConnClosedWithError"_sr);
countConnClosedWithoutError.init("Net2.CountConnClosedWithoutError"_sr);
countConnIncompatible.init("Net2.CountConnIncompatible"_sr);
countConnIncompatibleWithOldClient.init("Net2.CountConnIncompatibleWithOldClient"_sr);
}

Reference<struct Peer> getPeer(NetworkAddress const& address);
Expand Down Expand Up @@ -343,6 +345,8 @@ class TransportData {
Int64MetricHandle countConnEstablished;
Int64MetricHandle countConnClosedWithError;
Int64MetricHandle countConnClosedWithoutError;
Int64MetricHandle countConnIncompatible;
Int64MetricHandle countConnIncompatibleWithOldClient;

std::map<NetworkAddress, std::pair<uint64_t, double>> incompatiblePeers;
AsyncTrigger incompatiblePeersChanged;
Expand Down Expand Up @@ -1504,11 +1508,12 @@ ACTOR static Future<Void> connectionReader(TransportData* transport,
now() + FLOW_KNOBS->CONNECTION_ID_TIMEOUT;
}
compatible = false;
transport->countConnIncompatible++;
if (!protocolVersion.hasInexpensiveMultiVersionClient()) {
if (peer) {
peer->protocolVersion->set(protocolVersion);
}

transport->countConnIncompatibleWithOldClient++;
// Older versions expected us to hang up. It may work even if we don't hang up here, but
// it's safer to keep the old behavior.
throw incompatible_protocol_version();
Expand Down
6 changes: 6 additions & 0 deletions flow/Net2.actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ class Net2 final : public INetwork, public INetworkConnections {
Int64MetricHandle countClientTLSHandshakesOnMainThread;
Int64MetricHandle countServerTLSHandshakesOnSideThreads;
Int64MetricHandle countServerTLSHandshakesOnMainThread;
Int64MetricHandle countClientTLSHandshakesTimedout;
Int64MetricHandle countServerTLSHandshakesTimedout;

EventMetricHandle<SlowTask> slowTaskMetric;

Expand Down Expand Up @@ -988,6 +990,7 @@ class SSLConnection final : public IConnection, ReferenceCounted<SSLConnection>
return Void();
}
when(wait(delay(FLOW_KNOBS->CONNECTION_MONITOR_TIMEOUT))) {
g_net2->countServerTLSHandshakesTimedout++;
throw connection_failed();
}
}
Expand Down Expand Up @@ -1063,6 +1066,7 @@ class SSLConnection final : public IConnection, ReferenceCounted<SSLConnection>
return Void();
}
when(wait(delay(FLOW_KNOBS->CONNECTION_MONITOR_TIMEOUT))) {
g_net2->countClientTLSHandshakesTimedout++;
throw connection_failed();
}
}
Expand Down Expand Up @@ -1454,6 +1458,8 @@ void Net2::initMetrics() {
countClientTLSHandshakesOnMainThread.init("Net2.CountClientTLSHandshakesOnMainThread"_sr);
countServerTLSHandshakesOnSideThreads.init("Net2.CountServerTLSHandshakesOnSideThreads"_sr);
countServerTLSHandshakesOnMainThread.init("Net2.CountServerTLSHandshakesOnMainThread"_sr);
countClientTLSHandshakesTimedout.init("Net2.CountClientTLSHandshakesTimedout"_sr);
countServerTLSHandshakesTimedout.init("Net2.CountServerTLSHandshakesTimedout"_sr);
taskQueue.initMetrics();
}

Expand Down
15 changes: 15 additions & 0 deletions flow/SystemMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,21 @@ SystemStatistics customSystemMonitor(std::string const& eventName, StatisticsSta
(netData.countServerTLSHandshakesOnMainThread -
statState->networkState.countServerTLSHandshakesOnMainThread) /
currentStats.elapsed)
.detail("ConnectionIncompatible",
(netData.countConnIncompatible - statState->networkState.countConnIncompatible) /
currentStats.elapsed)
.detail("ConnectionIncompatibleWithOldClient",
(netData.countConnIncompatibleWithOldClient -
statState->networkState.countConnIncompatibleWithOldClient) /
currentStats.elapsed)
.detail("ClientTLSHandshakesTimedout",
(netData.countClientTLSHandshakesTimedout -
statState->networkState.countClientTLSHandshakesTimedout) /
currentStats.elapsed)
.detail("ServerTLSHandshakesTimedout",
(netData.countServerTLSHandshakesTimedout -
statState->networkState.countServerTLSHandshakesTimedout) /
currentStats.elapsed)

.trackLatest(eventName);

Expand Down
11 changes: 11 additions & 0 deletions flow/include/flow/SystemMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ struct NetworkData {
int64_t countClientTLSHandshakesOnMainThread;
int64_t countServerTLSHandshakesOnSideThreads;
int64_t countServerTLSHandshakesOnMainThread;
int64_t countConnIncompatible;
int64_t countConnIncompatibleWithOldClient; // Increments when a very old client connects to fdbserver with
// incompatible protocol version error. Please check the definition of
// hasInexpensiveMultiVersionClient.
int64_t countClientTLSHandshakesTimedout;
int64_t countServerTLSHandshakesTimedout;

void init() {
bytesSent = Int64Metric::getValueOrDefault("Net2.BytesSent"_sr);
Expand Down Expand Up @@ -149,6 +155,11 @@ struct NetworkData {
Int64Metric::getValueOrDefault("Net2.CountServerTLSHandshakesOnSideThreads"_sr);
countServerTLSHandshakesOnMainThread =
Int64Metric::getValueOrDefault("Net2.CountServerTLSHandshakesOnMainThread"_sr);
countConnIncompatible = Int64Metric::getValueOrDefault("Net2.CountConnIncompatible"_sr);
countConnIncompatibleWithOldClient =
Int64Metric::getValueOrDefault("Net2.CountConnIncompatibleWithOldClient"_sr);
countClientTLSHandshakesTimedout = Int64Metric::getValueOrDefault("Net2.CountClientTLSHandshakesTimedout"_sr);
countServerTLSHandshakesTimedout = Int64Metric::getValueOrDefault("Net2.CountServerTLSHandshakesTimedout"_sr);
}
};

Expand Down