[CONC-594] Non blocking api appears to be blocking for secure connections Created: 2022-05-23 Updated: 2023-07-17 |
|
| Status: | Open |
| Project: | MariaDB Connector/C |
| Component/s: | None |
| Affects Version/s: | 3.1.12 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Vladislav Vaintroub | Assignee: | Georg Richter |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
From https://mariadb.com/kb/en/non-blocking-api-appears-to-be-blocking-for-secure-connections/ I am encountering delays when using secure connections to AuroraDB, and wondering if the client lib (C-connector) is making lengthy system calls. Here is a callstack when not connected (and want to connected):
and callstack when already connected:
Using a more recent version (3.2.6) did not make a difference. |
| Comments |
| Comment by Georg Richter [ 2022-05-25 ] | |||||||||||||||||||||||||||||||
|
Is there a difference when not using init_command option? | |||||||||||||||||||||||||||||||
| Comment by Jacob [ 2022-12-12 ] | |||||||||||||||||||||||||||||||
|
Removing the use of init_command option appears to have resolved the blocking occurring from 'mysql_real_connect_start_internal'; however, when testing DB failover failure (by having a read slave become unresponsive) the mysql_ping_start_internal still appears to have the same unexpected blocking behavior. | |||||||||||||||||||||||||||||||
| Comment by Jacob [ 2023-01-03 ] | |||||||||||||||||||||||||||||||
|
Hi Georg(georg@mariadb.com) I managed to reproduce several related issues that were causing SSL implementation to block the main thread with async connections. I have made hopefully minimal code changes to address these and have validated that the issues are now all resolved. I am attaching a patch One note, among the issues I have identified/fixed with my patch was a double free that appears to have been since fixed in mainline: https://github.com/mariadb-corporation/mariadb-connector-c/commit/da9bb98c0cef8097ee50341722f08d5042efbe49. That said, I believe that my fix may be more robust than the solution above, so I am still including it. | |||||||||||||||||||||||||||||||
| Comment by Jacob [ 2023-01-03 ] | |||||||||||||||||||||||||||||||
|
In case it's helpful I am including the steps I use to apply the patch to the 3.3.3 version of the MariaDB C client library.
| |||||||||||||||||||||||||||||||
| Comment by Georg Richter [ 2023-01-03 ] | |||||||||||||||||||||||||||||||
|
Hi Jacob, thanks for your contribution would it be possible to open a PR on github for your patch? Thanks! /Georg | |||||||||||||||||||||||||||||||
| Comment by Jacob [ 2023-01-03 ] | |||||||||||||||||||||||||||||||
|
Hi Georg Unfortunately I haven't got a GitHub account setup yet. Is it required to have the patch considered for inclusion? If so, I'll schedule time to setup an account/fork the branch and go through the steps of creating a proper pull request. | |||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2023-01-04 ] | |||||||||||||||||||||||||||||||
|
No, it's not required, we can apply a patch too. PRs help to provide proper attribution though (you'll be shown as an author). | |||||||||||||||||||||||||||||||
| Comment by Jacob [ 2023-01-09 ] | |||||||||||||||||||||||||||||||
|
I created a pull request: https://github.com/mariadb-corporation/mariadb-connector-c/pull/211 but it seems to have failed a newly added unit test. However, when I ran the test locally with my changes it passes. The error reported in the unit test: https://app.travis-ci.com/github/mariadb-corporation/mariadb-connector-c/jobs/592736627
Seems to indicate that this code is triggering:
One thing I am not clear about is why does returning ret != NULL constitute an error in this case when the purpose of the test is to validate connection failure? Probably it would also be good to report the mysq_errno(&mysql) in this case so that it can be determined what precisely is failing. | |||||||||||||||||||||||||||||||
| Comment by Jacob [ 2023-01-10 ] | |||||||||||||||||||||||||||||||
|
Hi Georg, I have managed to address the above issues of failing async.c unit test when run by the travis pipeline. Seems like the usage of 0.0.0.0 IP was causing the connection to succeed due to there being a locally hosted mysql instance that was being successfully connected to, which caused the test to fail to err... fail to connect. Anyhow by changing the ip to 1.2.3.4 it started passing (sort of) I actually had to reduce the number of iterations from 100 to 10 since 100 iterations was running really close to the 180s of running time in travis for some reason. I cannot repro such a long running time locally either for this test. Anyhow there is now still one remaining unit test issue that I cannot seem to repro locally, this time in connection.c unit test: test_auth256 Details are in this pull request but the errors are a bit confusing to me:
It looks like the mysql 5.7 and 8.0 versions of these tests are the only ones failing, but when I run it locally against 5.7.40 MYSQL server it passes for me. Would you be able to take a look and let me know if this test passes without my changes? | |||||||||||||||||||||||||||||||
| Comment by Jacob Cossairt [ 2023-07-17 ] | |||||||||||||||||||||||||||||||
|
Hi Georg, Just following up on the status of this. It would be great to get the changes from the other Jacob ( https://github.com/mariadb-corporation/mariadb-connector-c/pull/216 ) included in a future version. |