{"record":{"id":"6d8aca185f814fa2","repo":"apache/seatunnel","slug":"snapshotting-of-table-table-id-failed","errorCode":null,"errorMessage":"Snapshotting of table ${table.id()} failed","messagePattern":"Snapshotting of table (.+?) failed","errorType":"exception","errorClass":"ConnectException","httpStatus":null,"severity":"critical","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/source/reader/fetch/scan/MySqlSnapshotSplitReadTask.java","lineNumber":253,"sourceCode":"                            snapshotSplit.splitId(),\n                            Strings.duration(stop - exportStart));\n                    snapshotProgressListener.rowsScanned(\n                            snapshotContext.partition, table.id(), rows);\n                    logTimer = getTableScanLogTimer();\n                }\n                dispatcher.dispatchSnapshotEvent(\n                        snapshotContext.partition,\n                        table.id(),\n                        getChangeRecordEmitter(snapshotContext, table.id(), row),\n                        snapshotReceiver);\n            }\n            LOG.info(\n                    \"Finished exporting {} records for split '{}', total duration '{}'\",\n                    rows,\n                    snapshotSplit.splitId(),\n                    Strings.duration(clock.currentTimeInMillis() - exportStart));\n        } catch (SQLException e) {\n            throw new ConnectException(\"Snapshotting of table \" + table.id() + \" failed\", e);\n        }\n    }\n\n    protected ChangeRecordEmitter<MySqlPartition> getChangeRecordEmitter(\n            MySqlSnapshotContext snapshotContext, TableId tableId, Object[] row) {\n        snapshotContext.offset.event(tableId, clock.currentTime());\n        return new SnapshotChangeRecordEmitter<>(\n                snapshotContext.partition, snapshotContext.offset, row, clock);\n    }\n\n    private Threads.Timer getTableScanLogTimer() {\n        return Threads.timer(clock, LOG_INTERVAL);\n    }\n\n    private static class MySqlSnapshotContext\n            extends RelationalSnapshotChangeEventSource.RelationalSnapshotContext<\n                    MySqlPartition, MySqlOffsetContext> {\n","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/source/reader/fetch/scan/MySqlSnapshotSplitReadTask.java#L235-L271","documentation":"In MySqlSnapshotSplitReadTask.createDataEventsForTable, a SQLException while executing the snapshot SELECT for a split is wrapped in a ConnectException: 'Snapshotting of table <id> failed'. The library throws this because the JDBC read of the table chunk could not be completed, so the snapshot data cannot be produced.","triggerScenarios":"The JDBC query executed for the table's snapshot split (via executeQuery) throws SQLException — connection failure, query timeout, permission denial, or the table being dropped/altered during snapshot.","commonSituations":"Snapshotting very large tables exceeding net_write_timeout / wait_timeout; user lacking SELECT privilege; MySQL connection dropped; table renamed/dropped mid-snapshot.","solutions":["Inspect the wrapped SQLException cause for the real reason","Verify the SeaTunnel MySQL user has SELECT privilege on the table","Increase JDBC timeouts (connectTimeout, socketTimeout) and MySQL net_write_timeout/net_read_timeout","Reduce chunk/split size so each snapshot query runs shorter","Avoid DDL on the table during snapshot phase"],"exampleFix":"// before\n} catch (SQLException e) {\n    throw new ConnectException(\"Snapshotting of table \" + table.id() + \" failed\", e);\n}\n// after\n// no code fix needed by user; ensure:\nGRANT SELECT ON mydb.mytable TO 'seatunnel'@'%';\nSET GLOBAL net_write_timeout = 600;","handlingStrategy":"validation","validationCode":"mysql -u seatunnel -p -e \"SELECT COUNT(*) FROM mydb.mytable; SHOW VARIABLES LIKE 'net_write_timeout';\"","typeGuard":null,"tryCatchPattern":"try {\n    engine.execute(jobConfig);\n} catch (Exception e) {\n    if (e.getMessage().contains(\"Snapshotting of table\")) {\n        log.error(\"Snapshot SELECT failed; check cause and privileges\", e);\n    }\n}","preventionTips":["GRANT SELECT on all snapshotted tables","Increase JDBC socketTimeout and MySQL net_write_timeout/net_read_timeout","Freeze DDL during the snapshot phase","Use smaller chunk sizes so each SELECT is short-lived"],"tags":["mysql","cdc","snapshot","jdbc","sql-exception"],"backgroundTag":"database-query-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"}