{"record":{"id":"2682e95e9603ff46","repo":"risingwavelabs/risingwave","slug":"task-is-not-running","errorCode":null,"errorMessage":"task {:?} is not running","messagePattern":"task (.+?) is not running","errorType":"error_code","errorClass":"BatchError","httpStatus":null,"severity":"error","filePath":"src/batch/src/task/task_execution.rs","lineNumber":671,"sourceCode":"            .take()\n            .with_context(|| {\n                format!(\n                    \"Task{:?}'s output{} has already been taken.\",\n                    task_id,\n                    output_id.get_output_id(),\n                )\n            })?;\n        let task_output = TaskOutput {\n            receiver,\n            output_id: output_id.try_into()?,\n            failure: self.failure.clone(),\n        };\n        Ok(task_output)\n    }\n\n    pub fn check_if_running(&self) -> Result<()> {\n        if *self.state.lock() != TaskStatus::Running {\n            bail!(\"task {:?} is not running\", self.get_task_id());\n        }\n        Ok(())\n    }\n\n    pub fn check_if_aborted(&self) -> Result<bool> {\n        match *self.state.lock() {\n            TaskStatus::Aborted => Ok(true),\n            TaskStatus::Finished => bail!(\"task {:?} has been finished\", self.get_task_id()),\n            _ => Ok(false),\n        }\n    }\n\n    /// Check the task status: whether has ended.\n    pub fn is_end(&self) -> bool {\n        let guard = self.state.lock();\n        !(*guard == TaskStatus::Running || *guard == TaskStatus::Pending)\n    }\n}","sourceCodeStart":653,"sourceCodeEnd":689,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/batch/src/task/task_execution.rs#L653-L689","documentation":"A validation guard in BatchTaskExecution::check_if_running: it reads the task's current TaskStatus and bails unless the state is exactly Running. It fires when a client (e.g., the gRPC GetTaskOutput or abort paths) touches a task that is pending, aborted, or already finished — i.e., the caller assumed the task was executing but the state machine says otherwise. The offending input is the task_id whose state transitioned before or between the caller's requests.","triggerScenarios":"Thrown at src/batch/src/task/task_execution.rs:671 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fetch the task's current status first and only query output/cancel when it is Running","Treat this as an expected race on fast-completing tasks: if the task already finished, use the finished task's result or failure instead of the running output channel","Check TaskManager for the task's terminal state and error to surface the real failure to the client","Avoid tight retry loops; a task will never return to Running once it left that state"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}