File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 14
14
using System . Threading ;
15
15
using System . Transactions ;
16
16
using NHibernate . Cfg ;
17
+ using NHibernate . Driver ;
17
18
using NHibernate . Engine ;
18
19
using NHibernate . Linq ;
19
20
using NHibernate . Test . TransactionTest ;
@@ -186,6 +187,12 @@ public async Task CanDeleteItemAsync(bool explicitFlush)
186
187
public async Task CanUseSessionWithManyScopesAsync ( bool explicitFlush )
187
188
{
188
189
IgnoreIfUnsupported ( explicitFlush ) ;
190
+ // ODBC with SQL-Server always causes scopes to go distributed, which causes their transaction completion to run
191
+ // asynchronously. But ODBC enlistment also check the previous transaction in a way that do not guard against it
192
+ // being concurrently disposed of. See https://github.com/nhibernate/nhibernate-core/pull/1505 for more details.
193
+ Assume . That ( ! ( Sfi . ConnectionProvider . Driver is OdbcDriver ) ,
194
+ "ODBC sometimes fails on second scope by checking the previous transaction status, which may yield an object disposed exception" ) ;
195
+
189
196
using ( var s = WithOptions ( ) . ConnectionReleaseMode ( ConnectionReleaseMode . OnClose ) . OpenSession ( ) )
190
197
{
191
198
using ( var tx = new TransactionScope ( TransactionScopeAsyncFlowOption . Enabled ) )
@@ -529,4 +536,4 @@ public class SystemTransactionWithoutAutoJoinTransactionAsync : SystemTransactio
529
536
{
530
537
protected override bool AutoJoinTransaction => false ;
531
538
}
532
- }
539
+ }
Original file line number Diff line number Diff line change 4
4
using System . Threading ;
5
5
using System . Transactions ;
6
6
using NHibernate . Cfg ;
7
+ using NHibernate . Driver ;
7
8
using NHibernate . Engine ;
8
9
using NHibernate . Linq ;
9
10
using NHibernate . Test . TransactionTest ;
@@ -175,6 +176,12 @@ public void CanDeleteItem(bool explicitFlush)
175
176
public void CanUseSessionWithManyScopes ( bool explicitFlush )
176
177
{
177
178
IgnoreIfUnsupported ( explicitFlush ) ;
179
+ // ODBC with SQL-Server always causes scopes to go distributed, which causes their transaction completion to run
180
+ // asynchronously. But ODBC enlistment also check the previous transaction in a way that do not guard against it
181
+ // being concurrently disposed of. See https://github.com/nhibernate/nhibernate-core/pull/1505 for more details.
182
+ Assume . That ( ! ( Sfi . ConnectionProvider . Driver is OdbcDriver ) ,
183
+ "ODBC sometimes fails on second scope by checking the previous transaction status, which may yield an object disposed exception" ) ;
184
+
178
185
using ( var s = WithOptions ( ) . ConnectionReleaseMode ( ConnectionReleaseMode . OnClose ) . OpenSession ( ) )
179
186
{
180
187
using ( var tx = new TransactionScope ( ) )
@@ -539,4 +546,4 @@ public void SessionIsNotEnlisted()
539
546
}
540
547
}
541
548
}
542
- }
549
+ }
You can’t perform that action at this time.
0 commit comments