|
Demo Version
|
|
Download and try for yourself a fully working demo version, including sample apps and documentation. The only limitation is that the demo version only works inside the debugger.
|
|
Subscribe
|
|
Get It All for $50 USD:
WebPortal, ORMapper,
Source Code, All Updates
|
|
User Login
|
|
|
|
|
|
Wilson ORMapper Forums : Bugs & Issues : Error during rollback/Zombie message
|
|
| 1/15/2007 9:50:23 PM |
C#/.NET 2.0 I'm doing a lot of record inserts and getting an error and this stack frame:
..sqlTransaction.Zombie()
..sqlInternalTransaction.ZombieParent()
..sqlInternalTransaction.Rollback()
..sqlTransaction.Rollback()
..Obectspace.PersistChanges [Save() entry point]
I did a search on this and saw some older messages with one fix but a reference to a possible ADO.net problem. I upgraded to the latest ormapper, same results. Interestingly, this wasn't happening when i was going to SQL 2005 with two computers; it does happen on one computer to SQL 2000. This may be exacerbating some sort of resource problem.
Is there a workaround; a flush() or wait() or something? I'm willing to sacrifice run time for stability. Please help.
John Mott
johnmott@comcast.net |
| 3/26/2007 7:11:06 PM |
We encountered the same random Zombie. A few months ago, we opened a support incident with Microsoft. After many (many...many...many...) hours of troubleshooting, researching, escalating, and finger pointing, Microsoft finally conceded that this is a bug with ADO.Net. In specific, it's a bug with the SqlTransaction object. It will be fixed in a "future version" of ADO.Net, but a hotfix will not be issued since this is an "obscure scenario with a simple workaround."
I won't bore you with details, just a fix.
Don't use the SqlTransaction's Connection property.
Check the source code for the ORMapper and you'll find that Internals.Connection.GetTransaction connects to the database, begins a transaction and returns the IDbTransaction. The calling method (the Transaction constructor) then assigns an internal reference to the IDbTransaction's Connection property. What we found was that every once in a while, the IDbTransaction's Connection was NULL!!!! This ended up to be the root of the Zombie issue, which manifested itself later when we called PersistChanges.
The reason the Connection was NULL is really quite odd. In ADO.Net 2.0, the SqlTransaction was modified so that it has two references to the SqlConnection used to create it. The first is the publicly exposed Connection property. The second in a private connection property. The private connection has a weak reference to the public connection.
Since the SqlConnection is created inside Internals.Connection.GetTransaction, it goes out of scope when the IDbTransaction is returned to the Transaction's constructor. At that point, the Connection is eligible for Garbage Collection. Every once in a while, the GC collects the Connection object between the point the Transaction is created and the point you PersistChanges.
We fixed this using the following code:
1) Modify the constructor of the Transaction class:
internal Transaction(Context context, IsolationLevel isolationLevel) { this.context = context; //in .NET 2.0 is to keep a reference to the outer connection of the transaction // //OLD CODE //this.transaction = this.context.Connection.GetTransaction(isolationLevel); //this.connection = this.transaction.Connection; // //NEW CODE this.connection = this.context.Connection.GetConnection(); this.transaction = this.connection.BeginTransaction( isolationLevel ); this.context.Connection.InterceptCommand(this.id, null, CommandInfo.BeginTran, null); }
2) Modify the Internals.Connection class
a. Remove the GetTransaction( String isolationLevel ) as it will no longer be referenced
b. Add new method GetConnection() which will return a connection to the database:
internal IDbConnection GetConnection() { IDbConnection connection = ProviderFactory.GetConnection(this.connection, this.provider); connection.Open(); return connection; }
Happy Hairpulling,
Rob |
| 4/12/2007 2:28:18 PM |
Rob,
If this really fixes it, I'll send you over a case of good german beer :)
We discovered/posted this problem already months ago and worked around it just retrying transactions up to three times when we get this zombie error. We were just about to switch to another O/R mapper because of this problem and the feeling it will never be fixed.
We could reproduce the error several times a hour before with a small test program and will test the fix tomorrow and post about our results.
Paul, could you please comment on this?
Regards, Gunter
|
| 4/13/2007 2:18:19 AM |
We were seeing this error from time to time and a couple weeks ago I came across this thread and updated the code as described. We haven't seen the issue since. Hopefully you'll have the same experience, and hopefully the fix will make it's way into the next release. :)
Cheers, Steve http://iqueryable.com/
|
| 4/18/2007 3:32:40 PM |
Strike!
The fix works. Whereas with the old version we could reproduce the zombie within several thousand saves, with the fix in place it didn't occur after one million.
By the way, the error seemed always to occur more often on heavily memory and cpu constrained systems (not on our development systems). After seeing the patch i can now imagine why.
Thanks again,
Gunter |
| 5/1/2007 11:04:44 PM |
I can definitely acknowledge that you and a few others are obviously encountering a very real problem. I hesitate to call it a bug since I know the previous problem like this that I had fixed was due to a bug in ADO.NET. But nonetheless it does seem to be a new issue, so it may well be a bug too, and no matter what it should be fixed. On the other hand, I know that I and many others run quite a few applications that have never ever encountered this issue. That has certainly contributed to my not forcing myself to have to find the time to look into this, and unfortunately I just am not getting things done that I would like to do, including finishing already started stuff.
At one time I believed that I just needed to change my job situation, as the one that I was at had grown to expect too much of my time. About the time I changed jobs my wife changed positions and started working a very very early morning shift. I thought I would adapt but I never did, and she has now found a more normal position. So now I find that my current job is not expecting too much, and my home life has finally gotten mostly back to normal, but I am so far behind on what I want to do on my own that its gotten depressing. Meanwhile its been so long since I've had free time that I've been enjoying spending it in other ways, which just adds to my delays.
That's probably not what you were asking for when you asked me to comment, but I hope it does clarify where I am at. I believe I was always clear from the beginning that my ORMapper was something that I found useful for myself, and that was why and remains why I created it. Of course instead of sharing my code for free I charged $50, but that was always because I felt it was a significant amount of code, and not because I was trying to become a software vendor. I think most people have understood this and not expected to much, and to that end I've actually went far beyond that in my upkeep of the ORMapper, even better than some real vendors if I dare so.
Unfortunately that may have created the impression that I was always going to make this my priority, but as much as I sometimes want to, that simply is not and cannot be my reality. So while I do still hope to make the time to make another official release, including this bug fix, I'm also very happy to see that Rob has apparently fixed it since I haven't found the time. In the meantime, I hope that you and others continue to find the ORMapper to be useful once you get this bug fix in place, as I know I and many others have. I do hope to either update it for Linq, or if Linq is good enough then I want to update my Portal to Linq -- whatever I find useful myself again, and hopefully others will agree.
I should stop myself now. :)
Thanks, Paul Wilson |
| 5/1/2007 11:05:36 PM |
This solution worked for us as well. Wow! That was a nasty one. Thanks guys!
-Justin |
|
|