When running test {{JPALockTest}} against a SQL Server 2008 R2 environment, the {{testLockModeTypeRead}} and {{testLockModeTypeWrite}} deadlock. The test case requires the feature {{DoesReadCommittedNotCauseWritersToBlockReadersCheck}} and while the {{SQLServerDialect}} indicates the feature is supported, these features are not enabled by default; hence why the test case hangs.
There are two possible options:
# Dialect's settings are set based on metadata collection by querying {{sys.databases}} and examining the values in columns {{snapshot_isolation_state=1}} and {{is_read_committed_snapshot_on=true}} during boot-up. # execute the appropriate database alter statements for the specific session before starting the transaction. {code} ALTER DATABASE MyDatabase SET ALLOW_SNAPSHOT_ISOLATION ON ALTER DATABASE MyDatabase SET READ_COMMITTED_SNAPSHOT ON {code} start transaction and execute test and then end the transaction followed by {code} ALTER DATABASE MyDatabase SET READ_COMMITTED_SNAPSHOT OFF ALTER DATABASE MyDatabase SET ALLOW_SNAPSHOT_ISOLATION OFF {code} |
|