Peter Fitzgibbons
2005-Apr-06 19:52 UTC
MSSQL Server Transactions problem during test/unit
Hello All, I got a stack trace for "Cannot create new connection because in manual transaction mode." during a test/unit run. Please see the .rb and output at http://rafb.net/paste/results/t2UidP41.html Can someone help me out with this? I ran a trivial test against another MSSQL db/table and did not have a problem. Thanks for your assistance. Peter J. Fitzgibbons Applications Manager Lakewood Homes - "The American Dream Builder"(r) Peter.Fitzgibbons-STCS76aLmhk1y/cD6r8xzl6hYfS7NtTn@public.gmane.org (847) 884-8800 _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Chris McGrath
2005-Apr-06 20:24 UTC
Re: MSSQL Server Transactions problem during test/unit
I had this problem today too while using AR against a legacy database. I think it may have been something to do with primary key on the table not being an identity field, though I didn''t have time to investigate much further. Would your problem table be the same? I don''t have a fix for this, but if we can narrow the problem down it should be easier to create one. Cheers, Chris On Apr 6, 2005 8:52 PM, Peter Fitzgibbons <Peter.Fitzgibbons-p2lxMnUesd41y/cD6r8xzl6hYfS7NtTn@public.gmane.org> wrote:> > > Hello All, > > I got a stack trace for "Cannot create new connection because in manual > transaction mode." during a test/unit run. > > Please see the .rb and output at > http://rafb.net/paste/results/t2UidP41.html > > Can someone help me out with this? > > I ran a trivial test against another MSSQL db/table and did not have a > problem. > > Thanks for your assistance. > > Peter J. Fitzgibbons > Applications Manager > Lakewood Homes - "The American Dream Builder"(r) > Peter.Fitzgibbons-STCS76aLmhk1y/cD6r8xzl6hYfS7NtTn@public.gmane.org > (847) 884-8800 > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Peter Fitzgibbons
2005-Apr-06 21:42 UTC
Re: MSSQL Server Transactions problem during test/unit
Chris McGrath <c.r.mcgrath@...> writes:> > I had this problem today too while using AR against a legacy database. > I think it may have been something to do with primary key on the table > not being an identity field, though I didn''t have time to investigate > much further. > > Would your problem table be the same? I don''t have a fix for this, but > if we can narrow the problem down it should be easier to create one. > > Cheers, > > Chris >I changed my table defs from uniqueidentifier to int identity(1,1) and that change did not correct this issue. It does not seem to be related to the datatype of Primary Key column(s). Chris, maybe you could paste your code so I can compare versions?
Chris McGrath
2005-Apr-06 22:33 UTC
Re: Re: MSSQL Server Transactions problem during test/unit
I don''t have access to the code at the moment as it''s at work, and I wouldn''t be able to paste it anyway. I''ll try and find some time tomorrow to come up with a small test that reproduces the error, so it can be attached to a ticket on dev.rubyonrails.com, and we can go from there. Of course if you manage to do that first, that''d be great! :) Cheers, Chris On Apr 6, 2005 10:42 PM, Peter Fitzgibbons <peter.fitzgibbons-p2lxMnUesd41y/cD6r8xzl6hYfS7NtTn@public.gmane.org> wrote:> Chris McGrath <c.r.mcgrath@...> writes: > > > > > I had this problem today too while using AR against a legacy database. > > I think it may have been something to do with primary key on the table > > not being an identity field, though I didn''t have time to investigate > > much further. > > > > Would your problem table be the same? I don''t have a fix for this, but > > if we can narrow the problem down it should be easier to create one. > > > > Cheers, > > > > Chris > > > > I changed my table defs from uniqueidentifier to int identity(1,1) and that > change did not correct this issue. > > It does not seem to be related to the datatype of Primary Key column(s). > > Chris, maybe you could paste your code so I can compare versions? > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Peter Fitzgibbons
2005-Apr-11 14:59 UTC
Re: MSSQL Server Transactions problem during test/unit
CC: David Heinemeier Hansson Chris, David, I think I found a cause for this issue. MS Knowledgebase article http://support.microsoft.com/default.aspx/kb/271128/EN-US/? shows how the SQL OLEDB provider creates "implicit" connections when a forward-only or read-only recordset is being generated. I believe this is what is causing the AR::Base::Log method to fail... it is getting an implicit connection to do it''s db write. During transactions, the implicit connection is refused due to transaction context. David, How can we alter the Log method to have it create a new connection? Moreover, in MS SQL programming, the current "best practice", as encouraged by .NET IDE and examples, is to create a new connection for EVERY action and relase that connection as soon as logically possible. Is there a simple edit to the sqlserveradapter to make it create a new connection for EVERY action? Thanks for your time.