Fix error on OS X regarding resetting timeouts.

This happens when remote disconnects due to inactivity. It seems
to work on Linux, likely due to difference in SO_LINGER, maybe a
different default timeout on Darwin.

Verified manually using clickhouse cloud using following process:

1. Connect to instance.
2. Run `show tables`.
3. Wait 6 minutes.
4. Run `show tables`.

With this fix, the EINVAL is not reported, and client will simply
reconnect.
This commit is contained in:
Manas Alekar 2023-05-13 22:55:27 -07:00
parent dfbba48510
commit c87b33a24d

View File

@ -31,13 +31,15 @@ TimeoutSetter::~TimeoutSetter()
{
try
{
bool connected = socket.impl()->initialized();
if (!connected)
return;
socket.setSendTimeout(old_send_timeout);
socket.setReceiveTimeout(old_receive_timeout);
}
catch (...)
{
/// Sometimes caught on Mac OS X. This message can be safely ignored.
/// If you are developer using Mac, please debug this error message by yourself.
tryLogCurrentException("Client", "TimeoutSetter: Can't reset timeouts");
}
}