[MXS-2490] Unknown prepared statement handler (0) given to mysqld_stmt_execute Created: 2019-05-15 Updated: 2021-01-25 Resolved: 2019-06-24 |
|
| Status: | Closed |
| Project: | MariaDB MaxScale |
| Component/s: | readwritesplit |
| Affects Version/s: | 2.3.6 |
| Fix Version/s: | 2.3.9, 2.3.10 |
| Type: | Bug | Priority: | Major |
| Reporter: | balyn | Assignee: | markus makela |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | asterisk, mariadb, maxscale, odbc, unixODBC | ||
| Environment: |
Scheme: App: MaxScale: Master: Slave: |
||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Description |
| Comments |
| Comment by markus makela [ 2019-06-10 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
An improved error message will be logged in 2.3.8. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by markus makela [ 2019-06-20 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Managed to reproduce this and it seems this can happen when a statement is retried when it fails. If this is the same problem, it'll be fixed in 2.3.9. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by markus makela [ 2019-06-24 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Tentatively closing this as fixed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by George Diamantopoulos [ 2019-07-05 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Unfortunately I'm having the exact same issue balyn reported with version 2.3.9 as well. If it helps, this seems to happen when asterisk is configured with ODBC and the driver used is mariadb-connector-odbc 3.1.1 but not (or at least not right away after starting asterisk) when the driver used is libmyodbc 5.1.10-3. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by George Diamantopoulos [ 2019-07-05 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I've just tried with latest Oracle libmyodbc binary available for jessie (5.3.13) and was UNable to reproduce the issue. Could this be a problem with mariadb's libmaodbc instead, I wonder? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by balyn [ 2019-07-06 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I would appreciate if Assignee try to reproduce it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by markus makela [ 2019-07-07 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Did the MaxScale log have any errors or warnings? MaxScale 2.3.9 should reply with a different error if the client sent an unknown prepared statement handle. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by George Diamantopoulos [ 2019-07-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Here's the output from 2.3.9 (some lines skipped, indicated by ellipsis):
And here's the same event as logged by 2.3.8:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by markus makela [ 2019-07-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for the logs, this clarifies the situation. It looks like the client is using a statement ID that is either not in use or was not returned from the same MaxScale session. gedia if you could confirm that this does not happen with the Oracle ODBC connector, then we know that there's something odd going on with the MariaDB ODBC connector and MaxScale. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by markus makela [ 2019-07-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Can you try if adding version_string=10.1.14-MariaDB to all the services helps? We suspect that some of the problems might be due to direct execution of prepared statements. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by George Diamantopoulos [ 2019-07-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I've just performed a test with version_string=10.1.14-MariaDB set for the readwritesplit service and it doesn't seem to make a difference. Out of curiosity, how does the version string affect direct execution? And yes, I can confirm that this issue does not manifest when using Oracle's ODBC connector for mysql, at least with the versions mentioned in my previous posts. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by markus makela [ 2019-07-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The MariaDB ODBC connector uses a special command to speed up prepared statement execution by using what is referred to as direct execution. As support for it was added in MariaDB 10.2.2, using a version string lower than this should prevent it from being used but it appears at least some of the errors are not caused by this. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by markus makela [ 2019-07-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The fix to this will prevent the error with the exact ID of 4294967295. The other errors are still not resolved which means more investigation is needed. Just to be sure, could you check whether this particular error disappeared from the log after adding the version_string?
If it's possible, can you also add log_info=1 under the maxscale section to enable verbose logging? This would be very helpful in figuring out what is happening in the code. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by George Diamantopoulos [ 2019-07-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Unfortunately the ID you mentioned still produces errors with custom version_string:
I'm attaching logs produced with log_info and version_string. Some irrelevant output has been trimmed, hostnames, IPs and usernames have been masked. Let me know if I can be of any further assistance. Thanks! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by markus makela [ 2019-07-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Looks like there's some invalid SQL that is assumed to work:
The connector seems to use the statement ID 0 to close a prepared statement that didn't succeed in the first place. Lawrin georg Does this make any sense to you or could it be a problem in Asterisk itself? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by markus makela [ 2019-07-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
gedia Can you get any information about the version string from the Asterisk side? Confirming that MaxScale indeed sends the correct version string would help. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by George Diamantopoulos [ 2019-07-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Here's the relevant packet captured over the network. Version gets "5.5.5-" prepended as per version_string documentation:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Lawrin Novitsky [ 2019-07-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
markus makela Now that looks like high chances to be a problem on my side. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Lawrin Novitsky [ 2019-07-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
And what is the server version. The query does not fail with latest MariaDB | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by markus makela [ 2019-07-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by George Diamantopoulos [ 2019-07-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Installed locally along with asterisk from official mariadb repos for jessie:
mariadb-connector-odbc is version 3.1.1 and the package was built locally, which must have pulled libmariadb @ 2c5aebb for compilation. cmake was configured with:
The backends are all on 10.3.16 on debian buster from official mariadb repos. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Lawrin Novitsky [ 2019-07-15 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Would it be possible to provide ODBC trace for the issue? Because I could not repeat the issue. Nor could I find in the source code any possible scenario leading to it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by George Diamantopoulos [ 2019-07-16 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for the follow-up. I've managed to get a trace, is there any way I can send it to you privately? This is on a development platform of course, but just to be safe that there isn't any privileged information exposed publicly... I also noticed there's a relevant commit in the 2.3 tree of Maxscale: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by markus makela [ 2019-07-16 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
You can find the daily build here: http://max-tst-01.mariadb.com/ci-repository/?C=M;O=D | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by George Diamantopoulos [ 2019-07-18 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hm, it seems there are no daily builds for debian. Is the debian source package available somewhere so that I can built my own package for testing? Thanks. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by markus makela [ 2019-07-18 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
You can find the instructions to build MaxScale from source here: https://github.com/mariadb-corporation/MaxScale/blob/2.3/Documentation/Getting-Started/Building-MaxScale-from-Source-Code.md | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by George Diamantopoulos [ 2019-07-24 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
OK, so I have a few updates. However, please note that these results were produced on systems different than the ones from my previous reports. Previous reports:
New Test 1:
Results: Similar behaviour is seen as with previous reports. Upon starting asterisk, the following was logged. As there didn't seem to be an improvement over the previous setups, I didn't perform any other tests other than starting asterisk.
New Test 2 - Same configuration as New Test 1 but:
Results: Upon starting asterisk, no errors or warnings are logged this time on the maxscale node. However, the following is logged upon call completion. Despite these warnings in Maxscale logs, functionality does not seem to be affected (calls are setup properly and CDRs are written successfully in MariaDB):
Note that this time, only warnings about prepared statements with ID '0' seem to be logged. Let me know if I can be of any further assistance. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by markus makela [ 2019-07-24 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
A big thanks for doing all the testing! It looks like the newer versions fix almost all the problems and if I had to guess I'd say the ID 0 issue could possibly be caused by the ODBC connector. Lawrin what does the ODBC connector use when closing a statement that used the ID -1? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Lawrin Novitsky [ 2019-07-24 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
markus makela The thing is that c/odbc does not deal with stmts id directly at all. It uses MariaDB C/C via C API functions. It may be that it erroneously closes stmt handler. But even in this case I am not sure who should handle that - c/c or c/odbc. I don't mind to fix it on my end, though | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by George Diamantopoulos [ 2019-08-16 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@Lawrin It seems ODBC connector 3.1.3 behaves the same as 3.1.2 in this regard (case: on buster with asterisk 16). Should I file a bug with the C/Connector project? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Lawrin Novitsky [ 2019-08-19 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
gedia Which exactly issue are we talking about here? If about closing of stmt with stmt_id=0, then iirc it wasn't supposed to be in 3.1.3, as the C/C release was finalized by then. Filing the bug won't hurt, but I can do that. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by balyn [ 2019-08-20 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hello. For some reasons, I could not make more diagnostics after mine first post, sorry. So now, when I try to connect Asterisk 16.3 with MaxScale 2.3.11-1, I get some new log messages. As a result, I get this warns+error and no new line in the db:
After that I put "use_sql_variables_in=master" in [splitter] section, so warns changed and I have new record in the db:
For now, I will make some tests to be sure read-writesplitting works well. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by George Diamantopoulos [ 2019-09-05 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@balyn The warnings you get after having set "use_sql_variables_in=master" do not indicate an issue with Maxscale. It seems that this is an issue with Connector/C which you can follow here: https://jira.mariadb.org/browse/CONC-435 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Diego Dupin [ 2021-01-25 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
this might be due to https://jira.mariadb.org/browse/CONC-522 |