{"record":{"id":"1cfe3bf58add8205","repo":"apache/seatunnel","slug":"api-09-1cfe3b","errorCode":"API-09","errorMessage":"Handle save mode failed","messagePattern":"Handle save mode failed","errorType":"error_code","errorClass":"SeaTunnelRuntimeException","httpStatus":null,"severity":"error","filePath":"seatunnel-core/seatunnel-spark-starter/seatunnel-spark-starter-common/src/main/java/org/apache/seatunnel/core/starter/spark/execution/SinkExecuteProcessor.java","lineNumber":226,"sourceCode":"        if (createdAnySink && !skippedTables.isEmpty()) {\n            log.warn(\n                    MultiTableFailureHelper.formatFailedTableSummary(\n                            \"Some sink tables were skipped in Spark starter.\", skippedTables));\n        }\n        // the sink is the last stream\n        return null;\n    }\n\n    public void handleSaveMode(SeaTunnelSink sink) {\n        if (sink instanceof SupportSaveMode) {\n            Optional<SaveModeHandler> saveModeHandler =\n                    ((SupportSaveMode) sink).getSaveModeHandler();\n            if (saveModeHandler.isPresent()) {\n                try (SaveModeHandler handler = saveModeHandler.get()) {\n                    handler.open();\n                    new SaveModeExecuteWrapper(handler).execute();\n                } catch (Exception e) {\n                    throw new SeaTunnelRuntimeException(HANDLE_SAVE_MODE_FAILED, e);\n                }\n            }\n        }\n    }\n\n    private boolean shouldContinueOtherTables() {\n        return MultiTableFailureHelper.shouldContinueOtherTables(\n                ReadonlyConfig.fromConfig(sparkRuntimeEnvironment.getConfig()));\n    }\n\n    private RuntimeException wrapThrowable(Throwable error) {\n        if (error instanceof RuntimeException) {\n            return (RuntimeException) error;\n        }\n        return new RuntimeException(error);\n    }\n\n    private void logSkippedTable(","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-core/seatunnel-spark-starter/seatunnel-spark-starter-common/src/main/java/org/apache/seatunnel/core/starter/spark/execution/SinkExecuteProcessor.java#L208-L244","documentation":"Thrown when executing a sink's SaveModeHandler — the pre-write actions like auto-create-table, drop-table, or clear-data — fails. The handler is opened, executed via SaveModeExecuteWrapper, and any Exception is rethrown as a SeaTunnelRuntimeException with code API-09 ('Handle save mode failed'). The root cause (typically a database error) is attached.","triggerScenarios":"Sink implements SupportSaveMode and its SaveModeHandler.open() or execute() throws — e.g. CREATE TABLE fails on the target database (insufficient privileges, syntax unsupported, connection failure), or DROP/TRUNCATE of an existing table fails.","commonSituations":"Target database user lacks CREATE/DROP privileges; table exists with a conflicting schema; JDBC dialect in the save-mode handler not supporting the target DB version; network/credentials issues to the catalog DB.","solutions":["Read the 'Caused by' exception to see the actual database/DDL error","Grant the DB user the privileges needed by the save-mode (CREATE TABLE / DROP TABLE)","Change the save-mode option (e.g. from create_when_not_exist/drop_and_create to error_if_schema_mismatch or reuse the existing table)","Test the DDL manually against the target database"],"exampleFix":"// before\nsave_mode = \"DROP_AND_CREATE\"\n// after\nsave_mode = \"APPEND\"  # or ERROR_IF_SCHEMA_MISMATCH if DDL privileges are missing","handlingStrategy":"try-catch","validationCode":"// Pre-flight: check DDL privileges on the target database\n// GRANT CREATE, DROP ON target_db.* TO 'seatunnel_user'@'%';","typeGuard":null,"tryCatchPattern":"try {\n    runJob();\n} catch (SeaTunnelRuntimeException e) {\n    if (\"API-09\".equals(((SeaTunnelRuntimeException) e).getSeaTunnelErrorCode().getCode())) {\n        log.error(\"Save-mode DDL failed; check cause\", e.getCause());\n    }\n}","preventionTips":["Grant the sink DB user CREATE/DROP privileges required by the chosen save-mode","Prefer conservative save modes (APPEND / error_if_schema_mismatch) in production","Test save-mode DDL manually against the target DB before running jobs"],"tags":["save-mode","sink","database"],"backgroundTag":"database-write-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}