{"record":{"id":"fd584947cf54176a","repo":"apache/dolphinscheduler","slug":"commandduplicatehandleexception-command","errorCode":null,"errorMessage":"CommandDuplicateHandleException(command)","messagePattern":"CommandDuplicateHandleException\\(command\\)","errorType":"exception","errorClass":"CommandDuplicateHandleException","httpStatus":null,"severity":"warning","filePath":"dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/workflow/execution/WorkflowExecutionFactory.java","lineNumber":76,"sourceCode":"     */\n    private IWorkflowExecution doCreateWorkflowExecution(Command command) {\n        final CommandType commandType = command.getCommandType();\n        final ICommandHandler commandHandler = commandHandlers\n                .stream()\n                .filter(c -> c.commandType() == commandType)\n                .findFirst()\n                .orElseThrow(() -> new IllegalArgumentException(\n                        \"Cannot find ICommandHandler for commandType: \" + commandType));\n        return commandHandler.handleCommand(command);\n    }\n\n    /**\n     * Delete the command in db, if the command is not exist in db will throw CommandDuplicateHandleException\n     */\n    private void deleteCommandOrThrow(Command command) {\n        boolean deleteResult = commandDao.deleteById(command.getId());\n        if (!deleteResult) {\n            throw new CommandDuplicateHandleException(command);\n        }\n    }\n}\n","sourceCodeStart":58,"sourceCodeEnd":80,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/workflow/execution/WorkflowExecutionFactory.java#L58-L80","documentation":"Thrown when a command's row cannot be deleted from the DB, meaning the command was already consumed/deleted by another process. It guards duplicate command handling so the same command is not executed twice.","triggerScenarios":"createWorkflowExecuteRunnable -> deleteCommandOrThrow: commandDao.deleteById(command.getId()) returns false because the command no longer exists (duplicate delivery or concurrent master).","commonSituations":"Duplicate commands enqueued by retry mechanisms, two master failover instances processing the same command, replayed commands after a master restart.","solutions":["Confirm the workflow instance was already created by another consumer; treat as benign duplicate","Check master HA/failover setup to ensure only one master consumes commands","Clear stale/duplicate rows in t_ds_command if stuck","Re-submit the workflow if no instance was actually created"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"boolean exists = commandDao.findById(command.getId()).isPresent(); // check before createWorkflowExecuteRunnable","typeGuard":null,"tryCatchPattern":"try { runnable = workflowExecutionFactory.createWorkflowExecuteRunnable(command); } catch (CommandDuplicateHandleException e) { log.info(\"command {} already consumed, skipping\", command.getId()); }","preventionTips":["Run a single active master per command queue (proper HA/failover config)","Avoid manual inserts into t_ds_command","Clean duplicate command rows during maintenance"],"tags":["java","master","duplicate-command"],"backgroundTag":"record-not-found","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}