Add some logging to StorageRabbitMQ

This commit is contained in:
kssenii 2023-09-20 15:54:11 +02:00
parent 2ba9263098
commit 3ef2c37b92
2 changed files with 68 additions and 49 deletions

View File

@ -959,11 +959,52 @@ bool StorageRabbitMQ::hasDependencies(const StorageID & table_id)
void StorageRabbitMQ::streamingToViewsFunc()
{
chassert(initialized);
if (initialized)
{
try
{
streamToViewsImpl();
}
catch (...)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
}
mv_attached.store(false);
try
{
/// If there is no running select, stop the loop which was
/// activated by previous select.
if (connection->getHandler().loopRunning())
stopLoopIfNoReaders();
}
catch (...)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
}
if (shutdown_called)
{
LOG_DEBUG(log, "Shutdown called, stopping background streaming process");
}
else
{
/// Reschedule with backoff.
if (milliseconds_to_wait < rabbitmq_settings->rabbitmq_empty_queue_backoff_end_ms)
milliseconds_to_wait += rabbitmq_settings->rabbitmq_empty_queue_backoff_step_ms;
LOG_DEBUG(log, "Rescheduling background streaming process in {}", milliseconds_to_wait);
streaming_task->scheduleAfter(milliseconds_to_wait);
}
}
void StorageRabbitMQ::streamToViewsImpl()
{
if (!initialized)
{
chassert(false);
return;
}
auto table_id = getStorageID();
// Check if at least one direct dependency is attached
@ -999,31 +1040,8 @@ void StorageRabbitMQ::streamingToViewsFunc()
milliseconds_to_wait = rabbitmq_settings->rabbitmq_empty_queue_backoff_start_ms;
}
}
}
catch (...)
{
tryLogCurrentException(__PRETTY_FUNCTION__);
}
}
mv_attached.store(false);
/// If there is no running select, stop the loop which was
/// activated by previous select.
if (connection->getHandler().loopRunning())
stopLoopIfNoReaders();
if (!shutdown_called)
{
/// Reschedule with backoff.
if (milliseconds_to_wait < rabbitmq_settings->rabbitmq_empty_queue_backoff_end_ms)
milliseconds_to_wait += rabbitmq_settings->rabbitmq_empty_queue_backoff_step_ms;
streaming_task->scheduleAfter(milliseconds_to_wait);
}
}
bool StorageRabbitMQ::tryStreamToViews()
{
auto table_id = getStorageID();

View File

@ -187,6 +187,7 @@ private:
void bindExchange(AMQP::TcpChannel & rabbit_channel);
void bindQueue(size_t queue_id, AMQP::TcpChannel & rabbit_channel);
void streamToViewsImpl();
/// Return true on successful stream attempt.
bool tryStreamToViews();
bool hasDependencies(const StorageID & table_id);