HHH-13577 LockTest.testContendedPessimisticLock and StatementIsClosedAfterALockExceptionTest.testStatementIsClosed tests fail on Sybase

HHH-13577 : Re-enable LockTest for SybaseASE15Dialect
(cherry picked from commit 210aff098c)
This commit is contained in:
Andrea Boriero 2019-08-14 11:55:11 +01:00 committed by Gail Badner
parent e60defd402
commit 60cb3762ba
3 changed files with 14 additions and 6 deletions

View File

@ -559,7 +559,6 @@ public class LockTest extends BaseEntityManagerFunctionalTestCase {
@SkipForDialect(HSQLDialect.class) @SkipForDialect(HSQLDialect.class)
// ASE15.5 will generate select...holdlock and fail at this test, but ASE15.7 passes it. Skip it for ASE15.5 // ASE15.5 will generate select...holdlock and fail at this test, but ASE15.7 passes it. Skip it for ASE15.5
// only. // only.
@SkipForDialect(value = { SybaseASE15Dialect.class }, strictMatching = true, jiraKey = "HHH-6820")
@SkipForDialect(value = { SQLServerDialect.class }) @SkipForDialect(value = { SQLServerDialect.class })
public void testContendedPessimisticLock() throws Exception { public void testContendedPessimisticLock() throws Exception {
final CountDownLatch latch = new CountDownLatch( 1 ); final CountDownLatch latch = new CountDownLatch( 1 );

View File

@ -28,6 +28,7 @@ import org.hibernate.dialect.H2Dialect;
import org.hibernate.dialect.MySQLDialect; import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.PostgreSQL81Dialect; import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.dialect.SQLServerDialect; import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.SybaseASE15Dialect;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
@ -568,6 +569,12 @@ public class TransactionUtil {
st.execute(String.format( "SET TRANSACTION LOCK WAIT TIMEOUT %d", millis )); st.execute(String.format( "SET TRANSACTION LOCK WAIT TIMEOUT %d", millis ));
} }
} }
else if( Dialect.getDialect() instanceof SybaseASE15Dialect) {
try (Statement st = connection.createStatement()) {
//Prepared Statements fail for SET commands
st.execute(String.format( "SET LOCK WAIT %d", millis/1000 ));
}
}
else { else {
try { try {
connection.setNetworkTimeout( Executors.newSingleThreadExecutor(), (int) millis ); connection.setNetworkTimeout( Executors.newSingleThreadExecutor(), (int) millis );

View File

@ -79,11 +79,13 @@ public class ExceptionUtil {
else { else {
Throwable rootCause = ExceptionUtil.rootCause( e ); Throwable rootCause = ExceptionUtil.rootCause( e );
if ( if (
rootCause != null && ( rootCause != null && (
rootCause.getMessage().contains( "timeout" ) || rootCause.getMessage().contains( "timeout" ) ||
rootCause.getMessage().contains( "timed out" ) || rootCause.getMessage().contains( "timed out" ) ||
rootCause.getMessage().contains( "lock(s) could not be acquired" ) rootCause.getMessage().contains( "lock(s) could not be acquired" ) ||
) rootCause.getMessage().contains( "Could not acquire a lock" )
)
) { ) {
return true; return true;
} }