locked
Random occurrences of SQLState IM004 RRS feed

  • Question

  • Greetings,

    As the title says.. ok, actually, let's go from the beginning. We've a project that's been running on a Windows 2008 R2 + IIS 7.5 + PHP 5.6 + Sql Server 2008 for the past 4 years. Since the beginning of the year, out of the blue we started getting hit by intermittent errors connecting to the database at which point, if we don't recycle the app pool, then the app won't be able to establish database connection again.

    The exception provided by sqlsrv is 

    SQLState IM004
    [Microsoft][ODBC Driver Manager] Driver's SQLAllocHandle on SQL_HANDLE_ENV failed

    Now here's the thing. We've traced the IIS logs and there's no pattern to what triggers it. Like, the queries are all different but are queries that are executed pretty much all the time. To make it even weirder, for a whole 9 days last month, it didn't happen once. We've tried reinstalling the ODBC 11 Driver but there's no change whatsoever.

    While I realize updating to ODBC 17 Driver would be a good option, that'd require to migrate the entire project to PHP 7 and that's something we can't afford at present. So, all in all, anyone has any idea of how to either fix or at least trace this error? We are at our wits' end, we've tried everything we could think of and we aren't closer to a solution than we were a month ago. It's definitely something about the ODBC driver but we can't tell what. So hopefully somebody may have some idea as to where we could look.


    Thank you all in advance.

    Wednesday, February 5, 2020 2:18 AM