Skip to content

Commit c3597a3

Browse files
Fix TeamCity scope concurrency issues
Troubles with scope concurrency seems to occur more easily under the TeamCity agent than on my laptop.
1 parent d576b58 commit c3597a3

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,12 @@ 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 & SQL Anywhere .Net provider always causes system transactions to be distributed, causing them to
195+
// SAP HANA & SQL Anywhere .Net providers always cause system transactions to be distributed, causing them to
196196
// 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.
199199
if (Sfi.ConnectionProvider.Driver is HanaDriverBase || Sfi.ConnectionProvider.Driver is SapSQLAnywhere17Driver)
200-
Assert.Ignore("SAP HANA scope handling causes concurrency issues preventing chaining scope usages.");
200+
Assert.Ignore("SAP HANA and SQL Anywhere scope handling causes concurrency issues preventing chaining scope usages.");
201201

202202
using (var s = WithOptions().ConnectionReleaseMode(ConnectionReleaseMode.OnClose).OpenSession())
203203
{
@@ -265,6 +265,13 @@ public async Task CanUseSessionWithManyScopesAsync(bool explicitFlush)
265265
public async Task CanUseSessionOutsideOfScopeAfterScopeAsync(bool explicitFlush)
266266
{
267267
IgnoreIfUnsupported(explicitFlush);
268+
// SAP SQL Anywhere .Net provider always causes system transactions to be distributed, causing them to
269+
// complete on concurrent threads. This creates race conditions when chaining session usage after a scope,
270+
// the subsequent usage finding the connection still enlisted in the previous transaction, its complete
271+
// being still not finished on its own thread.
272+
if (Sfi.ConnectionProvider.Driver is SapSQLAnywhere17Driver)
273+
Assert.Ignore("SAP SQL Anywhere scope handling causes concurrency issues preventing chaining session usages.");
274+
268275
using (var s = WithOptions().ConnectionReleaseMode(ConnectionReleaseMode.OnClose).OpenSession())
269276
{
270277
using (var tx = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))

src/NHibernate.Test/SystemTransactions/SystemTransactionFixture.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,12 @@ 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 & SQL Anywhere .Net provider always causes system transactions to be distributed, causing them to
184+
// SAP HANA & SQL Anywhere .Net providers always cause system transactions to be distributed, causing them to
185185
// 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.
188188
if (Sfi.ConnectionProvider.Driver is HanaDriverBase || Sfi.ConnectionProvider.Driver is SapSQLAnywhere17Driver)
189-
Assert.Ignore("SAP HANA scope handling causes concurrency issues preventing chaining scope usages.");
189+
Assert.Ignore("SAP HANA and SQL Anywhere scope handling causes concurrency issues preventing chaining scope usages.");
190190

191191
using (var s = WithOptions().ConnectionReleaseMode(ConnectionReleaseMode.OnClose).OpenSession())
192192
{
@@ -254,6 +254,13 @@ public void CanUseSessionWithManyScopes(bool explicitFlush)
254254
public void CanUseSessionOutsideOfScopeAfterScope(bool explicitFlush)
255255
{
256256
IgnoreIfUnsupported(explicitFlush);
257+
// SAP SQL Anywhere .Net provider always causes system transactions to be distributed, causing them to
258+
// complete on concurrent threads. This creates race conditions when chaining session usage after a scope,
259+
// the subsequent usage finding the connection still enlisted in the previous transaction, its complete
260+
// being still not finished on its own thread.
261+
if (Sfi.ConnectionProvider.Driver is SapSQLAnywhere17Driver)
262+
Assert.Ignore("SAP SQL Anywhere scope handling causes concurrency issues preventing chaining session usages.");
263+
257264
using (var s = WithOptions().ConnectionReleaseMode(ConnectionReleaseMode.OnClose).OpenSession())
258265
{
259266
using (var tx = new TransactionScope())

0 commit comments

Comments
 (0)