apache/seatunnel · warning

Unable to set innodb_lock_wait_timeout

Error message

Unable to set innodb_lock_wait_timeout

What it means

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.

Source

Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/io/debezium/connector/mysql/legacy/SnapshotReader.java:235

            if (!isRunning()) {
                return;
            }

            final long snapshotLockTimeout =
                    context.getConnectorConfig().snapshotLockTimeout().getSeconds();
            logger.info(
                    "Step 0: disabling autocommit, enabling repeatable read transactions, and setting lock wait timeout to {}",
                    snapshotLockTimeout);
            mysql.setAutoCommit(false);
            sql.set("SET TRANSACTION ISOLATION LEVEL REPEATABLE READ");
            mysql.executeWithoutCommitting(sql.get());
            sql.set("SET SESSION lock_wait_timeout=" + snapshotLockTimeout);
            mysql.executeWithoutCommitting(sql.get());
            try {
                sql.set("SET SESSION innodb_lock_wait_timeout=" + snapshotLockTimeout);
                mysql.executeWithoutCommitting(sql.get());
            } catch (SQLException e) {
                logger.warn("Unable to set innodb_lock_wait_timeout", e);
            }

            // Generate the DDL statements that set the charset-related system variables ...
            Map<String, String> systemVariables =
                    connectionContext.readMySqlCharsetSystemVariables();
            String setSystemVariablesStatement = connectionContext.setStatementFor(systemVariables);
            AtomicBoolean interrupted = new AtomicBoolean(false);
            long lockAcquired = 0L;
            int step = 1;

            Configuration configuration = context.config();
            try {
                // ------------------------------------
                // LOCK TABLES
                // ------------------------------------
                // Obtain read lock on all tables. This statement closes all open tables and locks
                // all tables
                // for all databases with a global read lock, and it prevents ALL updates while we

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Set a snapshot lock timeout whose seconds value is within the server's accepted innodb_lock_wait_timeout range
  2. Grant the connector's MySQL user the privileges needed to set session variables, or use an account that can on managed services
  3. Check the logged SQLException for the exact server error and address privileges/connectivity
  4. Coordinate with the preceding SET SESSION lock_wait_timeout step — if that one also fails, fix the account permissions before re-running the snapshot

Example fix

// before
snapshot.lock.timeout = 0 (invalid seconds for innodb_lock_wait_timeout)
// after
snapshot.lock.timeout = 30000 (-> SET SESSION innodb_lock_wait_timeout = 30)
Defensive patterns

Strategy: validation

Validate before calling

-- Verify before running the legacy snapshot:
SHOW GRANTS FOR 'cdc_user'@'%';
SET SESSION lock_wait_timeout = 30;
SET SESSION innodb_lock_wait_timeout = 30; -- must succeed for the CDC account

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/e74a6d0e1fefe90d. Report an issue: GitHub.