Skip to content

Commit ee50ee8

Browse files
committed
HHH-19551 - Address deficiencies in pessimistic locking
1 parent d3e9198 commit ee50ee8

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

hibernate-core/src/main/java/org/hibernate/dialect/MariaDBDialect.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@
1212

1313
import jakarta.persistence.Timeout;
1414
import org.hibernate.QueryTimeoutException;
15-
import org.hibernate.Timeouts;
1615
import org.hibernate.boot.model.FunctionContributions;
1716
import org.hibernate.boot.model.TypeContributions;
1817
import org.hibernate.dialect.aggregate.AggregateSupport;
1918
import org.hibernate.dialect.aggregate.MySQLAggregateSupport;
2019
import org.hibernate.dialect.function.CommonFunctionFactory;
2120
import org.hibernate.dialect.identity.IdentityColumnSupport;
2221
import org.hibernate.dialect.identity.MariaDBIdentityColumnSupport;
23-
import org.hibernate.dialect.lock.spi.LockTimeoutStyle;
2422
import org.hibernate.dialect.sequence.MariaDBSequenceSupport;
2523
import org.hibernate.dialect.sequence.SequenceSupport;
2624
import org.hibernate.dialect.sql.ast.MariaDBSqlAstTranslator;
@@ -280,7 +278,9 @@ public SequenceInformationExtractor getSequenceInformationExtractor() {
280278

281279
@Override
282280
public boolean supportsSkipLocked() {
283-
//only supported on MySQL and as of 10.6
281+
// only supported on MariaDB as of 10.6 (and MySQL 8.0)
282+
// - MySQLDialect supports >= 8.0 so not overridden from the default (true) there.
283+
// - however, MariaDBDialect supports >= 10.5 so we need to check
284284
return getVersion().isSameOrAfter( 10, 6 );
285285
}
286286

@@ -306,14 +306,6 @@ protected boolean supportsAliasLocks() {
306306
return false;
307307
}
308308

309-
@Override
310-
public LockTimeoutStyle getLockTimeoutStyle(Timeout timeout) {
311-
if ( timeout.milliseconds() == Timeouts.SKIP_LOCKED_MILLI && !supportsSkipLocked() ) {
312-
return LockTimeoutStyle.UNSUPPORTED;
313-
}
314-
return LockTimeoutStyle.QUERY;
315-
}
316-
317309
@Override
318310
public Timeout getLockTimeout(Connection connection, SessionFactoryImplementor factory) {
319311
// technically, Hibernate should never use these due to MariaDB supporting LockTimeoutStyle.QUERY;

hibernate-core/src/main/java/org/hibernate/dialect/MySQLDialect.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,11 +1289,10 @@ public void setLockTimeout(Timeout timeout, Connection connection, SessionFactor
12891289

12901290
@Override
12911291
public LockTimeoutStyle getLockTimeoutStyle(Timeout timeout) {
1292-
if ( timeout.milliseconds() == Timeouts.SKIP_LOCKED_MILLI ) {
1292+
if ( timeout.milliseconds() == Timeouts.SKIP_LOCKED_MILLI && !supportsSkipLocked() ) {
12931293
return LockTimeoutStyle.UNSUPPORTED;
12941294
}
1295-
1296-
return LockTimeoutStyle.CONNECTION;
1295+
return LockTimeoutStyle.QUERY;
12971296
}
12981297

12991298
@Override

0 commit comments

Comments
 (0)