{"record":{"id":"d024ea9cf663c856","repo":"apache/dolphinscheduler","slug":"save-error","errorCode":"SAVE_ERROR","errorMessage":"SAVE_ERROR","messagePattern":"SAVE_ERROR","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.java","lineNumber":119,"sourceCode":"            throw new ServiceException(Status.USER_NO_OPERATION_PERM);\n        }\n\n        AlertPluginInstance alertPluginInstance = new AlertPluginInstance();\n        String paramsMapJson = parsePluginParamsMap(pluginInstanceParams);\n        alertPluginInstance.setPluginInstanceParams(paramsMapJson);\n        alertPluginInstance.setInstanceName(instanceName);\n        alertPluginInstance.setPluginDefineId(pluginDefineId);\n\n        if (alertPluginInstanceMapper.existInstanceName(alertPluginInstance.getInstanceName()) == Boolean.TRUE) {\n            throw new ServiceException(Status.PLUGIN_INSTANCE_ALREADY_EXISTS);\n        }\n\n        int i = alertPluginInstanceMapper.insert(alertPluginInstance);\n        if (i > 0) {\n            log.info(\"Create alert plugin instance complete, name:{}\", alertPluginInstance.getInstanceName());\n            return alertPluginInstance;\n        }\n        throw new ServiceException(Status.SAVE_ERROR);\n    }\n\n    /**\n     * update alert plugin instance\n     *\n     * @param loginUser            login user\n     * @param pluginInstanceId     plugin instance id\n     * @param instanceName         instance name\n     * @param pluginInstanceParams plugin instance params\n     */\n    @Override\n    public AlertPluginInstance updateById(User loginUser, int pluginInstanceId, String instanceName,\n                                          String pluginInstanceParams) {\n\n        if (!canOperatorPermissions(loginUser, null, AuthorizationType.ALERT_PLUGIN_INSTANCE, ALERT_PLUGIN_UPDATE)) {\n            throw new ServiceException(Status.USER_NO_OPERATION_PERM);\n        }\n","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.java#L101-L137","documentation":"Thrown by AlertPluginInstanceServiceImpl.create when alertPluginInstanceMapper.insert() returns 0, meaning no row was inserted into t_ds_alert_plugin_instance. The service treats any non-insert as a generic save failure and raises ServiceException(Status.SAVE_ERROR).","triggerScenarios":"Calling the create-alert-plugin-instance API where the mapper insert affects 0 rows — typically a DB constraint failure, connection problem, or transaction rollback silently swallowed at the DAO layer.","commonSituations":"Database connectivity issues, duplicate instance name colliding with a unique constraint, schema drift after upgrade, or MySQL replication/timeout dropping the insert.","solutions":["Check the datasource health and DB error logs around the failed insert (the mapper does not propagate the underlying SQLException).","Verify the alert plugin instance name does not violate unique constraints in t_ds_alert_plugin_instance.","Re-run the insert with SQL logging enabled to see why the row count is 0.","Confirm the alert-plugin-instance table schema matches the current DolphinScheduler version."],"exampleFix":"// before\nthrow new ServiceException(Status.SAVE_ERROR);\n// after\nlog.error(\"Insert alert plugin instance affected 0 rows, name:{}\", alertPluginInstance.getInstanceName());\nthrow new ServiceException(Status.SAVE_ERROR);","handlingStrategy":"try-catch","validationCode":"// caller-side: verify datasource reachable and name not duplicated before create\nAlertPluginInstance existing = alertPluginInstanceService.getByName(loginUser, instanceName);\nif (existing != null) throw new IllegalArgumentException(\"instance name already in use\");","typeGuard":null,"tryCatchPattern":"try { alertPluginInstanceService.createAlertPluginInstance(loginUser, pluginDefineId, instanceName, params); } catch (ServiceException e) { if (e.getCode() == Status.SAVE_ERROR.getCode()) { /* check DB health, retry or surface DB error */ } throw e; }","preventionTips":["Monitor datasource health before persistence operations","Enforce unique-name validation in the UI before submit","Keep alert instance table schema in sync with the deployed version"],"tags":["database","persistence"],"backgroundTag":"database-write-failed","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"}