{"record":{"id":"633154c7d5fa451e","repo":"dgraph-io/dgraph","slug":"query-couldn-t-be-executed","errorCode":null,"errorMessage":"Query couldn't be executed","messagePattern":"Query couldn't be executed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"query/query.go","lineNumber":3025,"sourceCode":"\t\t\t\t\tstart, end := x.PageRange(sg.Params.Cascade.First,\n\t\t\t\t\t\tsg.Params.Cascade.Offset, len(sg.uidMatrix[i].Uids))\n\t\t\t\t\tsg.uidMatrix[i].Uids = sg.uidMatrix[i].Uids[start:end]\n\t\t\t\t}\n\t\t\t}\n\t\t\tspana.End()\n\n\t\t\t_, spanp := otel.Tracer(\"\").Start(ctx, \"Populate Post Aggregation Var Map \"+sg.Attr)\n\t\t\tif err := sg.populatePostAggregation(req.Vars, []*SubGraph{}, nil); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tspanp.End()\n\t\t}\n\t}\n\n\t// Ensure all the queries are executed.\n\tfor _, it := range hasExecuted {\n\t\tif !it {\n\t\t\treturn errors.Errorf(\"Query couldn't be executed\")\n\t\t}\n\t}\n\treq.Latency.Processing += time.Since(execStart)\n\n\t// If we had a shortestPath SG, append it to the result.\n\tif len(shortestSg) != 0 {\n\t\treq.Subgraphs = append(req.Subgraphs, shortestSg...)\n\t}\n\treturn nil\n}\n\n// ExecutionResult holds the result of running a query.\ntype ExecutionResult struct {\n\tSubgraphs  []*SubGraph\n\tSchemaNode []*pb.SchemaNode\n\tTypes      []*pb.TypeUpdate\n\tMetrics    map[string]uint64\n}","sourceCodeStart":3007,"sourceCodeEnd":3043,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/query/query.go#L3007-L3043","documentation":"During ExecutionResult processing, Dgraph tracks per-subgraph execution in a hasExecuted bitmap. If any subgraph never executed (e.g. its processing path returned early or was skipped), the whole query returns this error. It signals an internal scheduling/processing failure rather than a data problem.","triggerScenarios":"Executing a multi-block or recursion/shortest-path query where one of the subgraphs is not marked executed in the hasExecuted slice, typically due to an internal skip path in processTaskPartial or query planning.","commonSituations":"Complex queries combining recurse/shortest-path blocks with other blocks, intermittent internal failures, or queries whose subgraph list length mismatched expected execution count.","solutions":["Retry the query once to rule out a transient internal scheduling issue","Split the query into separate simpler requests (run recurse/shortest blocks separately)","Check server logs for a preceding root-cause error in the same request","Upgrade Dgraph; this guard usually indicates an internal bug fixed in later versions"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"var resp *api.Response\nfor i := 0; i < 2; i++ {\n    resp, err = txn.Query(ctx, dql)\n    if err == nil || !strings.Contains(err.Error(), \"Query couldn't be executed\") {\n        break\n    }\n    // split complex query into simpler blocks before retry\n}","preventionTips":["Avoid mixing recurse/shortest blocks with many other blocks in one request","Monitor server logs for internal errors correlated with this guard","Keep Dgraph version current; internal scheduling bugs get fixed upstream"],"tags":["dql","execution","dgraph"],"backgroundTag":"query-execution-failed","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}