| 3044 | } |
| 3045 | |
| 3046 | std::optional<trace::TraceConfig> Task::maybeMakeTraceConfig() const { |
| 3047 | const auto& queryConfig = queryCtx_->queryConfig(); |
| 3048 | if (!queryConfig.queryTraceEnabled()) { |
| 3049 | return std::nullopt; |
| 3050 | } |
| 3051 | |
| 3052 | BOLT_USER_CHECK( |
| 3053 | !queryConfig.queryTraceDir().empty(), |
| 3054 | "Query trace enabled but the trace dir is not set"); |
| 3055 | |
| 3056 | BOLT_USER_CHECK( |
| 3057 | !queryConfig.queryTraceTaskRegExp().empty(), |
| 3058 | "Query trace enabled but the trace task regexp is not set"); |
| 3059 | |
| 3060 | if (!RE2::FullMatch(taskId_, queryConfig.queryTraceTaskRegExp())) { |
| 3061 | return std::nullopt; |
| 3062 | } |
| 3063 | |
| 3064 | const auto traceNodes = queryConfig.queryTraceNodeIds(); |
| 3065 | BOLT_USER_CHECK(!traceNodes.empty(), "Query trace nodes are not set"); |
| 3066 | |
| 3067 | const auto traceDir = trace::getTaskTraceDirectory( |
| 3068 | queryConfig.queryTraceDir(), queryCtx_->queryId(), taskId_); |
| 3069 | |
| 3070 | std::vector<std::string> traceNodeIds; |
| 3071 | folly::split(',', traceNodes, traceNodeIds); |
| 3072 | std::unordered_set<std::string> traceNodeIdSet( |
| 3073 | traceNodeIds.begin(), traceNodeIds.end()); |
| 3074 | BOLT_USER_CHECK_EQ( |
| 3075 | traceNodeIdSet.size(), |
| 3076 | traceNodeIds.size(), |
| 3077 | "Duplicate trace nodes found: {}", |
| 3078 | folly::join(", ", traceNodeIds)); |
| 3079 | |
| 3080 | bool foundTraceNode{false}; |
| 3081 | for (const auto& traceNodeId : traceNodeIds) { |
| 3082 | if (core::PlanNode::findFirstNode( |
| 3083 | planFragment_.planNode.get(), |
| 3084 | [traceNodeId](const core::PlanNode* node) -> bool { |
| 3085 | return node->id() == traceNodeId; |
| 3086 | })) { |
| 3087 | foundTraceNode = true; |
| 3088 | break; |
| 3089 | } |
| 3090 | } |
| 3091 | BOLT_USER_CHECK( |
| 3092 | foundTraceNode, |
| 3093 | "Trace plan nodes not found from task {}: {}", |
| 3094 | taskId_, |
| 3095 | folly::join(",", traceNodeIdSet)); |
| 3096 | |
| 3097 | LOG(INFO) << "Trace input for plan nodes " << traceNodes << " from task " |
| 3098 | << taskId_; |
| 3099 | |
| 3100 | trace::UpdateAndCheckTraceLimitCB updateAndCheckTraceLimitCB = |
| 3101 | [this](uint64_t bytes) { |
| 3102 | queryCtx_->updateTracedBytesAndCheckLimit(bytes); |
| 3103 | }; |
nothing calls this directly
no test coverage detected