{"record":{"id":"3c652b6f6abbb48b","repo":"apache/seatunnel","slug":"api-09-3c652b","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-2-starter/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-2-starter/src/main/java/org/apache/seatunnel/core/starter/spark/execution/SinkExecuteProcessor.java#L208-L244","documentation":"SinkExecuteProcessor.handleSaveMode applies schema/data save-mode actions via a SaveModeHandler; any exception inside handler.open() or SaveModeExecuteWrapper.execute() is wrapped in a SeaTunnelRuntimeException with code HANDLE_SAVE_MODE_FAILED (API-09).","triggerScenarios":"Executing save-mode operations (auto-create tables, execute DDL/data in save-mode jar) fails — e.g. driver/credentials issues, DDL errors, connection failure while opening the handler.","commonSituations":"Missing JDBC driver on the Spark classpath; insufficient privileges to create tables; save-mode custom SQL failing; target database unreachable.","solutions":["Read the wrapped cause for the underlying save-mode failure","Ensure required drivers are on the classpath (add to env jars)","Verify credentials/permissions for schema creation or data manipulation on the target","Test the save-mode handler's target connection independently before running the job"],"exampleFix":"// before\nenv {\n  jars = []\n}\n// after\nenv {\n  jars = \"file:///opt/seatunnel/connectors/mysql-connector-java-8.0.x.jar\"\n}","handlingStrategy":"try-catch","validationCode":"try (SaveModeHandler h = handler) {\n    h.open();\n} catch (Exception e) {\n    precheckFailure(e); // surface driver/connection problems before the job\n}","typeGuard":null,"tryCatchPattern":"try {\n    sinkProcessor.execute();\n} catch (SeaTunnelRuntimeException e) {\n    if (\"API-09\".equals(e.getSeaTunnelErrorCode().getCode())) {\n        log.error(\"Save mode failed, cause:\", e.getCause());\n    }\n}","preventionTips":["Ensure JDBC drivers are on the classpath via env.jars","Validate save-mode custom SQL in the target database first","Check write privileges for auto table creation","Test target connectivity before running the full job"],"tags":["spark","save-mode","sink","api-09"],"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-14T11:17:12.474Z"}