[MXS-2597] MaxScale doesn't handle errors from microhttpd Created: 2019-07-11  Updated: 2020-01-08  Resolved: 2019-07-20

Status: Closed
Project: MariaDB MaxScale
Component/s: REST-API
Affects Version/s: 2.3.9
Fix Version/s: 2.2.22, 2.3.10, 2.4.1

Type: Bug Priority: Major
Reporter: Geoff Montee (Inactive) Assignee: markus makela
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MXS-2596 When log_info is enabled, MaxScale sh... Closed

 Description   

MaxScale uses microhttpd to implement the admin interface/REST API:

https://github.com/mariadb-corporation/MaxScale/blob/maxscale-2.3.9/server/core/admin.cc#L400

microhttpd allows an application to handle errors by setting an error handler by calling the MHD_set_panic_func function:

Function: void MHD_set_panic_func (MHD_PanicCallback cb, void *cls)
Set a handler for fatal errors.

cb
function to call if MHD encounters a fatal internal error. If no handler was set explicitly, MHD will call abort.

cls
closure argument for cb; the other arguments are the name of the source file, line number and a string describing the nature of the fatal error (which can be NULL)

https://www.gnu.org/software/libmicrohttpd/manual/html_node/microhttpd_002dinit.html

MaxScale doesn't seem to currently do this, so microhttpd error messages are lost. This can make problems with the admin interface more difficult to debug.



 Comments   
Comment by markus makela [ 2019-07-15 ]

Any suggestions on how to reproduce this?

Comment by Geoff Montee (Inactive) [ 2019-07-15 ]

Hi markus makela,

I noticed that microhttpd errors were not being printed when a MaxScale instance was not able to bind to the admin port during startup because another process was already using the port. In this case, I would have expected some kind of error message from microhttpd, but the MaxScale log only showed this:

Jul 11 13:57:06 maxscale1 maxscale[29995]: Failed to initialize admin interface

So if you want to reproduce this, then you could try setting admin_port to a port that MaxScale won't be able to bind to during startup.

https://mariadb.com/kb/en/mariadb-maxscale-23-mariadb-maxscale-configuration-usage-scenarios/#admin_port

Comment by markus makela [ 2019-07-15 ]

Thanks, that should be enough to allow me to reproduce and fix it.

Comment by markus makela [ 2019-07-16 ]

Adding the handler doesn't seem to help with the problem as it isn't a panic situation for the daemon.

Comment by markus makela [ 2019-07-16 ]

Seems that MHD_USE_DEBUG must be passed in the flags to actually produce error messages for the custom logger installed with MHD_OPTION_EXTERNAL_LOGGER.

Generated at Thu Feb 08 04:15:18 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.