mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-21 09:10:48 +00:00
Merge pull request #26953 from ClickHouse/fix-race-in-connections-collector
Hold context in HedgedConnections to prevent use-after-free on settings.
This commit is contained in:
commit
407f53b476
@ -3,6 +3,7 @@
|
|||||||
#include <Client/HedgedConnections.h>
|
#include <Client/HedgedConnections.h>
|
||||||
#include <Common/ProfileEvents.h>
|
#include <Common/ProfileEvents.h>
|
||||||
#include <Interpreters/ClientInfo.h>
|
#include <Interpreters/ClientInfo.h>
|
||||||
|
#include <Interpreters/Context.h>
|
||||||
|
|
||||||
namespace ProfileEvents
|
namespace ProfileEvents
|
||||||
{
|
{
|
||||||
@ -21,13 +22,14 @@ namespace ErrorCodes
|
|||||||
|
|
||||||
HedgedConnections::HedgedConnections(
|
HedgedConnections::HedgedConnections(
|
||||||
const ConnectionPoolWithFailoverPtr & pool_,
|
const ConnectionPoolWithFailoverPtr & pool_,
|
||||||
const Settings & settings_,
|
ContextPtr context_,
|
||||||
const ConnectionTimeouts & timeouts_,
|
const ConnectionTimeouts & timeouts_,
|
||||||
const ThrottlerPtr & throttler_,
|
const ThrottlerPtr & throttler_,
|
||||||
PoolMode pool_mode,
|
PoolMode pool_mode,
|
||||||
std::shared_ptr<QualifiedTableName> table_to_check_)
|
std::shared_ptr<QualifiedTableName> table_to_check_)
|
||||||
: hedged_connections_factory(pool_, &settings_, timeouts_, table_to_check_)
|
: hedged_connections_factory(pool_, &context_->getSettingsRef(), timeouts_, table_to_check_)
|
||||||
, settings(settings_)
|
, context(std::move(context_))
|
||||||
|
, settings(context->getSettingsRef())
|
||||||
, drain_timeout(settings.drain_timeout)
|
, drain_timeout(settings.drain_timeout)
|
||||||
, allow_changing_replica_until_first_data_packet(settings.allow_changing_replica_until_first_data_packet)
|
, allow_changing_replica_until_first_data_packet(settings.allow_changing_replica_until_first_data_packet)
|
||||||
, throttler(throttler_)
|
, throttler(throttler_)
|
||||||
|
@ -72,7 +72,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
HedgedConnections(const ConnectionPoolWithFailoverPtr & pool_,
|
HedgedConnections(const ConnectionPoolWithFailoverPtr & pool_,
|
||||||
const Settings & settings_,
|
ContextPtr context_,
|
||||||
const ConnectionTimeouts & timeouts_,
|
const ConnectionTimeouts & timeouts_,
|
||||||
const ThrottlerPtr & throttler,
|
const ThrottlerPtr & throttler,
|
||||||
PoolMode pool_mode,
|
PoolMode pool_mode,
|
||||||
@ -188,6 +188,7 @@ private:
|
|||||||
Packet last_received_packet;
|
Packet last_received_packet;
|
||||||
|
|
||||||
Epoll epoll;
|
Epoll epoll;
|
||||||
|
ContextPtr context;
|
||||||
const Settings & settings;
|
const Settings & settings;
|
||||||
|
|
||||||
/// The following two fields are from settings but can be referenced outside the lifetime of
|
/// The following two fields are from settings but can be referenced outside the lifetime of
|
||||||
|
@ -102,7 +102,7 @@ RemoteQueryExecutor::RemoteQueryExecutor(
|
|||||||
if (main_table)
|
if (main_table)
|
||||||
table_to_check = std::make_shared<QualifiedTableName>(main_table.getQualifiedName());
|
table_to_check = std::make_shared<QualifiedTableName>(main_table.getQualifiedName());
|
||||||
|
|
||||||
return std::make_shared<HedgedConnections>(pool, current_settings, timeouts, throttler, pool_mode, table_to_check);
|
return std::make_shared<HedgedConnections>(pool, context, timeouts, throttler, pool_mode, table_to_check);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user