{"record":{"id":"312e9452dfaedeb8","repo":"apache/seatunnel","slug":"interrupted-while-reading-structure-of-schema","errorCode":null,"errorMessage":"Interrupted while reading structure of schema ","messagePattern":"Interrupted while reading structure of schema ","errorType":"exception","errorClass":"InterruptedException","httpStatus":null,"severity":"info","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/io/debezium/connector/mysql/MySqlSnapshotChangeEventSource.java","lineNumber":451,"sourceCode":"        // Record default charset\n        addSchemaEvent(\n                snapshotContext,\n                \"\",\n                connection.setStatementFor(connection.readMySqlCharsetSystemVariables()));\n\n        for (TableId tableId : capturedSchemaTables) {\n            if (!sourceContext.isRunning()) {\n                throw new InterruptedException(\n                        \"Interrupted while emitting initial DROP TABLE events\");\n            }\n            addSchemaEvent(\n                    snapshotContext, tableId.catalog(), \"DROP TABLE IF EXISTS \" + quote(tableId));\n        }\n\n        final Map<String, DatabaseLocales> databaseCharsets = connection.readDatabaseCollations();\n        for (String database : databases) {\n            if (!sourceContext.isRunning()) {\n                throw new InterruptedException(\n                        \"Interrupted while reading structure of schema \" + databases);\n            }\n\n            LOGGER.info(\"Reading structure of database '{}'\", database);\n            addSchemaEvent(snapshotContext, database, \"DROP DATABASE IF EXISTS \" + quote(database));\n            final StringBuilder createDatabaseDddl =\n                    new StringBuilder(\"CREATE DATABASE \" + quote(database));\n            final DatabaseLocales defaultDatabaseLocales = databaseCharsets.get(database);\n            if (defaultDatabaseLocales != null) {\n                defaultDatabaseLocales.appendToDdlStatement(database, createDatabaseDddl);\n            }\n            addSchemaEvent(snapshotContext, database, createDatabaseDddl.toString());\n            addSchemaEvent(snapshotContext, database, \"USE \" + quote(database));\n\n            createSchemaEventsForTables(snapshotContext, tablesToRead.get(database), true);\n        }\n    }\n","sourceCodeStart":433,"sourceCodeEnd":469,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/io/debezium/connector/mysql/MySqlSnapshotChangeEventSource.java#L433-L469","documentation":"MySqlSnapshotChangeEventSource.readTableStructure iterates over the databases being snapshotted, emitting DROP DATABASE schema events and capturing CREATE DDL into the schema history. Before each database it checks whether the connector task is still running; if the task was cancelled, stopped, or its thread interrupted, it aborts the snapshot by throwing InterruptedException. This is a cooperative-cancellation signal, not a MySQL-side failure.","triggerScenarios":"The snapshot loop calls sourceContext.isRunning() before processing each database and the flag has flipped to false (or the thread's interrupt flag was set), typically because the job was cancelled by the engine, the connector task was stopped/restarted, or a shutdown/interrupt was delivered to the snapshot thread mid-readTableStructure.","commonSituations":"Cancelling a SeaTunnel Zeta job while a large snapshot is in progress; connector task restart or failover during schema capture; `snapshot.locking.mode` or long schema reads making the window where a stop can land very large; operator redeploys while a first snapshot runs.","solutions":["No fix needed if the cancellation was intentional: the snapshot will resume or restart on the next task start.","If it fires unexpectedly, check the Zeta/connector logs just before this line for an explicit cancel, stop, or failover event to find who interrupted the task.","Reduce snapshot duration (e.g. snapshot on a replica, smaller table.changelog set, snapshot.max.threads tuning) so fewer interruptions land mid-schema-read.","If it happens repeatedly at the same point, verify MySQL connectivity/stability so the schema read completes quickly instead of hanging until a stop arrives."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// before submitting the CDC job\nif (!mysqlReachable(host, port, user, password)) {\n  throw new IllegalStateException(\"MySQL unreachable; snapshot would stall and risk interruption\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  executeCdcJob(config);\n} catch (InterruptedException e) {\n  Thread.currentThread().interrupt(); // preserve interrupt status\n  log.info(\"Snapshot cancelled at {} — will resume on restart\", e.getMessage());\n}","preventionTips":["Avoid cancelling jobs during first snapshots; schedule stops between snapshots","Keep snapshots short (fewer tables, replica-based snapshot)","Monitor snapshot progress so cancellations are deliberate","Ensure the engine's task thread is not spuriously interrupted by checkpoint timeouts"],"tags":["interrupted","snapshot","cancellation","mysql-cdc"],"backgroundTag":"operation-interrupted","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}