Search code examples
javamysqlspring-bootjdbcjooq

Workaround for using NOWAIT and SKIP LOCKED clause in JOOQ


I'm using Jooq for my DB transaction management. I found that the NOWAIT and SKIP LOCKED clauses are supported only in the later versions of MySQL. In the MYSQL version I'm using does not support them. So, in JooQ, is there a workaround for this to work? Where one thread doesn't wait for a locked entity and continues processing other entities without changing the innodb_lock_wait_timeout DB configure?


Solution

  • SKIP LOCKED would be hard to emulate, but it makes perfect sense to emulate WAIT n or NOWAIT using the innodb_lock_wait_timeout session variable. We're going to do that already for PostgreSQL in jOOQ 3.15, so why not do it for older versions of MySQL as well:

    This will be made available in jOOQ 3.15