{"record":{"id":"e74a6d0e1fefe90d","repo":"apache/seatunnel","slug":"unable-to-set-innodb-lock-wait-timeout-e74a6d","errorCode":null,"errorMessage":"Unable to set innodb_lock_wait_timeout","messagePattern":"Unable to set innodb_lock_wait_timeout","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/io/debezium/connector/mysql/legacy/SnapshotReader.java","lineNumber":235,"sourceCode":"            if (!isRunning()) {\n                return;\n            }\n\n            final long snapshotLockTimeout =\n                    context.getConnectorConfig().snapshotLockTimeout().getSeconds();\n            logger.info(\n                    \"Step 0: disabling autocommit, enabling repeatable read transactions, and setting lock wait timeout to {}\",\n                    snapshotLockTimeout);\n            mysql.setAutoCommit(false);\n            sql.set(\"SET TRANSACTION ISOLATION LEVEL REPEATABLE READ\");\n            mysql.executeWithoutCommitting(sql.get());\n            sql.set(\"SET SESSION lock_wait_timeout=\" + snapshotLockTimeout);\n            mysql.executeWithoutCommitting(sql.get());\n            try {\n                sql.set(\"SET SESSION innodb_lock_wait_timeout=\" + snapshotLockTimeout);\n                mysql.executeWithoutCommitting(sql.get());\n            } catch (SQLException e) {\n                logger.warn(\"Unable to set innodb_lock_wait_timeout\", e);\n            }\n\n            // Generate the DDL statements that set the charset-related system variables ...\n            Map<String, String> systemVariables =\n                    connectionContext.readMySqlCharsetSystemVariables();\n            String setSystemVariablesStatement = connectionContext.setStatementFor(systemVariables);\n            AtomicBoolean interrupted = new AtomicBoolean(false);\n            long lockAcquired = 0L;\n            int step = 1;\n\n            Configuration configuration = context.config();\n            try {\n                // ------------------------------------\n                // LOCK TABLES\n                // ------------------------------------\n                // Obtain read lock on all tables. This statement closes all open tables and locks\n                // all tables\n                // for all databases with a global read lock, and it prevents ALL updates while we","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/io/debezium/connector/mysql/legacy/SnapshotReader.java#L217-L253","documentation":"The legacy SnapshotReader tries to set the session variable innodb_lock_wait_timeout to the configured snapshot lock timeout before generating the consistent snapshot. A SQLException here is caught and logged as a warning; snapshot execution continues, but the InnoDB row-lock wait guard is not in effect for this session.","triggerScenarios":"execute() (called from doStart) runs 'SET SESSION innodb_lock_wait_timeout=<snapshotLockTimeout>' via mysql.executeWithoutCommitting and the driver throws SQLException — typically due to insufficient privileges, a value outside the server's allowed range, or a broken connection.","commonSituations":"CDC user on RDS/Aurora/Cloud SQL lacking privileges to set the variable to the requested value; snapshot.lock.timeout (millis) converted to a seconds value out of range; locking during a snapshot against a restricted replica.","solutions":["Set a snapshot lock timeout whose seconds value is within the server's accepted innodb_lock_wait_timeout range","Grant the connector's MySQL user the privileges needed to set session variables, or use an account that can on managed services","Check the logged SQLException for the exact server error and address privileges/connectivity","Coordinate with the preceding SET SESSION lock_wait_timeout step — if that one also fails, fix the account permissions before re-running the snapshot"],"exampleFix":"// before\nsnapshot.lock.timeout = 0 (invalid seconds for innodb_lock_wait_timeout)\n// after\nsnapshot.lock.timeout = 30000 (-> SET SESSION innodb_lock_wait_timeout = 30)","handlingStrategy":"validation","validationCode":"-- Verify before running the legacy snapshot:\nSHOW GRANTS FOR 'cdc_user'@'%';\nSET SESSION lock_wait_timeout = 30;\nSET SESSION innodb_lock_wait_timeout = 30; -- must succeed for the CDC account","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use a MySQL account permitted to set session lock variables on managed platforms","Keep snapshot.lock.timeout within valid innodb_lock_wait_timeout bounds","Check snapshot logs for both lock_wait_timeout and innodb_lock_wait_timeout warnings after startup","Prefer the current (non-legacy) snapshot source, which handles these settings more robustly"],"tags":["mysql","cdc","snapshot","jdbc","legacy"],"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"}