{"record":{"id":"e677ef6766d3ec41","repo":"hashicorp/nomad","slug":"executor-shutdown-failed-v","errorCode":null,"errorMessage":"executor Shutdown failed: %v","messagePattern":"executor Shutdown failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/exec/driver.go","lineNumber":630,"sourceCode":"\tcase <-ctx.Done():\n\t\treturn\n\tcase <-d.ctx.Done():\n\t\treturn\n\tcase ch <- result:\n\t}\n}\n\nfunc (d *Driver) StopTask(taskID string, timeout time.Duration, signal string) error {\n\thandle, ok := d.tasks.Get(taskID)\n\tif !ok {\n\t\treturn drivers.ErrTaskNotFound\n\t}\n\n\tif err := handle.exec.Shutdown(signal, timeout); err != nil {\n\t\tif handle.pluginClient.Exited() {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"executor Shutdown failed: %v\", err)\n\t}\n\n\treturn nil\n}\n\nfunc (d *Driver) DestroyTask(taskID string, force bool) error {\n\thandle, ok := d.tasks.Get(taskID)\n\tif !ok {\n\t\treturn drivers.ErrTaskNotFound\n\t}\n\n\tif handle.IsRunning() && !force {\n\t\treturn fmt.Errorf(\"cannot destroy running task\")\n\t}\n\n\tif !handle.pluginClient.Exited() {\n\t\tif err := handle.exec.Shutdown(\"\", 0); err != nil {\n\t\t\thandle.logger.Error(\"destroying executor failed\", \"error\", err)","sourceCodeStart":612,"sourceCodeEnd":648,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/exec/driver.go#L612-L648","documentation":"StopTask sends a shutdown signal to the task's executor and waits up to the given timeout for graceful termination. If executor.Shutdown returns an error, the driver reports 'executor Shutdown failed'. If the plugin client has already exited, the error is swallowed since the task is already gone.","triggerScenarios":"Calling driver.StopTask(taskID, timeout, signal) while the executor is alive but executor.Shutdown(signal, timeout) returns an error (signal delivery failed or the process did not exit within timeout).","commonSituations":"Task ignores SIGTERM and outlives the kill_timeout; executor process wedged or unresponsive; insufficient permissions to signal the process; stopping tasks during client shutdown.","solutions":["Retry StopTask; if the process remains, the subsequent DestroyTask (force) will tear it down.","Increase the task's kill_timeout so the application has time to handle the shutdown signal.","Ensure the application handles SIGTERM (or the configured kill signal) and exits promptly.","Check executor logs for why the signal or wait failed (permissions, zombie process, plugin crash)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := driver.StopTask(taskID, timeout, signal); err != nil {\n    if strings.Contains(err.Error(), \"executor Shutdown failed\") {\n        // escalate: force destroy\n        _ = driver.DestroyTask(taskID, true)\n    }\n}","preventionTips":["Size kill_timeout to the application's real shutdown time.","Ensure apps handle SIGTERM and exit promptly.","Track down wedged executors via executor plugin logs."],"tags":["exec-driver","task-shutdown","nomad"],"backgroundTag":"graceful-shutdown-failed","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}