Add warning about too long TQueue clear.

This commit is contained in:
levlam 2022-11-21 12:20:48 +03:00
parent 19e080d3d2
commit 2849a0857b
1 changed files with 10 additions and 1 deletions

View File

@ -228,13 +228,22 @@ class TQueueImpl final : public TQueue {
return;
}
auto start_time = Time::now();
auto total_event_length = q.total_event_length;
auto end_it = q.events.end();
while (keep_count-- > 0) {
for (size_t i = 0; i < keep_count; i++) {
--end_it;
}
for (auto it = q.events.begin(); it != end_it;) {
pop(q, queue_id, it, q.tail_id);
}
auto clear_time = Time::now() - start_time;
if (clear_time > 0.1) {
LOG(WARNING) << "Cleared " << (size - keep_count) << " TQueue events with total size "
<< (total_event_length - q.total_event_length) << " in " << time << " seconds";
}
}
Result<size_t> get(QueueId queue_id, EventId from_id, bool forget_previous, int32 unix_time_now,