A small workaround, it you explicitly use NH's transactions (in addition to DTC), it works.
2009/10/7 Ayende Rahien <[email protected]> > If someone want to take additional look a this, I attached he NH patch with > the failing test. > > > 2009/10/7 Ayende Rahien <[email protected]> > >> when in doubt with nhibernate, plug in nh prof :-) >> Here is what is going on there: >> >> -- statement #1 >> INSERT INTO [Submission] >> (Version, >> Id) >> VALUES (1 /* @p0 */, >> 0 /* @p1 */) >> >> -- statement #2 >> ERROR: >> Could not synchronize database state with session >> NHibernate.StaleStateException: Unexpected row count: -1; expected: 1 >> at >> NHibernate.AdoNet.Expectations.BasicExpectation.VerifyOutcomeNonBatched(Int32 >> rowCount, IDbCommand statement) in >> C:\oss\NHibernate\src\NHibernate\AdoNet\Expectations.cs:line 33 >> at NHibernate.AdoNet.NonBatchingBatcher.AddToBatch(IExpectation >> expectation) in >> C:\oss\NHibernate\src\NHibernate\AdoNet\NonBatchingBatcher.cs:line 40 >> at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object >> id, Object[] fields, Boolean[] notNull, Int32 j, SqlCommandInfo sql, Object >> obj, ISessionImplementor session) in >> C:\oss\NHibernate\src\NHibernate\Persister\Entity\AbstractEntityPersister.cs:line >> 2642 >> at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object >> id, Object[] fields, Object obj, ISessionImplementor session) in >> C:\oss\NHibernate\src\NHibernate\Persister\Entity\AbstractEntityPersister.cs:line >> 2990 >> at NHibernate.Action.EntityInsertAction.Execute() in >> C:\oss\NHibernate\src\NHibernate\Action\EntityInsertAction.cs:line 59 >> at NHibernate.Engine.ActionQueue.Execute(IExecutable executable) in >> C:\oss\NHibernate\src\NHibernate\Engine\ActionQueue.cs:line 130 >> at NHibernate.Engine.ActionQueue.ExecuteActions(IList list) in >> C:\oss\NHibernate\src\NHibernate\Engine\ActionQueue.cs:line 113 >> at NHibernate.Engine.ActionQueue.ExecuteActions() in >> C:\oss\NHibernate\src\NHibernate\Engine\ActionQueue.cs:line 146 >> at >> NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource >> session) in >> C:\oss\NHibernate\src\NHibernate\Event\Default\AbstractFlushingEventListener.cs:line >> 255 >> at >> NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent event) >> in >> C:\oss\NHibernate\src\NHibernate\Event\Default\DefaultFlushEventListener.cs:line >> 19 >> at NHibernate.Impl.SessionImpl.Flush() in >> C:\oss\NHibernate\src\NHibernate\Impl\SessionImpl.cs:line 1523 >> at >> NHibernate.Transaction.AdoNetWithDistrubtedTransactionFactory.DistributedTransactionContext.System.Transactions.IEnlistmentNotification.Prepare(PreparingEnlistment >> preparingEnlistment) in >> C:\oss\NHibernate\src\NHibernate\Transaction\AdoNetWithDistrubtedTransactionFactory.cs:line >> 107 >> >> -- statement #3 >> ERROR: >> DTC transaction prepre phase failed >> System.Transactions.TransactionException: The operation is not valid for >> the state of the transaction. ---> System.Data.SqlClient.SqlException: >> Timeout expired. The timeout period elapsed prior to completion of the >> operation or the server is not responding. >> at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException >> exception, Boolean breakConnection) >> at >> System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject >> stateObj) >> at >> System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject >> stateObj, UInt32 error) >> at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult >> asyncResult, TdsParserStateObject stateObj) >> at System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket() >> at System.Data.SqlClient.TdsParserStateObject.ReadBuffer() >> at System.Data.SqlClient.TdsParserStateObject.ReadByte() >> at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, >> SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet >> bulkCopyHandler, TdsParserStateObject stateObj) >> at >> System.Data.SqlClient.TdsParser.TdsExecuteTransactionManagerRequest(Byte[] >> buffer, TransactionManagerRequestType request, String transactionName, >> TransactionManagerIsolationLevel isoLevel, Int32 timeout, >> SqlInternalTransaction transaction, TdsParserStateObject stateObj, Boolean >> isDelegateControlRequest) >> at >> System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransactionYukon(TransactionRequest >> transactionRequest, String transactionName, IsolationLevel iso, >> SqlInternalTransaction internalTransaction, Boolean >> isDelegateControlRequest) >> at >> System.Data.SqlClient.SqlDelegatedTransaction.SinglePhaseCommit(SinglePhaseEnlistment >> enlistment) >> --- End of inner exception stack trace --- >> at System.Transactions.TransactionState.Rollback(InternalTransaction >> tx, Exception e) >> at System.Transactions.Transaction.Rollback() >> at System.Transactions.TransactionScope.InternalDispose() >> at System.Transactions.TransactionScope.Dispose() >> at >> NHibernate.Transaction.AdoNetWithDistrubtedTransactionFactory.DistributedTransactionContext.System.Transactions.IEnlistmentNotification.Prepare(PreparingEnlistment >> preparingEnlistment) in >> C:\oss\NHibernate\src\NHibernate\Transaction\AdoNetWithDistrubtedTransactionFactory.cs:line >> 113 >> >> >> I am not sure _why_ this is going on, though. >> >> But I don't get what is actually happening, which is really annoying. >> I managed to repro that on the NH code base, I'll post to the nh dev >> mailing list with the details. >> >> >> 2009/10/7 Simone Busoli <[email protected]> >> >>> That must be something trivial, or at least that's what I usually end up >>> with when I struggle on stuff like this after going down the 'select is >>> broken' path. >>> >>> 2009/10/7 Ayende Rahien <[email protected]> >>> >>>> I can't figure out what is going on there yet, it is REALLY strange. >>>> >>>> 2009/10/7 Simone Busoli <[email protected]> >>>> >>>> That's pretty weird, I think thousands of people are doing the same all >>>>> over the world, or am I missing something which makes this case special? >>>>> >>>>> 2009/10/7 Ayende Rahien <[email protected]> >>>>> >>>>> That is a bug, investigating where the issue is now >>>>>> >>>>>> 2009/10/7 Vadim Kantorov <[email protected]> >>>>>> >>>>>> >>>>>>> Uploaded a repro. It presumes you have an sql express instance on >>>>>>> your >>>>>>> machine (if not, please go to the DefaultDatabaseConfiguration file >>>>>>> to >>>>>>> change) and "bugs" database created with enabled trusted connection. >>>>>>> >>>>>>> On 8 окт, 00:48, Vadim Kantorov <[email protected]> wrote: >>>>>>> > Ok, I have an idea how to reproduce ;) >>>>>>> > Instead of creating a new project, I'll copy this one and remove >>>>>>> all >>>>>>> > the rubbish :) >>>>>>> > >>>>>>> > On 8 окт, 00:23, Ayende Rahien <[email protected]> wrote: >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > > Can you create a unit test to reproduce the problem?This scenario >>>>>>> is known >>>>>>> > > to work correctly (at least I think so, I wrote a test for >>>>>>> something >>>>>>> > > similar). >>>>>>> > >>>>>>> > > 2009/10/7 Vadim Kantorov <[email protected]> >>>>>>> > >>>>>>> > > > Helped. Ridiculous. >>>>>>> > > > Oren, I would like the session to be enlisted in the >>>>>>> transaction, so >>>>>>> > > > it is ok, isn't it? >>>>>>> > >>>>>>> > > > I still have no clue what this exception means and what are the >>>>>>> > > > internal reasons.. >>>>>>> > > > Oren, if you do, could you please explain further a little bit. >>>>>>> > >>>>>>> > > > I wonder if it is me who screwed up or it is NH or whatever >>>>>>> that is >>>>>>> > > > buggy. >>>>>>> > >>>>>>> > > > On 7 окт, 23:37, Corey Kaylor <[email protected]> wrote: >>>>>>> > > > > Not sure which Dialect is being used, but if it's SQL Server >>>>>>> we've had >>>>>>> > > > > issues with the enlistment of transactions in NHibernate and >>>>>>> changed our >>>>>>> > > > > settings to use the property below. I hadn't had time to >>>>>>> track down >>>>>>> > > > exactly >>>>>>> > > > > why the default transaction factory had issues, but >>>>>>> regardless for us >>>>>>> > > > this >>>>>>> > > > > fixed our issues. >>>>>>> > > > > .SetProperty(Environment.TransactionStrategy, >>>>>>> > > > > "NHibernate.Transaction.AdoNetTransactionFactory") >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>> >>>> >>>> >>> >>> >>> >>> >> > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Rhino Tools Dev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rhino-tools-dev?hl=en -~----------~----~----~----~------~----~------~--~---
