Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
david-garcia-garcia opened this issue May 4, 2015 · 33 comments

Comments

@david-garcia-garcia
Copy link

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
Copy link
Author

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.

@meet-bhagdev
Copy link
Contributor

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.

@david-garcia-garcia
Copy link
Author

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
Copy link
Author

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.

@Lfsantos
Copy link

I’d love to take a look at this.

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

Thanks

From: Davvid [mailto:notifications@github.com]
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//issues/49#issuecomment-122886221.

@david-garcia-garcia
Copy link
Author

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
Copy link
Author

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.

@Lfsantos
Copy link

Lfsantos commented Aug 5, 2015

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 <notifications@git.luolix.topmailto:notifications@github.com> 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//issues/49#issuecomment-127882620.

@david-garcia-garcia
Copy link
Author

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
Copy link
Author

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.

@Lfsantos
Copy link

Lfsantos commented Aug 6, 2015

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

I’ll keep you posted

From: Davvid [mailto:notifications@github.com]
Sent: Thursday, August 6, 2015 10:57 AM
To: Azure/msphpsql msphpsql@noreply.github.com
Cc: Luiz Fernando Santos lfsantos@microsoft.com
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//issues/49#issuecomment-128458978.

@Lfsantos
Copy link

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:notifications@github.com]
Sent: Thursday, August 6, 2015 10:57 AM
To: Azure/msphpsql msphpsql@noreply.github.com
Cc: Luiz Fernando Santos lfsantos@microsoft.com
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//issues/49#issuecomment-128458978.

@Lfsantos
Copy link

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 <lfsantos@microsoft.commailto:lfsantos@microsoft.com>
Date: Tuesday, August 11, 2015 at 10:09 PM
To: Azure/msphpsql <reply@reply.git.luolix.topmailto:reply@reply.github.com>, Azure/msphpsql <msphpsql@noreply.git.luolix.topmailto:msphpsql@noreply.github.com>
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:notifications@github.com]
Sent: Thursday, August 6, 2015 10:57 AM
To: Azure/msphpsql <msphpsql@noreply.git.luolix.topmailto:msphpsql@noreply.github.com>
Cc: Luiz Fernando Santos <lfsantos@microsoft.commailto:lfsantos@microsoft.com>
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//issues/49#issuecomment-128458978.

@david-garcia-garcia
Copy link
Author

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
Copy link
Author

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

@Lfsantos
Copy link

Lfsantos commented Sep 1, 2015

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:notifications@github.com]
Sent: Thursday, August 20, 2015 6:44 AM
To: Azure/msphpsql msphpsql@noreply.github.com
Cc: Luiz Fernando Santos lfsantos@microsoft.com
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%2fgit.luolix.top%2fAzure%2fmsphpsql%2fissues%2f49%23issuecomment-133011874&data=01%7c01%7clfsantos%40microsoft.com%7caed3e59f63794c02353b08d2a9657296%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=YHIlHM4SOlCokQLg5GA6IFMARt%2fCJtLMHMNWUuFnkPU%3d.

@david-garcia-garcia
Copy link
Author

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.

@Lfsantos
Copy link

Lfsantos commented Sep 3, 2015

That was exactly the behavior I’ve got.

I’ll continue investigating on my end.

Thanks

From: Davvid [mailto:notifications@github.com]
Sent: Wednesday, September 2, 2015 7:06 PM
To: Azure/msphpsql msphpsql@noreply.github.com
Cc: Luiz Fernando Santos lfsantos@microsoft.com
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%2fgit.luolix.top%2fAzure%2fmsphpsql%2fissues%2f49%23issuecomment-137301281&data=01%7c01%7clfsantos%40microsoft.com%7cebe800f891614c31d06508d2b4044817%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=uvwgyq5Qcho6vWQNwUmYo7BIzX6YT5onop7xVhDlFrY%3d.

@david-garcia-garcia
Copy link
Author

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.

@Lfsantos
Copy link

Lfsantos commented Sep 4, 2015

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 <notifications@git.luolix.topmailto:notifications@github.com> wrote:

I just posted a repro script for another issue in #50https://na01.safelinks.protection.outlook.com/?url=https%3a%2f%2fgit.luolix.top%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%2fgit.luolix.top%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%2fgit.luolix.top%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%2fgit.luolix.top%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%2fgit.luolix.top%2fAzure%2fmsphpsql%2fissues%2f49%23issuecomment-137774580&data=01%7c01%7clfsantos%40microsoft.com%7c26ca8d5cc4c24e91a81608d2b540c531%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=eoeDFNBhL2S8RZ2F9g0qIo%2bNjY%2f67inihRoRnjziyp8%3d.

@agrarian
Copy link

I am also getting the [Microsoft][ODBC Driver Manager] Function sequence error.

$q = "SELECT * FROM ".TBL_USERS." WHERE username = '$username'"; $stmt = sqlsrv_query($this->connection, $q, array(),array( "Scrollable" => 'static' )); if(!$stmt || (sqlsrv_num_rows($stmt) < 1)){ error_log("getUserInfo failed for $username: $q",3,'error.log'); sqlsrv_free_stmt($stmt); return NULL; } else { /* Return result array */ sqlsrv_next_result($stmt); $dbrow = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC); if($dbrow === false) { error_log("dbrow is false\n",3,"error.log"); if( ($errors = sqlsrv_errors() ) != null) { foreach( $errors[0] as $key=>$error ) { error_log("$key -> $error\n",3,"error.log"); } } } elseif (is_null($dbrow)){ error_log("dbrow is NULL\n",3,"error.log"); } else { error_log("dbrow is OK\n",3,"error.log"); } }
It appears whenever I call the sqlsrv_fetch_array function.

@meet-bhagdev
Copy link
Contributor

@agrarian What version of driver are you using?

@agrarian
Copy link

v4.0.1https://github.com/Azure/msphpsql/releases/tag/v4.0.1

Terry

From: Meet Bhagdev [mailto:notifications@github.com]
Sent: Tuesday, March 15, 2016 3:14 PM
To: Azure/msphpsql msphpsql@noreply.github.com
Cc: Carnes, Terry (RTIS) Tcarnes@reedtech.com
Subject: Re: [msphpsql] SQLSTATE[HY010]: [Microsoft][ODBC Driver Manager] Function sequence error (again) (#49)

@agrarianhttps://github.com/agrarian What version of driver are you using?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHubhttps://github.com//issues/49#issuecomment-196979695

@yitam
Copy link
Contributor

yitam commented Mar 9, 2017

Hi @agrarian, I'm trying to understand your script. Why did you call sqlsrv_next_result() before sqlsrv_fetch_array()? Did you want to test for errors? If you drop sqlsrv_next_result() then there shouldn't be any problem.

Hi @david-garcia-garcia do you still have function sequence error problem? I looked at the other related issue #50 and your repro script is gone.

@rkevinburton
Copy link

I am getting this error:

[unixODBC][Driver Manager]Function sequence error

On both the 4.3.0 release of sqlsrv and 5.1.0 preview. I am running a different framework that is mostly mentioned here (CodeIgniter rather than Drupal). I am afraid I don't know where to look for the error. Is it an error in the framework, the driver, or unixOBDC? What is the bottom line as far as fixes or workarounds? Thank you.

@yitam
Copy link
Contributor

yitam commented Oct 10, 2017

Hello @rkevinburton
Function sequence error can be caused by various factors, so more info is required in addition to telling us you get this error. Therefore, please create a new issue by providing repro script(s), the platform and/or version of the SQL Server, etc. The more you provide the closer we can get to help answer your questions.

@rkevinburton
Copy link

rkevinburton commented Oct 10, 2017 via email

@yitam
Copy link
Contributor

yitam commented Oct 10, 2017

Hello @rkevinburton regrettably it's still a bit vague and we won't be able to reproduce the problem without a concrete repro scenario. For example, when you encountered this error were you doing a simple select, or update, or insert, with or without using stored procedure, transactions, etc.?

@rkevinburton
Copy link

rkevinburton commented Oct 10, 2017 via email

@yitam
Copy link
Contributor

yitam commented Oct 10, 2017

Thanks @rkevinburton. The problem likely lies in the file models/ion_auth_parent_model.php, line 1222, as indicated in the error message. Looks like something went wrong when trying to delete a certain user? I'm guessing that the user with id 685 and group 1 doesn't exist.

Please bring this problem to your application developers. FYI, function sequence error often occurs when ODBC functions are called out of the order required. You can check this page for different scenarios that caused HY010 error

@rkevinburton
Copy link

rkevinburton commented Oct 10, 2017 via email

@yitam
Copy link
Contributor

yitam commented Oct 10, 2017

@rkevinburton we cannot investigate further unless we have clear steps to reproduce the problems. I'd happily help when you can provide a repro. In your example above, the error is clearly specific to your application and how the class(es) work(s) underneath.

@david-puglielli
Copy link
Contributor

Closing due to inactivity. Please reopen if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants