-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add transaction scope and distributed transaction tests #8
base: master
Are you sure you want to change the base?
Add transaction scope and distributed transaction tests #8
Conversation
Regarding to distributed transaction and On my local machine, this test ShouldNotThrowWhenDistributedTransaction throws (sometimes!) exception like
It is not clear for me, because when According to docs.microsoft.com
But, it seems to me, that durable resources (sql) have already enlisted to transaction (during open sql connection or hit to database like Flush()), because I can see that transaction is already distributed (transaction can not be promoted to distributed without durable resources) right there. Maybe, @fredericDelaporte could describe a little bit more. |
Yes, on the second session usage, it goes to distributed when we have About the occasional failures, they look to me as bugs of the dataprovider/MS-DTC/SQLServer transaction coordinator. (With SQL-Server, distributed transactions involving the same SQL-Server and no other durable resources are not actually coordinated by MS-DTC but offloaded to the SQL-Server. For other cases it may a bit more complicated.) During nhibernate/nhibernate-core#627, I have tried many things and I think I have also tried to actually release the connection at session disposal, but it was even more unstable as far as I remember. But maybe I am wrong and it should be tried again, at least for dialects now flagged with Anyway, the safer would be to cease relying on additional DML interactions with the database during the 2PC, which means disabling From @RogerKratz
Maybe the |
using NHibernate.Envers.Tests.Entities; | ||
using NUnit.Framework; | ||
|
||
namespace NHibernate.Envers.Tests.Integration.Basic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In NHibernate.Envers.Tests.Integration there is converted Hibernate Envers tests, so these tests suits better in NetSpecific.Integration instead.
{ | ||
} | ||
|
||
#if NETCOREAPP2_0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe put the ignore on the complete class instead?
Will try to catch up the org nhib core thread about this one tomorrow. Maybe I miss something obvious but... From @fredericDelaporte
Sounds like a big change. In our current project eg, we call flush twice for each commit in our nhib abstraction (why? - too long story for this thread). |
@fredericDelaporte @IwanowM |
I do not know how the Java transaction coordinator actually works, and why that works better on Hibernate side. But I think they are just widely different. Maybe the Java one has some transaction completion event occurring before the 2PC actually starts, allowing to do additional changes in the transaction without advanced features like Or maybe the Java transaction coordinator is just a lot more reliable and robust than Ado.Net combined with MsDtc and .Net data-providers specific implementations. |
I have added few failing tests according to #7
The main problem is that Envers tries to perform database related work during
BeforeTransactionCompletion
event, but it is forbidden by NH iftransaction.use_connection_on_system_prepare = false
(check TransactionScopeWithoutUseConnectionOnPrepare).For now, this problem takes place only in .NET Framework, but it seems, .net core already has support of ambient transaction (but without distributed transaction), so this problem will appear soon in .net Core
Performing database related work during
BeforeTransactionCompletion
also causes problems in case of distributed transaction, regardless of the values of thetransaction.use_connection_on_system_prepare
.1st commit phase begins concurrently for all transaction managers, so it seems to me, there is a high probability, despite of
EnlistDuringPrepareRequired
, that when prepare phase in AdoNetWithSystemTransactionFactory starts, corresponding sql connection has already been locked by database transaction manager and, as a result, we can not use this connection any more.Any way, to resolve this problem we need to move all database related work from DoBeforeTransactionCompletion to some place before TransactionScope dispose.