Skip to content

Commit 512362d

Browse files
Ignore unsupported scope usages
1 parent e81c8ae commit 512362d

File tree

5 files changed

+22
-7
lines changed

5 files changed

+22
-7
lines changed

src/NHibernate.Test/Async/SystemTransactions/SystemTransactionFixture.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,11 @@ public async Task CanUseSessionWithManyScopesAsync(bool explicitFlush)
192192
// being concurrently disposed of. See https://github.com/nhibernate/nhibernate-core/pull/1505 for more details.
193193
if (Sfi.ConnectionProvider.Driver is OdbcDriver)
194194
Assert.Ignore("ODBC sometimes fails on second scope by checking the previous transaction status, which may yield an object disposed exception");
195-
// SAP HANA .Net provider always causes system transactions to be distributed, causing them to complete
196-
// on concurrent threads. This creates race conditions when chaining scopes, the subsequent scope usage
195+
// SAP HANA & SQL Anywhere .Net provider always causes system transactions to be distributed, causing them to
196+
// complete on concurrent threads. This creates race conditions when chaining scopes, the subsequent scope usage
197197
// finding the connection still enlisted in the previous transaction, its complete being still not finished
198198
// on its own thread.
199-
if (Sfi.ConnectionProvider.Driver is HanaDriverBase)
199+
if (Sfi.ConnectionProvider.Driver is HanaDriverBase || Sfi.ConnectionProvider.Driver is SapSQLAnywhere17Driver)
200200
Assert.Ignore("SAP HANA scope handling causes concurrency issues preventing chaining scope usages.");
201201

202202
using (var s = WithOptions().ConnectionReleaseMode(ConnectionReleaseMode.OnClose).OpenSession())

src/NHibernate.Test/SystemTransactions/SystemTransactionFixture.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,11 @@ public void CanUseSessionWithManyScopes(bool explicitFlush)
181181
// being concurrently disposed of. See https://github.com/nhibernate/nhibernate-core/pull/1505 for more details.
182182
if (Sfi.ConnectionProvider.Driver is OdbcDriver)
183183
Assert.Ignore("ODBC sometimes fails on second scope by checking the previous transaction status, which may yield an object disposed exception");
184-
// SAP HANA .Net provider always causes system transactions to be distributed, causing them to complete
185-
// on concurrent threads. This creates race conditions when chaining scopes, the subsequent scope usage
184+
// SAP HANA & SQL Anywhere .Net provider always causes system transactions to be distributed, causing them to
185+
// complete on concurrent threads. This creates race conditions when chaining scopes, the subsequent scope usage
186186
// finding the connection still enlisted in the previous transaction, its complete being still not finished
187187
// on its own thread.
188-
if (Sfi.ConnectionProvider.Driver is HanaDriverBase)
188+
if (Sfi.ConnectionProvider.Driver is HanaDriverBase || Sfi.ConnectionProvider.Driver is SapSQLAnywhere17Driver)
189189
Assert.Ignore("SAP HANA scope handling causes concurrency issues preventing chaining scope usages.");
190190

191191
using (var s = WithOptions().ConnectionReleaseMode(ConnectionReleaseMode.OnClose).OpenSession())

src/NHibernate.Test/SystemTransactions/SystemTransactionFixtureBase.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ protected void DisableConnectionAutoEnlist(Configuration configuration)
5252
protected void IgnoreIfUnsupported(bool explicitFlush)
5353
{
5454
Assume.That(
55-
new[] { explicitFlush, UseConnectionOnSystemTransactionPrepare },
55+
new[]
56+
{
57+
explicitFlush,
58+
UseConnectionOnSystemTransactionPrepare && TestDialect.SupportsUsingConnectionOnSystemTransactionPrepare
59+
},
5660
Has.Some.EqualTo(true),
5761
"Implicit flush cannot work without using connection from system transaction prepare phase");
5862
}

src/NHibernate.Test/TestDialect.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,5 +138,10 @@ public bool SupportsSqlType(SqlType sqlType)
138138
/// Even quoted, some databases do not support square bracket in identifiers.
139139
/// </summary>
140140
public virtual bool SupportsSquareBracketInIdentifiers => true;
141+
142+
/// <summary>
143+
/// Some databases fail when a connection is enlisted during the first phase of a two phase commit.
144+
/// </summary>
145+
public virtual bool SupportsUsingConnectionOnSystemTransactionPrepare => true;
141146
}
142147
}

src/NHibernate.Test/TestDialects/SapSQLAnywhere17TestDialect.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,11 @@ public SapSQLAnywhere17TestDialect(Dialect.Dialect dialect)
2121
/// It seems they have decide to remove this support starting from version 16.
2222
/// </remarks>
2323
public override bool SupportsSquareBracketInIdentifiers => false;
24+
25+
/// <inheritdoc />
26+
/// <remarks>
27+
/// SQL Anywhere freezes on commit and the transaction ends by timeout.
28+
/// </remarks>
29+
public override bool SupportsUsingConnectionOnSystemTransactionPrepare => false;
2430
}
2531
}

0 commit comments

Comments
 (0)