{"record":{"id":"6061d64a2f96a9e6","repo":"prestodb/presto","slug":"generic-internal-error-6061d6","errorCode":"GENERIC_INTERNAL_ERROR","errorMessage":"Scheduling is complete, but stage execution %s is in state %s","messagePattern":"Scheduling is complete, but stage execution (.+?) is in state (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/execution/scheduler/SqlQueryScheduler.java","lineNumber":556,"sourceCode":"                        break;\n                    }\n\n                    // wait for a state change and then schedule again\n                    if (allBlocked && !blockedStages.isEmpty()) {\n                        try (TimeStat.BlockTimer timer = schedulerStats.getSleepTime().time()) {\n                            tryGetFutureValue(whenAnyComplete(blockedStages), 1, SECONDS);\n                        }\n                    }\n                    for (ListenableFuture<?> blockedStage : blockedStages) {\n                        blockedStage.cancel(true);\n                    }\n                }\n            }\n\n            for (StageExecutionAndScheduler stageExecutionInfo : scheduledStageExecutions) {\n                StageExecutionState state = stageExecutionInfo.getStageExecution().getState();\n                if (state != SCHEDULED && state != RUNNING && !state.isDone()) {\n                    throw new PrestoException(GENERIC_INTERNAL_ERROR, format(\"Scheduling is complete, but stage execution %s is in state %s\", stageExecutionInfo.getStageExecution().getStageExecutionId(), state));\n                }\n            }\n\n            scheduling.set(false);\n\n            // Inform the tracker that task scheduling has completed\n            partialResultQueryTaskTracker.completeTaskScheduling();\n\n            if (!getSectionsReadyForExecution().isEmpty()) {\n                startScheduling();\n            }\n        }\n        catch (Throwable t) {\n            scheduling.set(false);\n            queryStateMachine.transitionToFailed(t);\n            throw t;\n        }\n        finally {","sourceCodeStart":538,"sourceCodeEnd":574,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/execution/scheduler/SqlQueryScheduler.java#L538-L574","documentation":"Invariant failure in SqlQueryScheduler.schedule: the scheduler has no remaining work, yet a stage execution is not in a plausible terminal state. This indicates an internal state-machine inconsistency during query scheduling rather than a user error, and the query is aborted.","triggerScenarios":"Thrown at presto-main-base/src/main/java/com/facebook/presto/execution/scheduler/SqlQueryScheduler.java:556 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the query; this is a rare internal race in stage state handling","Upgrade to a Presto version containing the scheduler state-machine fix if it recurs","Report the incident with the query ID and full coordinator logs"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}