0

I have some production code that has worked for a few years and just started encountering errors last week. The errors only occur with a particular process that inserts a bunch of information into the database.

The error I'm getting is: "This SqlTransaction has completed; it is no longer usable" which tells me that the transaction is either being committed or rolled back between the first SubmitChanges and the second SubmitChanges.

Basically the code looks like this:

WithTransaction(db => {
// Do a bunch of stuff - insert, update objects
db.SubmitChanges();
// Do a bunch more stuff
db.SubmitChanges(); // <-- This line is throwing the error.
});

The code for WithTransaction just opens a transaction, does the action indicated, and then closes the transaction in a finally block. (There's also some error handling, but that's not relevant to this issue.

SubmitChanges is just a wrapper for System.Data.Linq.DataContext.SubmitChanges()

My hypothesis is that something is going wrong in the first SubmitChanges() that is causing the transaction to roll back but isn't throwing an error. So I'm wondering if there's a good way for me to debug the earlier SubmitChanges and see if anything is going wrong there.

Or, alternatively, any other ideas for how to debug this error.

  • This isn't a whole lot of code to go off of. If you haven't looked already, perhaps try [looking at this StackOverflow thread](https://stackoverflow.com/questions/6358806/this-sqltransaction-has-completed-it-is-no-longer-usable-configuration-er) for others who may have encountered your problem before. – PausePause Oct 04 '18 at 21:48

1 Answers1

1

The problem was that there was a hardware failure with the box running the program, which caused outgoing connections to die. I discovered this when trying to copy files from the server also failed.

Moral of the story: if the software looks correct, sometimes that's because it is correct.

Hope this helps someone else having the same problem!