We have recently installed FreeTDS with php56-mssql onto one of our RHEL7 servers. Everything appears to be functioning correctly except for this strange issue. The first time we load a php page that is using mssql_connect() function, the page accesses the sql server 2012 instance, obtains the data, and renders the page as expected. However if we refresh the page once, the page will render, but without any of the data from the database. If we refresh a second time we receive the following 503 message:
Service Temporarily Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
If we go on to refresh a third time, the page renders with all of the data as expected. Also during troubleshooting I noticed that if we load the page, wait ~15 seconds, and then refresh, that the page loads as expected.
When exploring the error_log we see the following messages:
[Fri Oct 21 12:37:44.971872 2016] [proxy_fcgi:error] [pid 14052:tid 140504888997632] [client xx.xxx.xx.xx:xxxxx] AH01071: Got error 'PHP message: PHP Warning: mssql_select_db(): 2 is not a valid MS SQL-Link resource in /var/www/vhosts/example.com/e0/conn.php on line 6\nPHP message: PHP Warning: mssql_init(): 2 is not a valid MS SQL-Link resource in /var/www/vhosts/example.com/httpdocs/e1/search.php on line 16\nPHP message: PHP Warning: mssql_bind() expects parameter 1 to be resource, boolean given in /var/www/vhosts/example.com/httpdocs/e1/search.php on line 17\nPHP message: PHP Warning: mssql_bind() expects parameter 1 to be resource, boolean given in /var/www/vhosts/example.com/httpdocs/e1/search.php on line 18\nPHP message: PHP Warning: mssql_execute() expects parameter 1 to be resource, boolean given in /var/www/vhosts/example.com/httpdocs/e1/search.php on line 19\nPHP message: PHP Warning: mssql_free_statement() expects parameter 1 to be resource, boolean given in /var/www/vhosts/example.com/httpdocs/e1/search.php on line 20\nPHP message: PHP Warning: mssql_fetch_array() expects parameter 1 to be resource, null given in /var/www/vhosts/example.com/httpdocs/e1/search.php on line 23\nPHP message: PHP Notice: Undefined offset: 0 in /var/www/vhosts/example.com/httpdocs/e1/search.php on line 53\nPHP message: PHP Notice: Undefined offset: 0 in /var/www/vhosts/example.com/httpdocs/e1/search.php on line 60\n', referer: http://example.com/contacts/
[Fri Oct 21 12:37:45.347450 2016] [proxy_fcgi:error] [pid 14109:tid 140504956139264] (104)Connection reset by peer: [client xx.xxx.xx.xx:xxxxx] AH01075: Error dispatching request to :, referer: http://example.com/e1/
[Fri Oct 21 12:37:45.347625 2016] [include:warn] [pid 14109:tid 140504956139264] [client xx.xxx.xx.xx:xxxxx] AH01374: mod_include: Options +Includes (or IncludesNoExec) wasn't set, INCLUDES filter removed: /error_docs/maintenance.html, referer: http://example.com/e1/
Any suggestions? I'm at a loss as to why this is happening the way that it's happening!?
UPDATE
Tested another page using this connection. It loads fine the first time but if you request it again before 15 seconds has passed it straight up fails to connect:
AH01071: Got error 'PHP message: PHP Warning: mssql_connect(): Unable to connect to server: theServerName