MCPcopy Create free account
hub / github.com/apache/impala / GatherCatalogUpdatesThread

Method GatherCatalogUpdatesThread

be/src/catalog/catalog-server.cc:1066–1116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1064}
1065
1066[[noreturn]] void CatalogServer::GatherCatalogUpdatesThread() {
1067 // catalog_topic_mode=minimal does not require initial reset to happen ahead of catalog
1068 // update gathering because coordinator will request metadata on-demand.
1069 bool require_initial_reset = FLAGS_catalog_topic_mode != "minimal";
1070 while (true) {
1071 unique_lock<mutex> unique_lock(catalog_lock_);
1072 // Protect against spurious wake-ups by checking the value of topic_updates_ready_.
1073 // It is only safe to continue on and update the shared pending_topic_updates_
1074 // when topic_updates_ready_ is false, otherwise we may be in the middle of
1075 // processing a heartbeat.
1076 // If require_initial_reset is True, this thread need to let TriggerResetMetadata
1077 // thread to proceed first.
1078 while (topic_updates_ready_
1079 || (require_initial_reset && !triggered_pending_reset_.Load())) {
1080 if (!triggered_pending_reset_.Load()) {
1081 // Wake up TriggerResetMetadata thread.
1082 catalog_update_cv_.NotifyOne();
1083 }
1084 catalog_update_cv_.Wait(unique_lock);
1085 }
1086
1087 MonotonicStopWatch sw;
1088 sw.Start();
1089
1090 // Clear any pending topic updates. They will have been processed by the heartbeat
1091 // thread by the time we make it here.
1092 pending_topic_updates_.clear();
1093
1094 long current_catalog_version;
1095 Status status = catalog_->GetCatalogVersion(&current_catalog_version);
1096 if (!status.ok()) {
1097 LOG(ERROR) << status.GetDetail();
1098 } else if (current_catalog_version != last_sent_catalog_version_) {
1099 // If there has been a change since the last time the catalog was queried,
1100 // call into the Catalog to find out what has changed.
1101 VLOG(2) << "Catalog version changed from " << last_sent_catalog_version_ << " to "
1102 << current_catalog_version << ". Gathering catalog delta.";
1103 TGetCatalogDeltaResponse resp;
1104 status = catalog_->GetCatalogDelta(this, last_sent_catalog_version_, &resp);
1105 if (!status.ok()) {
1106 LOG(ERROR) << status.GetDetail();
1107 } else {
1108 catalog_objects_max_version_ = resp.max_catalog_version;
1109 }
1110 }
1111
1112 topic_processing_time_metric_->Update(sw.ElapsedTime() / (1000.0 * 1000.0 * 1000.0));
1113 topic_updates_ready_ = true;
1114 if (!triggered_pending_reset_.Load()) catalog_update_cv_.NotifyOne();
1115 }
1116}
1117
1118[[noreturn]] void CatalogServer::RefreshMetrics() {
1119 while (true) {

Callers

nothing calls this directly

Calls 11

NotifyOneMethod · 0.80
GetCatalogVersionMethod · 0.80
GetDetailMethod · 0.80
GetCatalogDeltaMethod · 0.80
clearMethod · 0.65
LoadMethod · 0.45
WaitMethod · 0.45
StartMethod · 0.45
okMethod · 0.45
UpdateMethod · 0.45
ElapsedTimeMethod · 0.45

Tested by

no test coverage detected