MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / scheduleNext

Method scheduleNext

src/Interpreters/QueryMetricLog.cpp:265–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

263}
264
265void QueryMetricLogStatus::scheduleNext(String query_id)
266{
267 info.next_collect_time += std::chrono::milliseconds(info.interval_milliseconds);
268 const auto now = std::chrono::system_clock::now();
269 if (info.next_collect_time > now)
270 {
271 const auto wait_time = std::chrono::duration_cast<std::chrono::milliseconds>(info.next_collect_time - now).count();
272 LOG_TEST(logger, "Scheduling next collecting task for query_id {} in {} ms", query_id, wait_time);
273 info.task->scheduleAfter(wait_time);
274 }
275 else
276 {
277 LOG_TEST(logger, "The next collecting task for query {} should have already run at {}. Scheduling it right now",
278 query_id, timePointToString(info.next_collect_time));
279
280 /// Skipping lost runs
281 info.next_collect_time = now;
282 info.task->schedule();
283 }
284}
285
286std::optional<QueryMetricLogElement> QueryMetricLogStatus::createLogMetricElement(
287 const String & query_id,

Callers 1

startQueryMethod · 0.80

Calls 5

timePointToStringFunction · 0.85
scheduleAfterMethod · 0.80
nowFunction · 0.50
countMethod · 0.45
scheduleMethod · 0.45

Tested by

no test coverage detected