{"record":{"id":"d3400fa4db014af5","repo":"apache/seatunnel","slug":"unable-to-set-innodb-lock-wait-timeout","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/MySqlSnapshotChangeEventSource.java","lineNumber":218,"sourceCode":"        // With REPEATABLE READ, all SELECT queries within the scope of a transaction (which we\n        // don't yet have) will read\n        // from the same MVCC snapshot. Thus each plain (non-locking) SELECT statements within the\n        // same transaction are\n        // consistent also with respect to each other.\n        //\n        // See: https://dev.mysql.com/doc/refman/5.7/en/set-transaction.html\n        // See: https://dev.mysql.com/doc/refman/5.7/en/innodb-transaction-isolation-levels.html\n        // See: https://dev.mysql.com/doc/refman/5.7/en/innodb-consistent-read.html\n        connection.connection().setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);\n        connection.executeWithoutCommitting(\n                \"SET SESSION lock_wait_timeout=\"\n                        + connectorConfig.snapshotLockTimeout().getSeconds());\n        try {\n            connection.executeWithoutCommitting(\n                    \"SET SESSION innodb_lock_wait_timeout=\"\n                            + connectorConfig.snapshotLockTimeout().getSeconds());\n        } catch (SQLException e) {\n            LOGGER.warn(\"Unable to set innodb_lock_wait_timeout\", e);\n        }\n\n        // ------------------------------------\n        // LOCK TABLES\n        // ------------------------------------\n        // Obtain read lock on all tables. This statement closes all open tables and locks all\n        // tables\n        // for all databases with a global read lock, and it prevents ALL updates while we have this\n        // lock.\n        // It also ensures that everything we do while we have this lock will be consistent.\n        if (connectorConfig.getSnapshotLockingMode().usesLocking()\n                && connectorConfig.useGlobalLock()) {\n            try {\n                globalLock();\n                metrics.globalLockAcquired();\n            } catch (SQLException e) {\n                LOGGER.info(\n                        \"Unable to flush and acquire global read lock, will use table read locks after reading table names\");","sourceCodeStart":200,"sourceCodeEnd":236,"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#L200-L236","documentation":"MySqlSnapshotChangeEventSource attempts to set the MySQL session variable innodb_lock_wait_timeout to the configured snapshot lock timeout before taking global read locks for the snapshot. If the SET SESSION statement throws a SQLException, the source logs a warning and continues; the snapshot lock acquisition itself is not aborted, but the timeout guard is not applied.","triggerScenarios":"Executing 'SET SESSION innodb_lock_wait_timeout=<seconds>' during lockTablesForSchemaSnapshot fails with a SQLException — e.g. the connected account lacks privileges for the variable value, the server rejects the value (out of range / innodb disabled), or the connection is broken.","commonSituations":"MySQL users without SUPER or variable-set privileges on managed services (RDS, Aurora, Cloud SQL) where session variable ranges are restricted; snapshot.lock.timeout configured to a value outside server bounds; stale connections to a restarted MySQL.","solutions":["Verify snapshot.lock.timeout is within the server's allowed innodb_lock_wait_timeout range (1-1073741824) and adjust it","Grant the CDC user privileges to set session variables, or use an account that can on your managed MySQL","Check the SQLException in the log for the real cause (privilege vs connection) and fix connectivity/permissions accordingly","If timeouts persist, lower the lock timeout or run the snapshot during low-traffic windows"],"exampleFix":"// before\nconnectorConfig.snapshotLockTimeout(Duration.ofSeconds(0))\n// after (a valid, positive seconds value within server range)\nconnectorConfig.snapshotLockTimeout(Duration.ofSeconds(30))","handlingStrategy":"validation","validationCode":"// Before starting the CDC job, verify the account can set the variable:\n// SHOW VARIABLES LIKE 'innodb_lock_wait_timeout';\n// SET SESSION innodb_lock_wait_timeout = <snapshotLockTimeoutSeconds>;\n// SELECT @@innodb_lock_wait_timeout; -- must equal requested value","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Confirm snapshot.lock.timeout seconds are within 1..1073741824","Test the CDC MySQL account's ability to SET SESSION variables on managed clouds","Monitor logs for this warning after connector startup","Run snapshots during low-traffic windows to reduce lock-wait pressure"],"tags":["mysql","cdc","snapshot","jdbc"],"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"}