• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Issue “Driver's SQLAllocHandle on SQL_HANDLE_ENV failed” after component update 7 May 2019

Janus Bahs Jacquet

New Pleskian
Since some time between Tuesday afternoon (7 May) and Wednesday morning (8 May), European time, all attempts to connect to our SQL Server database through PHP (specifically PDO) fail with the following error message:

SQLSTATE[IM004]: [Microsoft][ODBC Driver Manager] Driver's SQLAllocHandle on SQL_HANDLE_ENV failed​

We have both an SQL Server database and a MySQL database running, and both are accessed from both PHP and Classic ASP (VBScript). Of these four constellations, only PHP connecting to the SQL Server database fails; the other three combinations work as they always have.

I can see from the Plesk changelog that a few seemingly relevant component updates were rolled out on 8 May, the day when we first saw the problem. I don’t actually know if any of these are related to the issue or not, but the fact that we’re suddenly getting error messages related to PHP’s connection via ODBC to an SQL Server database the same day that these exact three components are updated smells fishy. The updates in question are:
  • Updated PHP 7.1 to version 7.1.29.
  • Updated Microsoft ODBC Driver 17 for SQL Server to version 17.3.1.1.
  • Removed Microsoft ODBC Driver 13 for SQL Server from the default set of components.
  • Updated Microsoft Drivers for PHP 7.1/7.2 for SQL Server to version 5.6.1.
We use PHP 7.1, so we’re now on 7.1.29 – I don’t recall what version we were on before (perhaps 7.1.28 from April). Unless yesterday afternoon, we were still running Plesk 17.5.3, but I updated to 17.8.11 to see if that might magically fix things. Needless to say, it didn’t.

When I check the ODBC (64-bit) drivers on the server, I get this:

Screenshot-2019-05-09-at-15-38-04.png


It looks to me like there are three different ODBC drivers for SQL Server installed; I don’t know how to figure out which is being used with PDO to connect to SQL Server. Version 173.01.01 is, I take it, version 17.3.1.1, so that does seem to have been updated – I don’t know what version we had before. phpinfo() informed me that pdo_sqlsrv was version 5.2.0+10712, but that turned out to be because it was using the 32-bit extension, rather than the 64-bit extension (probably a manual error by me originally). After switching to the 64-bit version, pdo_sqlsrv is now version 5.6.1+11919, which fits with the changelog – but the connection error remains.

If ODBC Driver 13 was supposed to have been removed in the update, though, it clearly wasn’t, as the screenshot shows – but what exactly does “from the default set of components” mean anyway? Does that affect existing installs?

I’ve been researching and trying to find some kind of idea about what’s actually causing the SQLSTATE error, and the closest thing I’ve found is this GitHub issue from January, which seems to deal with a similar issue. The suggested fix there is to uninstall all previous versions of ODBC and install only the most recent one (17.2 in that issue, 17.3 now), but I can’t tell if that includes versions 11 and 13. At any rate, our msodbcsql17.dll file on the server is dated to 14 February, so I suspect this is perhaps not the cause of the current issue.

Apart from that one GitHub issue, I’ve come up completely empty-handed. I’ve been banging my head against the Internet wall all day, and I’ve nothing to show for it but a headache and an ended tether.

Can someone help me troubleshoot this? Am I barking up the wrong tree with the Plesk update? Might it be something else? Halp!
 
Here’s a better version of the screen shot – I hadn’t realised the resizing happened on the hosting site and not in the preview here (and for some reason I get an error message in Russian when I try to edit the post):

screengrab.png
 
Some further testing shows that I can connect to the SQL Server database using the old odbc_connect() and odbc_do() functions in PHP – the problem only seems to relate to PDO connections.

So I guess that limits it to the pdo_sqlsrv driver? (Except that’s the one that wasn’t actually changed along with the rest, since it was using the 32-bit version until this afternoon…)
 
This ended up getting solved by the host’s support team. I’m not sure precisely what they did, but they removed ODBC Driver 13 (as the Plesk update was presumably, then, supposed to have done automatically) and reinstalled ODBC Driver 17 from scratch, and that fixed it.
 
Back
Top