Skip to content

Commit 8e3ea6e

Browse files
committed
squash locking-related test failures on Informix
we really need a custom impl of LockingSupport
1 parent bcec20f commit 8e3ea6e

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
lines changed

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/InformixDialect.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,9 +572,18 @@ public LimitHandler getLimitHandler() {
572572

573573
@Override
574574
public LockingSupport getLockingSupport() {
575+
// TODO: need a custom impl, because:
576+
// 1. Informix does not support 'skip locked'
577+
// 2. Informix does not allow 'for update' with joins
575578
return LockingSupportSimple.STANDARD_SUPPORT;
576579
}
577580

581+
// TODO: remove once we have a custom LockingSupport impl
582+
@Override @Deprecated(forRemoval = true)
583+
public boolean supportsSkipLocked() {
584+
return false;
585+
}
586+
578587
@Override
579588
public boolean supportsIfExistsBeforeTableName() {
580589
return getVersion().isSameOrAfter( 11, 70 );

hibernate-core/src/test/java/org/hibernate/orm/test/jpa/lock/LockExceptionTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.hibernate.Timeouts;
1111
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
1212
import org.hibernate.cfg.AvailableSettings;
13+
import org.hibernate.community.dialect.InformixDialect;
1314
import org.hibernate.dialect.CockroachDialect;
1415
import org.hibernate.dialect.SQLServerDialect;
1516
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
@@ -53,6 +54,7 @@ protected void tearDown() {
5354
@Test
5455
@JiraKey( value = "HHH-8786" )
5556
@SkipForDialect(dialectClass = CockroachDialect.class, reason = "for update clause does not imply locking. See https://github.com/cockroachdb/cockroach/issues/88995")
57+
@SkipForDialect(dialectClass = InformixDialect.class, reason = "no failure")
5658
public void testLockTimeoutFind() {
5759
final Item item = new Item( "find" );
5860

@@ -94,6 +96,7 @@ public void testLockTimeoutFind() {
9496

9597
@Test
9698
@SkipForDialect(dialectClass = CockroachDialect.class, reason = "Cockroach uses SERIALIZABLE by default and seems to fail reading a row that is exclusively locked by a different TX")
99+
@SkipForDialect(dialectClass = InformixDialect.class, reason = "Cursor must be on simple SELECT for FOR UPDATE")
97100
public void testLockTimeoutRefresh() {
98101
final Item item = new Item( "refresh" );
99102

@@ -136,6 +139,7 @@ public void testLockTimeoutRefresh() {
136139

137140
@Test
138141
@SkipForDialect(dialectClass = CockroachDialect.class, reason = "Cockroach uses SERIALIZABLE by default and seems to fail reading a row that is exclusively locked by a different TX")
142+
@SkipForDialect(dialectClass = InformixDialect.class, reason = "no failure")
139143
public void testLockTimeoutLock() {
140144
final Item item = new Item( "lock" );
141145

hibernate-core/src/test/java/org/hibernate/orm/test/locking/options/LockedRowsTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import jakarta.persistence.LockModeType;
88
import jakarta.persistence.Timeout;
99
import org.hibernate.PessimisticLockException;
10+
import org.hibernate.community.dialect.InformixDialect;
1011
import org.hibernate.dialect.MariaDBDialect;
1112
import org.hibernate.dialect.lock.PessimisticEntityLockException;
1213
import org.hibernate.jpa.SpecHints;
@@ -66,6 +67,7 @@ void dropTestData(SessionFactoryScope factoryScope) {
6667

6768
@Test
6869
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportNoWait.class)
70+
@SkipForDialect(dialectClass = InformixDialect.class, reason = "no failure")
6971
void testFindNoWait(SessionFactoryScope factoryScope) {
7072
factoryScope.inTransaction( (session) -> {
7173
assert session.getDialect().supportsNoWait();
@@ -84,6 +86,7 @@ void testFindNoWait(SessionFactoryScope factoryScope) {
8486

8587
@Test
8688
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportNoWait.class)
89+
@SkipForDialect(dialectClass = InformixDialect.class, reason = "no failure")
8790
void testLockNoWait(SessionFactoryScope factoryScope) {
8891
factoryScope.inTransaction( (session) -> {
8992
session.find(Book.class,1, PESSIMISTIC_WRITE);
@@ -128,6 +131,7 @@ void testQuerySkipLocked(SessionFactoryScope factoryScope) {
128131
dialectClass = MariaDBDialect.class,
129132
reason = "Cannot figure this out - it passes when run by itself, but fails when run as part of the complete suite."
130133
)
134+
@SkipForDialect(dialectClass = InformixDialect.class, reason = "no failure")
131135
void testFindSkipLocked(SessionFactoryScope factoryScope) {
132136
factoryScope.inTransaction( (session) -> {
133137
session.find(Book.class,1, PESSIMISTIC_WRITE);

hibernate-core/src/test/java/org/hibernate/orm/test/locking/options/ScopeAndSecondaryTableTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
package org.hibernate.orm.test.locking.options;
66

77
import jakarta.persistence.LockModeType;
8+
import org.hibernate.community.dialect.InformixDialect;
89
import org.hibernate.testing.jdbc.SQLStatementInspector;
910
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
1011
import org.hibernate.testing.orm.junit.DomainModel;
1112
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
1213
import org.hibernate.testing.orm.junit.SessionFactory;
1314
import org.hibernate.testing.orm.junit.SessionFactoryScope;
15+
import org.hibernate.testing.orm.junit.SkipForDialect;
1416
import org.hibernate.testing.orm.transaction.TransactionUtil;
1517
import org.junit.jupiter.api.AfterEach;
1618
import org.junit.jupiter.api.BeforeEach;
@@ -40,6 +42,7 @@ void dropTestData(SessionFactoryScope factoryScope) {
4042

4143
@Test
4244
@RequiresDialectFeature(feature=DialectFeatureChecks.SupportsLockingJoins.class, comment = "Come back and rework this to account for follow-on testing")
45+
@SkipForDialect( dialectClass = InformixDialect.class, reason = "Cursor must be on simple SELECT for FOR UPDATE")
4346
void simpleTest(SessionFactoryScope factoryScope) {
4447
final SQLStatementInspector sqlCollector = factoryScope.getCollectingStatementInspector();
4548
factoryScope.inTransaction( (session) -> {

hibernate-core/src/test/java/org/hibernate/orm/test/locking/options/ScopeTests.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.hibernate.EnabledFetchProfile;
88
import org.hibernate.Hibernate;
99
import org.hibernate.Locking;
10+
import org.hibernate.community.dialect.InformixDialect;
1011
import org.hibernate.dialect.Dialect;
1112
import org.hibernate.dialect.H2Dialect;
1213
import org.hibernate.dialect.HSQLDialect;
@@ -60,6 +61,7 @@ void dropTestData(SessionFactoryScope factoryScope) {
6061
// todo : generally, we do not lock collection tables - HHH-19513 plus maybe general problem with many-to-many tables
6162

6263
@Test
64+
@SkipForDialect(dialectClass = InformixDialect.class, reason = "update does not block")
6365
void testFind(SessionFactoryScope factoryScope) {
6466
final SQLStatementInspector sqlCollector = factoryScope.getCollectingStatementInspector();
6567

@@ -75,6 +77,7 @@ void testFind(SessionFactoryScope factoryScope) {
7577
}
7678

7779
@Test
80+
@SkipForDialect(dialectClass = InformixDialect.class, reason = "update does not block")
7881
void testFindWithExtended(SessionFactoryScope factoryScope) {
7982
final SQLStatementInspector sqlCollector = factoryScope.getCollectingStatementInspector();
8083

@@ -111,6 +114,7 @@ void testFindWithExtendedJpaExpectation(SessionFactoryScope factoryScope) {
111114
@Test
112115
@SkipForDialect(dialectClass = HSQLDialect.class, reason = "See https://sourceforge.net/p/hsqldb/bugs/1734/")
113116
@SkipForDialect(dialectClass = H2Dialect.class, reason = "H2 seems to not extend locks across joins")
117+
@SkipForDialect(dialectClass = InformixDialect.class, reason = "Cursor must be on simple SELECT for FOR UPDATE")
114118
void testFindWithExtendedAndFetch(SessionFactoryScope factoryScope) {
115119
final SQLStatementInspector sqlCollector = factoryScope.getCollectingStatementInspector();
116120

@@ -148,6 +152,7 @@ void testFindWithExtendedAndFetch(SessionFactoryScope factoryScope) {
148152
}
149153

150154
@Test
155+
@SkipForDialect(dialectClass = InformixDialect.class, reason = "update does not block")
151156
void testLock(SessionFactoryScope factoryScope) {
152157
final SQLStatementInspector sqlCollector = factoryScope.getCollectingStatementInspector();
153158

@@ -167,6 +172,7 @@ void testLock(SessionFactoryScope factoryScope) {
167172
}
168173

169174
@Test
175+
@SkipForDialect(dialectClass = InformixDialect.class, reason = "update does not block")
170176
void testLockWithExtended(SessionFactoryScope factoryScope) {
171177
final SQLStatementInspector sqlCollector = factoryScope.getCollectingStatementInspector();
172178

@@ -185,6 +191,7 @@ void testLockWithExtended(SessionFactoryScope factoryScope) {
185191
}
186192

187193
@Test
194+
@SkipForDialect(dialectClass = InformixDialect.class, reason = "update does not block")
188195
void testRefresh(SessionFactoryScope factoryScope) {
189196
final SQLStatementInspector sqlCollector = factoryScope.getCollectingStatementInspector();
190197

@@ -202,6 +209,7 @@ void testRefresh(SessionFactoryScope factoryScope) {
202209
}
203210

204211
@Test
212+
@SkipForDialect(dialectClass = InformixDialect.class, reason = "update does not block")
205213
void testRefreshWithExtended(SessionFactoryScope factoryScope) {
206214
final SQLStatementInspector sqlCollector = factoryScope.getCollectingStatementInspector();
207215

@@ -221,6 +229,7 @@ void testRefreshWithExtended(SessionFactoryScope factoryScope) {
221229

222230
@Test
223231
@SkipForDialect(dialectClass = HSQLDialect.class, reason = "See https://sourceforge.net/p/hsqldb/bugs/1734/")
232+
@SkipForDialect(dialectClass = InformixDialect.class, reason = "Cursor must be on simple SELECT for FOR UPDATE")
224233
void testEagerFind(SessionFactoryScope factoryScope) {
225234
final SQLStatementInspector sqlCollector = factoryScope.getCollectingStatementInspector();
226235

@@ -253,6 +262,7 @@ private boolean willAggressivelyLockJoinedTables(Dialect dialect) {
253262
@Test
254263
@SkipForDialect(dialectClass = HSQLDialect.class, reason = "See https://sourceforge.net/p/hsqldb/bugs/1734/")
255264
@SkipForDialect(dialectClass = H2Dialect.class, reason = "H2 seems to not extend locks across joins")
265+
@SkipForDialect(dialectClass = InformixDialect.class, reason = "Cursor must be on simple SELECT for FOR UPDATE")
256266
void testEagerFindWithExtended(SessionFactoryScope factoryScope) {
257267
final SQLStatementInspector sqlCollector = factoryScope.getCollectingStatementInspector();
258268

@@ -288,6 +298,7 @@ void testEagerFindWithExtended(SessionFactoryScope factoryScope) {
288298
@Test
289299
@SkipForDialect(dialectClass = HSQLDialect.class, reason = "See https://sourceforge.net/p/hsqldb/bugs/1734/")
290300
@SkipForDialect(dialectClass = H2Dialect.class, reason = "H2 seems to not extend locks across joins")
301+
@SkipForDialect(dialectClass = InformixDialect.class, reason = "Cursor must be on simple SELECT for FOR UPDATE")
291302
void testEagerFindWithFetchScope(SessionFactoryScope factoryScope) {
292303
final SQLStatementInspector sqlCollector = factoryScope.getCollectingStatementInspector();
293304

0 commit comments

Comments
 (0)