mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
Merge pull request #41510 from kssenii/maybe-fix-storage-nats-tests
Try fix flaky test_storage_nats
This commit is contained in:
commit
fb93ca7ca8
@ -24,7 +24,8 @@ class ASTStorage;
|
|||||||
M(Milliseconds, nats_flush_interval_ms, 0, "Timeout for flushing data from NATS.", 0) \
|
M(Milliseconds, nats_flush_interval_ms, 0, "Timeout for flushing data from NATS.", 0) \
|
||||||
M(String, nats_username, "", "NATS username", 0) \
|
M(String, nats_username, "", "NATS username", 0) \
|
||||||
M(String, nats_password, "", "NATS password", 0) \
|
M(String, nats_password, "", "NATS password", 0) \
|
||||||
M(String, nats_token, "", "NATS token", 0)
|
M(String, nats_token, "", "NATS token", 0) \
|
||||||
|
M(UInt64, nats_startup_connect_tries, 5, "Number of connect tries at startup", 0) \
|
||||||
|
|
||||||
#define LIST_OF_NATS_SETTINGS(M) \
|
#define LIST_OF_NATS_SETTINGS(M) \
|
||||||
NATS_RELATED_SETTINGS(M) \
|
NATS_RELATED_SETTINGS(M) \
|
||||||
|
@ -92,10 +92,24 @@ StorageNATS::StorageNATS(
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
connection = std::make_shared<NATSConnectionManager>(configuration, log);
|
size_t num_tries = nats_settings->nats_startup_connect_tries;
|
||||||
if (!connection->connect())
|
for (size_t i = 0; i < num_tries; ++i)
|
||||||
throw Exception(ErrorCodes::CANNOT_CONNECT_NATS, "Cannot connect to {}. Nats last error: {}",
|
{
|
||||||
connection->connectionInfoForLog(), nats_GetLastError(nullptr));
|
connection = std::make_shared<NATSConnectionManager>(configuration, log);
|
||||||
|
|
||||||
|
if (connection->connect())
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (i == num_tries - 1)
|
||||||
|
{
|
||||||
|
throw Exception(
|
||||||
|
ErrorCodes::CANNOT_CONNECT_NATS,
|
||||||
|
"Cannot connect to {}. Nats last error: {}",
|
||||||
|
connection->connectionInfoForLog(), nats_GetLastError(nullptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_DEBUG(log, "Connect attempt #{} failed, error: {}. Reconnecting...", i + 1, nats_GetLastError(nullptr));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user