deardeng commented on code in PR #67464:
URL: https://github.com/apache/doris/pull/67464#discussion_r3923671736


##########
be/src/io/cache/peer_file_cache_reader.cpp:
##########
@@ -45,6 +50,49 @@ namespace doris::io {
 
 namespace {
 
+struct PeerConnectionHealth {
+    int32_t consecutive_failures = 0;
+    std::chrono::steady_clock::time_point circuit_open_until;
+    bool probe_in_flight = false;
+};
+
+// Entries are removed after a successful connection. Add expiry cleanup if 
permanently
+// unavailable peer addresses accumulate.
+bthread::Mutex peer_connection_health_mutex;
+std::unordered_map<std::string, PeerConnectionHealth> peer_connection_health;
+
+bool peer_connection_circuit_allows(const std::string& address) {
+    std::unique_lock<bthread::Mutex> lock(peer_connection_health_mutex);
+    auto it = peer_connection_health.find(address);
+    if (it == peer_connection_health.end() ||
+        it->second.circuit_open_until == std::chrono::steady_clock::time_point 
{}) {
+        return true;
+    }
+    auto& health = it->second;
+    if (std::chrono::steady_clock::now() < health.circuit_open_until || 
health.probe_in_flight) {
+        return false;
+    }
+    health.probe_in_flight = true;
+    return true;
+}
+
+void record_peer_connection_failure(const std::string& address) {
+    std::unique_lock<bthread::Mutex> lock(peer_connection_health_mutex);
+    auto& health = peer_connection_health[address];
+    health.probe_in_flight = false;
+    ++health.consecutive_failures;
+    if (health.consecutive_failures >= std::max(1, 
config::cache_peer_read_failure_threshold)) {
+        health.circuit_open_until =

Review Comment:
   This is intentional. The updated threshold applies to the existing 
consecutive failure count, so raising it from 3 to 10 allows further attempts 
until the count reaches 10. probe_in_flight still prevents concurrent probes, 
and mutable configuration changes are not expected to retroactively rewrite an 
existing circuit deadline.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to