Skip to content

Commit b8ee2ea

Browse files
committed
Pass max_ignored_errors/fallback_to_stale_replicas to PoolWithFailoverBase::get() too
1 parent de011a6 commit b8ee2ea

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

src/Client/ConnectionPoolWithFailover.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ IConnectionPool::Entry ConnectionPoolWithFailover::get(const ConnectionTimeouts
8484
break;
8585
}
8686

87-
return Base::get(try_get_entry, get_priority);
87+
UInt64 max_ignored_errors = settings ? settings->distributed_replica_max_ignored_errors.value : 0;
88+
bool fallback_to_stale_replicas = settings ? settings->fallback_to_stale_replicas_for_distributed_queries.value : true;
89+
90+
return Base::get(max_ignored_errors, fallback_to_stale_replicas, try_get_entry, get_priority);
8891
}
8992

9093
ConnectionPoolWithFailover::Status ConnectionPoolWithFailover::getStatus() const
@@ -206,8 +209,8 @@ std::vector<ConnectionPoolWithFailover::TryResult> ConnectionPoolWithFailover::g
206209
break;
207210
}
208211

209-
bool fallback_to_stale_replicas = settings ? settings->fallback_to_stale_replicas_for_distributed_queries.value : true;
210212
UInt64 max_ignored_errors = settings ? settings->distributed_replica_max_ignored_errors.value : 0;
213+
bool fallback_to_stale_replicas = settings ? settings->fallback_to_stale_replicas_for_distributed_queries.value : true;
211214

212215
return Base::getMany(min_entries, max_entries, max_tries,
213216
max_ignored_errors, fallback_to_stale_replicas,

src/Common/PoolWithFailoverBase.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ class PoolWithFailoverBase : private boost::noncopyable
117117
using PoolStates = std::vector<PoolState>;
118118

119119
/// Returns a single connection.
120-
Entry get(const TryGetEntryFunc & try_get_entry, const GetPriorityFunc & get_priority = GetPriorityFunc());
120+
Entry get(size_t max_ignored_errors, bool fallback_to_stale_replicas,
121+
const TryGetEntryFunc & try_get_entry, const GetPriorityFunc & get_priority = GetPriorityFunc());
121122

122123
/// This function returns a copy of pool states to avoid race conditions when modifying shared pool states.
123124
PoolStates updatePoolStates(size_t max_ignored_errors);
@@ -138,9 +139,13 @@ class PoolWithFailoverBase : private boost::noncopyable
138139

139140
template <typename TNestedPool>
140141
typename TNestedPool::Entry
141-
PoolWithFailoverBase<TNestedPool>::get(const TryGetEntryFunc & try_get_entry, const GetPriorityFunc & get_priority)
142+
PoolWithFailoverBase<TNestedPool>::get(size_t max_ignored_errors, bool fallback_to_stale_replicas,
143+
const TryGetEntryFunc & try_get_entry, const GetPriorityFunc & get_priority)
142144
{
143-
std::vector<TryResult> results = getMany(1, 1, 1, 0, true, try_get_entry, get_priority);
145+
std::vector<TryResult> results = getMany(
146+
1 /* min entries */, 1 /* max entries */, 1 /* max tries */,
147+
max_ignored_errors, fallback_to_stale_replicas,
148+
try_get_entry, get_priority);
144149
if (results.empty() || results[0].entry.isNull())
145150
throw DB::Exception(
146151
"PoolWithFailoverBase::getMany() returned less than min_entries entries.",

0 commit comments

Comments
 (0)