Site Loading

Recently I saw the most bizarre error:

Spring.Transaction.TransactionSystemException: Could not roll back Hibernate transaction —> NHibernate.TransactionException: Transaction not connected, or was disconnected
at NHibernate.Transaction.AdoTransaction.CheckNotZombied()
at NHibernate.Transaction.AdoTransaction.Rollback()

So I thought I would write a short post on what the cause was and how we solved it. When we looked further into the issue we found that the inner exception was the session was being closed before the query had been run.

Firstly a little information around the issue was that it was happening in the live environment and not staging or development environment. We had an idea it was related to the data since the amount of data in production was obviously larger than in our staging and dev environments. So after recreating the data we debugged the code and found the query was doing something like the following:


Basically We were getting a list of Ids to use for searching for another object. The Issue was that we were passing in about three thousand Ids into the query. The code was then breaking because each Id being sent was considered a separate parameter. Since NHibernate only allows 2100 parameters per call. It was breaking and closing the session which caused the zombie error. Once we found out what the error was, I thought I would update an entry to hopefully help anyone with the same issue.

To solve the issue we rewrote the query so that we did not pass in three thousand Ids.