[MDEV-24357] Connect REST API is not working for ubuntu when installed from package and WITH_SSL=bundled Created: 2020-12-07 Updated: 2023-01-19 Resolved: 2021-01-12 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Configuration, Storage Engine - Connect |
| Affects Version/s: | 10.2.36, 10.3.27, 10.4.17, 10.5.8 |
| Fix Version/s: | 10.2.37, 10.3.28 |
| Type: | Bug | Priority: | Major |
| Reporter: | Anel Husakovic | Assignee: | Olivier Bertrand |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | foundation | ||
| Environment: |
ubuntu 18.04 |
||
| Attachments: |
|
||||||||||||
| Issue Links: |
|
||||||||||||
| Description |
|
CONNECT SE is a powerful SE which has a feature of using REST queries for creating/querying the tables as can be found in KB - CONNECT rest queries.
Building the ha_connect.so results in no statically linked libcpprest.
Based on search procedure of cmake find_package as stated here we are ending in the result found in CMakeCache.txt in builddir:
One way to do so is to find distro version ( I couldn't find right regex from cmake --system-information|grep CMAKE_SYSTEM ) and use lsb_release. That is suggested in the patch. However another problem is that this will not work when WITH_SSL=bundled (or if we are using wolfssl.
In order to solve this easiest solution is to use WITH_SSL=system.
|
| Comments |
| Comment by Anel Husakovic [ 2020-12-07 ] | ||||||||||||||||||||||||||||||
|
bertrandop can you please review the patch 889e14fbcc12bc4. | ||||||||||||||||||||||||||||||
| Comment by Olivier Bertrand [ 2020-12-09 ] | ||||||||||||||||||||||||||||||
|
I cannot because having no more Linux machine home where I am confined. | ||||||||||||||||||||||||||||||
| Comment by Anel Husakovic [ 2020-12-10 ] | ||||||||||||||||||||||||||||||
|
Cool, looking forward to see the curl usage in the new Connect version. | ||||||||||||||||||||||||||||||
| Comment by Olivier Bertrand [ 2020-12-11 ] | ||||||||||||||||||||||||||||||
|
The big question is how can we synchronize that you do and what I do? | ||||||||||||||||||||||||||||||
| Comment by Olivier Bertrand [ 2021-01-07 ] | ||||||||||||||||||||||||||||||
|
[Anel Husakovic]: I looked into your patch 889e14fbcc12bc4 but did not include it yet in the new version of CMakeLists.txt because I think it needs to be edited. There are double if's (IF (UNIX) just following another IF (UNIX) or lines such as:
inside an IF (cpprestsdk FOUND), meaning that it is always true. | ||||||||||||||||||||||||||||||
| Comment by Anel Husakovic [ 2021-01-07 ] | ||||||||||||||||||||||||||||||
|
Hi bertrandop, thanks for looking into my patch. | ||||||||||||||||||||||||||||||
| Comment by Olivier Bertrand [ 2021-01-10 ] | ||||||||||||||||||||||||||||||
|
@Anel Husakovic: I tried to include your patch but I was obliged to remove it.
executes the code inside the IF even if cpprestsdk is not found and causes a compile error. | ||||||||||||||||||||||||||||||
| Comment by Anel Husakovic [ 2021-01-10 ] | ||||||||||||||||||||||||||||||
|
bertrandop yes it fails and it should we expect that to happen, right?
Previously compilation worked but ha_connect.so was built without statically linked libcpprest.so what wasn't correct and without any hints what was wrong.
By default, when running from source WITH_SSL is bundled which is not working (you have in description error that are raised) so one need to change that also, I used system instead. | ||||||||||||||||||||||||||||||
| Comment by Anel Husakovic [ 2021-01-10 ] | ||||||||||||||||||||||||||||||
|
Hi bertrandop I changed a bit the patch.
Note 1: Without libcpprest.so found, we got the following compile error (and we should):
With libcpprest.so found we got statically linked library:
Let me know if you are ok with this patch. | ||||||||||||||||||||||||||||||
| Comment by Olivier Bertrand [ 2021-01-11 ] | ||||||||||||||||||||||||||||||
|
Because compiling ha_connect.so (or dll) must be ok whether or not cpprestsdk is available, I choose to dynamically link it. However, to simplify the way it is done, CONNECT does not dynamically links to the cpprestsdk lib but to the intermediate lib GetRest, as explained in Appendix B of the CONNECT documentation. This reduces to only one Function address to be set when linking to GetRest (which is itself statically linked to cpprestsdk) As a matter of fact, almost all the part of the CMakeLists.txt file we are discussing is just that when compiling MariaDB from source, it also permits to include GetRest into CONNECT, which then becomes statically linked to cpprestsdk. But of course this works only if the package is available. However, this is not required and the CMakeLists.txt part of REST could be just reduced to:
This maybe is what should just be done, in particular on Ubuntu, if it causes problems. Then, CONNECT compiled from source would work like binary distributions, meaning that separately making the GetRest.so would have to be still done, and perhaps in a way specific to Ubuntu. Note that all this will be just another option in future versions because I have tested on buildbot that REST works without cpprestsdk providing cURL is available, which seems to be the case on almost all systems. | ||||||||||||||||||||||||||||||
| Comment by Anel Husakovic [ 2021-01-11 ] | ||||||||||||||||||||||||||||||
|
Dear bertrandop, Let me go through examples to show you:
Scenario 2 - uninstall libcpprest-dev package and try dynamically call Getrest.so
Conclusions
Looking forward to your reply and review. | ||||||||||||||||||||||||||||||
| Comment by Olivier Bertrand [ 2021-01-12 ] | ||||||||||||||||||||||||||||||
|
Thank you for working on this. I am sure it works like you describe. Nevertheless, I will take the opposite decision and completely remove the possibility of compiling a statically linked to cpprestsdk version of Connect. The new version of CMakeLists.txt will just contain:
The reason why? Allowing to compile a version of Connect statically linked to cpprestsdk was actually a temporary tool allowing to test REST on early versions of connect having no other mean to do it and should have been already removed. Indeed, an engine module, such as Connect, must be loadable by all means and therefore, never be dependent on an external product. This was already true for Java and JBDC and must be also true for REST. Don't forget that compiling a version is not only to use it locally but more generally to make a distribution (see Creating a Debian Repository) Even your module will work locally, not only it won't if you export it to another machine without cpprestsdk, but it will not load at all, making it useless even for those not using REST. Furthermore, cpprestsdk is not mandatory anymore, most future versions will use curl instead and curl seems to be available on almost all systems. So what you should do now (the version you have is not able to use curl) is to use REST the way it is described in appendix 2 and see if you have any trouble when compiling the external GetRest.so lib on Ubuntu. Thanks for your understanding. | ||||||||||||||||||||||||||||||
| Comment by Anel Husakovic [ 2021-01-12 ] | ||||||||||||||||||||||||||||||
|
Ok, I see what you mean, I just lost a lot of time and found out this problem related to my environment. I don't know what do you mean by appendix 2 - I gues this link? Please take a look other part of the patch and let me know is it acceptable, not related to static linkage, but rather to WITH_SSL option:
Do you want me to help regarding cURL development? | ||||||||||||||||||||||||||||||
| Comment by Olivier Bertrand [ 2021-01-12 ] | ||||||||||||||||||||||||||||||
|
I don't anything about that SSL stuff. Do you think it is important? Perhaps it could be wrong by preventing Connect to generate the _tabrest _ table type that could work anyway with CURL, and is harmless when not using REST. I have attached the new _tabrest _files. Maybe you can look at the way I call CURL in the Xcurl function. I did not know how to execute an external program and found this looking in the NET but there maybe a more appropriate way to do it. Perhaps also, replacing manually them in the source, you can test using REST via CURL. | ||||||||||||||||||||||||||||||
| Comment by Anel Husakovic [ 2021-01-18 ] | ||||||||||||||||||||||||||||||
|
When we use with_ssl=bundled we got compilation error. We have to disable this. | ||||||||||||||||||||||||||||||
| Comment by Olivier Bertrand [ 2021-01-18 ] | ||||||||||||||||||||||||||||||
|
There is nothing specific in the four files added when REST is ON that can explain a compilation error related to SSL. Unless something is found showing the contrary, and in this case that is the file itself that must be fixed to avoid it, no patch should be applied here. |