{"record":{"id":"db8167efba4ff909","repo":"apache/seatunnel","slug":"failed-to-append-edgeevent-to-wal-generated-id-is","errorCode":null,"errorMessage":"Failed to append EdgeEvent to WAL: generated id is missing.","messagePattern":"Failed to append EdgeEvent to WAL: generated id is missing\\.","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"critical","filePath":"seatunnel-edge-agent/seatunnel-edge-agent-starter/src/main/java/org/apache/seatunnel/edge/agent/starter/wal/sqlite/SqliteWalStore.java","lineNumber":101,"sourceCode":"                statement.setBytes(2, payload);\n                statement.setLong(3, event.getEventTime());\n                statement.setBytes(4, MetadataSerde.serialize(event.getMetadata()));\n                statement.setString(5, WalRecordStatus.PENDING.name());\n                statement.setInt(6, 0);\n                statement.setLong(7, now);\n                statement.setLong(8, now);\n                statement.setLong(9, batchId);\n                statement.executeUpdate();\n                try (ResultSet generatedKeys = statement.getGeneratedKeys()) {\n                    if (generatedKeys.next()) {\n                        long rowId = generatedKeys.getLong(1);\n                        connection.commit();\n                        return rowId;\n                    }\n                }\n            }\n            connection.rollback();\n            throw new SQLException(\"Failed to append EdgeEvent to WAL: generated id is missing.\");\n        } catch (Exception ex) {\n            connection.rollback();\n            throw ex;\n        } finally {\n            connection.setAutoCommit(autoCommit);\n        }\n    }\n\n    @Override\n    public List<WalRecord> claimPending(int maxRecords, int maxAttempts) throws Exception {\n        if (maxRecords < 1 || maxAttempts < 1) {\n            return new ArrayList<>();\n        }\n        boolean autoCommit = connection.getAutoCommit();\n        connection.setAutoCommit(false);\n        try {\n            List<WalRecord> records = selectPendingOrderByIdAsc(maxRecords, maxAttempts);\n            long now = System.currentTimeMillis();","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-edge-agent/seatunnel-edge-agent-starter/src/main/java/org/apache/seatunnel/edge/agent/starter/wal/sqlite/SqliteWalStore.java#L83-L119","documentation":"SqliteWalStore.append() inserts the event row and retrieves the auto-generated row id; if the insert succeeds but no generated key is returned, the store rolls back and throws this SQLException. A WAL row without an id is unusable for ordering and replay, so the append is treated as failed.","triggerScenarios":"Calling walStore.append(event) when Statement.RETURN_GENERATED_KEYS (or equivalent) yields no key after the insert — e.g. a driver/table configuration that does not expose rowids, or an INSERT statement the driver cannot report generated keys for.","commonSituations":"Using a sqlite JDBC driver whose generated-key support is disabled or incompatible; schema changes replacing the rowid-based table with one lacking auto-generated keys; driver version downgrades.","solutions":["Verify the sqlite JDBC driver version supports generated-key retrieval and is up to date.","Ensure the WAL table uses an INTEGER PRIMARY KEY autoincrement column so sqlite exposes the generated rowid.","Confirm the insert is executed with Statement.RETURN_GENERATED_KEYS / prepareStatement(sql, RETURN_GENERATED_KEYS).","Check schema drift — recreate the WAL table with the expected schema if it was altered externally."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { return store.append(event); } catch (SQLException e) { if (e.getMessage().contains(\"generated id is missing\")) { log.error(\"JDBC generated-keys unsupported; check driver/table schema\", e); } throw e; }","preventionTips":["Pin a sqlite JDBC driver version with generated-keys support.","Keep the WAL table's INTEGER PRIMARY KEY column intact.","Always prepare inserts with RETURN_GENERATED_KEYS.","Add a startup check that an INSERT into the WAL table returns a generated key."],"tags":["sqlite","wal","generated-keys","jdbc"],"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"}