msphpsql icon indicating copy to clipboard operation
msphpsql copied to clipboard

SQLSTATE[HY010]: [Microsoft][ODBC Driver Manager] Function sequence error (again)

Open david-garcia-garcia opened this issue 11 years ago • 33 comments

I am close to getting buffered queries working in the Drupal database abstraction layer, with performance gains of ~30% (that's huge) on a vanilla install.

But... I am seeing again the Function sequence error :(

It took me ages to isolate the issue this time into a sample script.

Download schema and sample script from this dropbox link:

https://www.dropbox.com/s/3nd8xdf32a7dmyz/sample_sqlsrv_may.zip?dl=0

For the error to go away, simply remove the transaction related statements:

$cnn->beginTransaction(); $cnn->commit();

So it looks like you cannot have a transaction nested in a loop while iterating on a client buffered result set.

david-garcia-garcia avatar May 04 '15 20:05 david-garcia-garcia

Not sure if directly related, but I am seeing the function sequence error appear randomly on different usage scenarios.

All of them when trying to iterate over a client buffered result set.

david-garcia-garcia avatar May 18 '15 18:05 david-garcia-garcia

Hi david-garcia-garcia can you explain some of the usage scenarios that are causing the sequence error. I am with the team at Microsoft that own's this driver. I might be able to help you out.

meet-bhagdev avatar May 18 '15 18:05 meet-bhagdev

The case was too complex and would need investigation to really isolate the steps to reproduce. But it did share something similar with the sample script I provided in the same comment:

  • The error came and go intermitently (one request with error, the next one without, and so on...)
  • The error appeared after previous operations on the same connection dealt with failing transactions and rollbacks.

If you could get to reproduce the error with the provided script there's a chance that both of them are indeed the same bug.

david-garcia-garcia avatar May 18 '15 19:05 david-garcia-garcia

I am seeing this error consistently on Drupal 8 - MSSQL integration (and is preventing any further development because it breaks man automated tests...).

Unluckily, the circumstances that lead to the error are so complex that I was unsuccessfull at isolating a test script. I even tried to PROXY all operations on Drupal's database abstraction layer to later reproduce every single operation done against the PDO driver without luck, the error simply won't reproduce.

If you are interested in helping solve this out to get D8 working on MSSQL Server, I can provide the exact steps to reproduce on a clean D8 install. You will need the -dev version of the SQL Server driver for Drupal - that I can only share privately at the moment.

david-garcia-garcia avatar Jul 20 '15 13:07 david-garcia-garcia

I’d love to take a look at this.

Can you share the repro steps and the dev version driver?

Thanks

From: Davvid [mailto:[email protected]] Sent: Monday, July 20, 2015 6:36 AM To: Azure/msphpsql Subject: Re: [msphpsql] SQLSTATE[HY010]: [Microsoft][ODBC Driver Manager] Function sequence error (again) (#49)

I am seeing this error consistently on Drupal 8 - MSSQL integration (and is preventing any further development because it breaks man automated tests...).

Unluckily, the circumstances that lead to the error are so complex that I was unsuccessfull at isolating a test script. I even tried to PROXY all operations on Drupal's database abstraction layer to later reproduce every single operation done against the PDO driver without luck, the error simply won't reproduce.

If you are interested in helping solve this out to get D8 working on MSSQL Server, I can provide the exact steps to reproduce on a clean D8 install. You will need the -dev version of the SQL Server driver for Drupal - that I can only share privately at the moment.

— Reply to this email directly or view it on GitHubhttps://github.com/Azure/msphpsql/issues/49#issuecomment-122886221.

Lfsantos avatar Jul 20 '15 15:07 Lfsantos

Steps to reproduce:

  • Download a fresh copy of D8: git clone --branch 8.0.x http://git.drupal.org/project/drupal.git
  • Setup the site on IIS (see attached phpinfo() for enabled extensions and overal configuration)
  • Unzip the SQL Server driver to the root of drupal, this will show you SQL Server as an available target during the install process.
  • Install on SQL Server
  • Go to /admin/modules and enable the "testing" module
  • Go to /admin/config/development/testing and enable the \Drupal\search\Tests\SearchNumbersTest inside the "Search" group.
  • Set a breakpoint in line 183 of \core\modules\dblog\src\Controller\DbLogController.php (this is the loop where the error happens)
  • Run Tests. When the breakpoint is hit use F10 (Visual Studio + PHP Tools to debug) to step through about 4 times, the exception is thrown.

I found out that completely removing transaction management from the Drupal driver prevents the error from happening.

https://drive.google.com/file/d/0B2bjxiZ1Bb4BZmxNWnd1YmFpdDg/view?usp=sharing

(zip with sqlsrv driver, phpinfo() dump and screenshot of the exception)

Good luck. At least the exception is consistently reproducible.

Greetings

david-garcia-garcia avatar Jul 20 '15 17:07 david-garcia-garcia

Any luck with this? D8 is to be released before the end of the year, it would be nice to have it working on MSSQL shortly before that happens.

david-garcia-garcia avatar Aug 05 '15 06:08 david-garcia-garcia

I'm looking into it. I'll,keep you posted on that. Give me a week, since I was out of town.

Thanks

Sent from my iPad

On Aug 4, 2015, at 11:03 PM, Davvid <[email protected]mailto:[email protected]> wrote:

Any luck with this? D8 is to be released before the end of the year, it would be nice to have it working on MSSQL shortly before that happens.

Reply to this email directly or view it on GitHubhttps://github.com/Azure/msphpsql/issues/49#issuecomment-127882620.

Lfsantos avatar Aug 05 '15 06:08 Lfsantos

Do not use the latest D8 HEAD, download something from the date of my original post. Recent changes in D8 have broken the MSSQL driver for Drupal.

david-garcia-garcia avatar Aug 06 '15 11:08 david-garcia-garcia

Updated driver to fix compatiblity with latest head:

https://www.dropbox.com/s/j98z4fd8jh7wr0q/drivers2.rar?dl=0

Verified that the issue is still reproducible under the same conditions.

david-garcia-garcia avatar Aug 06 '15 17:08 david-garcia-garcia

I’ll take a look at this tonight, in my Mac

I’ll keep you posted

From: Davvid [mailto:[email protected]] Sent: Thursday, August 6, 2015 10:57 AM To: Azure/msphpsql [email protected] Cc: Luiz Fernando Santos [email protected] Subject: Re: [msphpsql] SQLSTATE[HY010]: [Microsoft][ODBC Driver Manager] Function sequence error (again) (#49)

Updated driver to fix compatiblity with latest head:

https://www.dropbox.com/s/j98z4fd8jh7wr0q/drivers2.rar?dl=0

Verified that the issue is still reproducible under the same conditions.

— Reply to this email directly or view it on GitHubhttps://github.com/Azure/msphpsql/issues/49#issuecomment-128458978.

Lfsantos avatar Aug 06 '15 17:08 Lfsantos

When I’m trying to create the SQL Server database in Drupal 8, I’m getting the following error in the PHP56 error_log file:

[11-Aug-2015 22:04:27 America/Los_Angeles] PHP Fatal error: Call to undefined function Drupal\Driver\Database\sqlsrv\wincache_ucache_get() in C:\inetpub\wwwroot\drupal\drivers\lib\Drupal\Driver\Database\sqlsrv\Connection.php on line 607

Any clue?

From: Davvid [mailto:[email protected]] Sent: Thursday, August 6, 2015 10:57 AM To: Azure/msphpsql [email protected] Cc: Luiz Fernando Santos [email protected] Subject: Re: [msphpsql] SQLSTATE[HY010]: [Microsoft][ODBC Driver Manager] Function sequence error (again) (#49)

Updated driver to fix compatiblity with latest head:

https://www.dropbox.com/s/j98z4fd8jh7wr0q/drivers2.rar?dl=0

Verified that the issue is still reproducible under the same conditions.

— Reply to this email directly or view it on GitHubhttps://github.com/Azure/msphpsql/issues/49#issuecomment-128458978.

Lfsantos avatar Aug 12 '15 05:08 Lfsantos

Hey Davvid,

I used the very first connector you sent me (used both versions in total) and the error below happens:

[13-Aug-2015 20:36:28 America/Los_Angeles] PHP Fatal error: Declaration of Drupal\Driver\Database\sqlsrv\Schema::addIndex() must be compatible with Drupal\Core\Database\Schema::addIndex($table, $name, $fields, array $spec) in C:\inetpub\wwwroot\drupal\drivers\lib\Drupal\Driver\Database\sqlsrv\Schema.php on line 41

From: Luiz Santos <[email protected]mailto:[email protected]> Date: Tuesday, August 11, 2015 at 10:09 PM To: Azure/msphpsql <[email protected]mailto:[email protected]>, Azure/msphpsql <[email protected]mailto:[email protected]> Subject: RE: [msphpsql] SQLSTATE[HY010]: [Microsoft][ODBC Driver Manager] Function sequence error (again) (#49)

When I'm trying to create the SQL Server database in Drupal 8, I'm getting the following error in the PHP56 error_log file:

[11-Aug-2015 22:04:27 America/Los_Angeles] PHP Fatal error: Call to undefined function Drupal\Driver\Database\sqlsrv\wincache_ucache_get() in C:\inetpub\wwwroot\drupal\drivers\lib\Drupal\Driver\Database\sqlsrv\Connection.php on line 607

Any clue?

From: Davvid [mailto:[email protected]] Sent: Thursday, August 6, 2015 10:57 AM To: Azure/msphpsql <[email protected]mailto:[email protected]> Cc: Luiz Fernando Santos <[email protected]mailto:[email protected]> Subject: Re: [msphpsql] SQLSTATE[HY010]: [Microsoft][ODBC Driver Manager] Function sequence error (again) (#49)

Updated driver to fix compatiblity with latest head:

https://www.dropbox.com/s/j98z4fd8jh7wr0q/drivers2.rar?dl=0

Verified that the issue is still reproducible under the same conditions.

Reply to this email directly or view it on GitHubhttps://github.com/Azure/msphpsql/issues/49#issuecomment-128458978.

Lfsantos avatar Aug 14 '15 03:08 Lfsantos

call to undefined function Drupal\Driver\Database\sqlsrv\wincache_ucache_get()

You need the Wincache PHP extension for the MSSQL driver to work.

http://sourceforge.net/projects/wincache/files/development/wincache-1.3.7.7-dev-5.4-nts-vc9-x86.exe/download

Declaration of Drupal\Driver\Database\sqlsrv\Schema::addIndex() must be compatible with Drupal\Core\Database\Schema::addIndex($table, $name, $fields, array $spec)

I already published the driver on Drupal.org (https://www.drupal.org/project/sqlsrv).

You can see that the latest commit has this issue fixed and the method has the correct signature.

http://cgit.drupalcode.org/sqlsrv/tree/drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php?id=28c5fef

(line 1601)

david-garcia-garcia avatar Aug 14 '15 07:08 david-garcia-garcia

Got any troubles to repro the issue? The latest dev from drupal.org should be working flawlessly to get past install.

https://www.drupal.org/project/sqlsrv

david-garcia-garcia avatar Aug 20 '15 13:08 david-garcia-garcia

Hi Davvid,

I was out in a family trip until Sunday. I’m back to work today. Before going out, I set up the whole environment, but I could not run the test successfully.

It just do not run. I did not have time to investigate the issue, which I’m planning to do today.

I’ll let you know.

From: Davvid [mailto:[email protected]] Sent: Thursday, August 20, 2015 6:44 AM To: Azure/msphpsql [email protected] Cc: Luiz Fernando Santos [email protected] Subject: Re: [msphpsql] SQLSTATE[HY010]: [Microsoft][ODBC Driver Manager] Function sequence error (again) (#49)

Got any troubles to repro the issue? The latest dev from drupal.org should be working flawlessly to get past install.

https://www.drupal.org/project/sqlsrvhttps://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fwww.drupal.org%2fproject%2fsqlsrv&data=01%7c01%7clfsantos%40microsoft.com%7caed3e59f63794c02353b08d2a9657296%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=G9VWBWYBpYx6HtsGAo0dJBFtrDpCdqegOSBsoetFqOg%3d

— Reply to this email directly or view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fgithub.com%2fAzure%2fmsphpsql%2fissues%2f49%23issuecomment-133011874&data=01%7c01%7clfsantos%40microsoft.com%7caed3e59f63794c02353b08d2a9657296%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=YHIlHM4SOlCokQLg5GA6IFMARt%2fCJtLMHMNWUuFnkPU%3d.

Lfsantos avatar Sep 01 '15 16:09 Lfsantos

I verified that this is still reproducible on lateset dev of driver and core.

It just do not run

That is weird, at least you should be seeing an error of some sort. I've sometimes experienced the progress bar getting stuck forever, but those bugs were already fixed.

david-garcia-garcia avatar Sep 03 '15 02:09 david-garcia-garcia

That was exactly the behavior I’ve got.

I’ll continue investigating on my end.

Thanks

From: Davvid [mailto:[email protected]] Sent: Wednesday, September 2, 2015 7:06 PM To: Azure/msphpsql [email protected] Cc: Luiz Fernando Santos [email protected] Subject: Re: [msphpsql] SQLSTATE[HY010]: [Microsoft][ODBC Driver Manager] Function sequence error (again) (#49)

I verified that this is still reproducible on lateset dev of driver and core.

It just do not run

That is weird, at least you should be seeing an error of some sort. I've sometimes experienced the progress bar getting stuck forever, but those bugs were already fixed.

— Reply to this email directly or view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fgithub.com%2fAzure%2fmsphpsql%2fissues%2f49%23issuecomment-137301281&data=01%7c01%7clfsantos%40microsoft.com%7cebe800f891614c31d06508d2b4044817%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=uvwgyq5Qcho6vWQNwUmYo7BIzX6YT5onop7xVhDlFrY%3d.

Lfsantos avatar Sep 03 '15 17:09 Lfsantos

I just posted a repro script for another issue in #50.

I have the feeling that both #49 and #50 might be the same thing as they both seem to exhibit themselves when a PDO exception is thrown (and managed by the user!) while inside a transaction.

So it might be worth taking a look at #50 first given that it is an "easy" stand alone single file repro script.

david-garcia-garcia avatar Sep 04 '15 15:09 david-garcia-garcia

I sent it to my team for investigation.

As soon as they find something, I'll reply back to you.

Sent from my iPad

On Sep 4, 2015, at 8:52 AM, Davvid <[email protected]mailto:[email protected]> wrote:

I just posted a repro script for another issue in #50https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fgithub.com%2fAzure%2fmsphpsql%2fissues%2f50&data=01%7c01%7clfsantos%40microsoft.com%7c26ca8d5cc4c24e91a81608d2b540c531%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=LJ03hTOp1NdUUt2R1%2bR0fIG5FuaAkGNRbTDkXNFjwQ8%3d.

I have the feeling that both #49https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fgithub.com%2fAzure%2fmsphpsql%2fissues%2f49&data=01%7c01%7clfsantos%40microsoft.com%7c26ca8d5cc4c24e91a81608d2b540c531%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=18fJyDJ3C7%2f210IE6MCGM3Qu7Tp3VDaaZpr6zLk6Uls%3d and #50https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fgithub.com%2fAzure%2fmsphpsql%2fissues%2f50&data=01%7c01%7clfsantos%40microsoft.com%7c26ca8d5cc4c24e91a81608d2b540c531%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=LJ03hTOp1NdUUt2R1%2bR0fIG5FuaAkGNRbTDkXNFjwQ8%3d might be the same thing as they both seem to exhibit themselves when a PDO exception is thrown (and managed by the user!) while inside a transaction.

So it might be worth taking a look at #50https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fgithub.com%2fAzure%2fmsphpsql%2fissues%2f50&data=01%7c01%7clfsantos%40microsoft.com%7c26ca8d5cc4c24e91a81608d2b540c531%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=LJ03hTOp1NdUUt2R1%2bR0fIG5FuaAkGNRbTDkXNFjwQ8%3d first given that it is an "easy" stand alone single file repro script.

Reply to this email directly or view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fgithub.com%2fAzure%2fmsphpsql%2fissues%2f49%23issuecomment-137774580&data=01%7c01%7clfsantos%40microsoft.com%7c26ca8d5cc4c24e91a81608d2b540c531%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=eoeDFNBhL2S8RZ2F9g0qIo%2bNjY%2f67inihRoRnjziyp8%3d.

Lfsantos avatar Sep 04 '15 15:09 Lfsantos