Sql Connection fails until App Pool recycleRSS

1 reply

Last post Jan 05, 2020 02:33 PM by JuanMdP

‹ Previous Thread|Next Thread ›
  • Sql Connection fails until App Pool recycle

    Jan 04, 2020 09:37 PM|JuanMdP|LINK

    Greetings,

    We've a server running Windows Server 2008 R2 with IIS + PHP 5.5 + Sql Server 2008. It's been running for the past two years with one or two issues here and there but unrelated to what started happening a week ago: connection to the database would suddenly drop. I initially thought this was something else (thus my other thread) but it turns out this is very specific: connection to the database simply drops and can't be re-established (thus resulting in error from sqlsrv_connect about not being able to establish connection). No files missing, no errors in FTR, logs for the app pool show different functionalities of the site used when this happens but no pattern to discern. Connection simply drops and until the app pool is recycled, it won't be able to connect to the database again~.

    This is using ezsql library (which uses sqlsrv), connections are closed as soon as they are done so I don't imagine it's that. Plus, this has been working for two years and this is the first time we've encountered this issue. The user pool is the same as six months ago, there hasn't been an increase in load, if anything, it's being used a little less since the online access has been disabled a while ago and currently only runs at an intranet level with about 50 ~ 80 users per hour. It also seems to happen randomly. Sometimes it's once every several hours and sometimes a few times within the span of an hour. I've tried looking info online but only a few cases were reported and nobody mentioned a solution or cause for this, thus, any kind of info would be greatly appreciated~.

  • Re: Sql Connection fails until App Pool recycle

    Jan 05, 2020 02:33 PM|JuanMdP|LINK

    A bit more of info upon further debugging of the errors returned by sqlsrv: 

    [0] => IM004
    [SQLSTATE] => IM004
    [1] => 0
    [code] => 0
    [2] => [Microsoft][ODBC Driver Manager] Driver's SQLAllocHandle on SQL_HANDLE_ENV failed
    [message] => [Microsoft][ODBC Driver Manager] Driver's SQLAllocHandle on SQL_HANDLE_ENV failed

    And on just one occasion I also got:

    [0] => 08001
    [SQLSTATE] => 08001
    [1] => 0
    [code] => 0
    [2] => [Microsoft][ODBC Driver 11 for SQL Server]Unable to complete login process due to delay in opening server connection
    [message] => [Microsoft][ODBC Driver 11 for SQL Server]Unable to complete login process due to delay in opening server connection

    From what I've found around the web, reinstalling / repairing the driver fixes it for those who experience this permanently, however I did and it still triggers here and there. Furthermore, this goes away the moment I recycle the app pool. Anyone else ever experienced this with PHP + Sqlsrv extension~?

‹ Previous Thread|Next Thread ›