apache/dolphinscheduler · warning · CommandDuplicateHandleException

CommandDuplicateHandleException(command)

Error message

CommandDuplicateHandleException(command)

What it means

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.

Source

Thrown at dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/workflow/execution/WorkflowExecutionFactory.java:76

     */
    private IWorkflowExecution doCreateWorkflowExecution(Command command) {
        final CommandType commandType = command.getCommandType();
        final ICommandHandler commandHandler = commandHandlers
                .stream()
                .filter(c -> c.commandType() == commandType)
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException(
                        "Cannot find ICommandHandler for commandType: " + commandType));
        return commandHandler.handleCommand(command);
    }

    /**
     * Delete the command in db, if the command is not exist in db will throw CommandDuplicateHandleException
     */
    private void deleteCommandOrThrow(Command command) {
        boolean deleteResult = commandDao.deleteById(command.getId());
        if (!deleteResult) {
            throw new CommandDuplicateHandleException(command);
        }
    }
}

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Confirm the workflow instance was already created by another consumer; treat as benign duplicate
  2. Check master HA/failover setup to ensure only one master consumes commands
  3. Clear stale/duplicate rows in t_ds_command if stuck
  4. Re-submit the workflow if no instance was actually created
Defensive patterns

Strategy: try-catch

Validate before calling

boolean exists = commandDao.findById(command.getId()).isPresent(); // check before createWorkflowExecuteRunnable

Try / catch

try { runnable = workflowExecutionFactory.createWorkflowExecuteRunnable(command); } catch (CommandDuplicateHandleException e) { log.info("command {} already consumed, skipping", command.getId()); }

Prevention

When it happens

Trigger: createWorkflowExecuteRunnable -> deleteCommandOrThrow: commandDao.deleteById(command.getId()) returns false because the command no longer exists (duplicate delivery or concurrent master).

Common situations: Duplicate commands enqueued by retry mechanisms, two master failover instances processing the same command, replayed commands after a master restart.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/fd584947cf54176a. Report an issue: GitHub.