Fix local break on timeout

This commit is contained in:
kssenii 2021-10-16 19:48:51 +00:00
parent de36038733
commit 4390dde76c
4 changed files with 14 additions and 1 deletions

View File

@ -517,6 +517,7 @@ void ClientBase::receiveResult(ASTPtr parsed_query)
const size_t poll_interval
= std::max(min_poll_interval, std::min<size_t>(receive_timeout.totalMicroseconds(), default_poll_interval));
bool break_on_timeout = connection->getConnectionType() != IServerConnection::Type::LOCAL;
while (true)
{
Stopwatch receive_watch(CLOCK_MONOTONIC_COARSE);
@ -547,7 +548,7 @@ void ClientBase::receiveResult(ASTPtr parsed_query)
else
{
double elapsed = receive_watch.elapsedSeconds();
if (elapsed > receive_timeout.totalSeconds())
if (break_on_timeout && elapsed > receive_timeout.totalSeconds())
{
std::cout << "Timeout exceeded while receiving data from server."
<< " Waited for " << static_cast<size_t>(elapsed) << " seconds,"

View File

@ -60,6 +60,8 @@ public:
~Connection() override;
IServerConnection::Type getConnectionType() const override { return IServerConnection::Type::SERVER; }
static ServerConnectionPtr createConnection(const ConnectionParameters & parameters, ContextPtr context);
/// Set throttler of network traffic. One throttler could be used for multiple connections to limit total traffic.

View File

@ -56,6 +56,14 @@ class IServerConnection : boost::noncopyable
public:
virtual ~IServerConnection() = default;
enum class Type
{
SERVER,
LOCAL
};
virtual Type getConnectionType() const = 0;
virtual void setDefaultDatabase(const String & database) = 0;
virtual void getServerVersion(

View File

@ -56,6 +56,8 @@ public:
~LocalConnection() override;
IServerConnection::Type getConnectionType() const override { return IServerConnection::Type::LOCAL; }
static ServerConnectionPtr createConnection(const ConnectionParameters & connection_parameters, ContextPtr current_context, bool send_progress = false);
void setDefaultDatabase(const String & database) override;