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

Method ArchiveQuery

be/src/service/impala-server.cc:1203–1268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1201}
1202
1203void ImpalaServer::ArchiveQuery(const QueryHandle& query_handle) {
1204 vector<uint8_t> compressed_profile;
1205 Status status = query_handle->profile()->Compress(&compressed_profile);
1206 if (!status.ok()) {
1207 // Didn't serialize the string. Continue with empty string.
1208 LOG_EVERY_N(WARNING, 1000) << "Could not serialize profile to archive string "
1209 << status.GetDetail();
1210 return;
1211 }
1212
1213 // If there was an error initialising archival (e.g. directory is not writeable),
1214 // FLAGS_log_query_to_file will have been set to false
1215 if (FLAGS_log_query_to_file) {
1216 stringstream ss;
1217 ss << UnixMillis() << " " << PrintId(query_handle->query_id()) << " ";
1218 Base64Encode(compressed_profile, &ss);
1219 status = profile_logger_->AppendEntry(ss.str());
1220 if (!status.ok()) {
1221 LOG_EVERY_N(WARNING, 1000) << "Could not write to profile log file file ("
1222 << google::COUNTER << " attempts failed): "
1223 << status.GetDetail();
1224 LOG_EVERY_N(WARNING, 1000)
1225 << "Disable query logging with --log_query_to_file=false";
1226 }
1227 }
1228
1229 // 'fetch_rows_lock()' protects several fields in ClientRequestState that are read
1230 // during QueryStateRecord creation. There should be no contention on this lock because
1231 // the query has already been closed (e.g. no more results can be fetched).
1232 shared_ptr<QueryStateRecord> record = nullptr;
1233 {
1234 lock_guard<mutex> l(*query_handle->fetch_rows_lock());
1235 record = make_shared<QueryStateRecord>(*query_handle, move(compressed_profile));
1236 }
1237 if (query_handle->GetCoordinator() != nullptr) {
1238 query_handle->GetCoordinator()->GetTExecSummary(&record->exec_summary);
1239 }
1240
1241 EnqueueCompletedQuery(query_handle, record);
1242
1243 if (FLAGS_query_log_size != 0 && FLAGS_query_log_size_in_bytes != 0) {
1244 int64_t record_size = EstimateSize(record.get());
1245 VLOG(3) << "QueryStateRecord of " << PrintId(query_handle->query_id()) << " is "
1246 << record_size << " bytes";
1247
1248 lock_guard<mutex> l(query_log_lock_);
1249 // Add record to the beginning of the log, and to the lookup index.
1250 ImpaladMetrics::QUERY_LOG_EST_TOTAL_BYTES->Increment(record_size);
1251 query_log_est_sizes_.push_front(record_size);
1252 query_log_.push_front(move(record));
1253 query_log_index_[query_handle->query_id()] = &query_log_.front();
1254
1255 while (!query_log_.empty()
1256 && ((FLAGS_query_log_size > -1 && FLAGS_query_log_size < query_log_.size())
1257 || (FLAGS_query_log_size_in_bytes > -1
1258 && FLAGS_query_log_size_in_bytes
1259 < ImpaladMetrics::QUERY_LOG_EST_TOTAL_BYTES->GetValue()))) {
1260 query_log_index_.erase(query_log_.back()->id);

Callers

nothing calls this directly

Calls 15

UnixMillisFunction · 0.85
PrintIdFunction · 0.85
moveFunction · 0.85
EstimateSizeFunction · 0.85
GetDetailMethod · 0.80
AppendEntryMethod · 0.80
fetch_rows_lockMethod · 0.80
GetCoordinatorMethod · 0.80
GetTExecSummaryMethod · 0.80
frontMethod · 0.80
eraseMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected