2025 Commits

Author SHA1 Message Date
Markus Mäkelä
e0ad6188ad Add module parameter options
The options allow the modules to impose type specific restrictions on the
parameters. This can be used to offload file permission and mandatory
parameter checks to the core.
2017-01-05 10:48:58 +02:00
Markus Mäkelä
5a290cb0b8 Use module parameters in monitors
All monitors now declare the parameters that they use. This allows the
core to check the validity of the parameters before they are passed to the
monitor. It also simplifies the processing of the parameters as they are
guaranteed to be valid.
2017-01-05 09:58:11 +02:00
Markus Mäkelä
cefc253e2c Check configuration with declared parameters
The declared parameters are now used to check whether the configuration is
valid. As the filters and monitors don't use the new declarations, the
code needs to be commented out. Once the parameter processing has been
migrated to the new system, the code can be enabled.
2017-01-05 09:58:10 +02:00
Markus Mäkelä
f7c6accaa0 Load default configuration values for modules
Filters, monitors and routers can now declare parameters and those
parameters will always be present. Currently, this removes the need to
parse simple values like booleans and integers.

Some of the more common parameter types could be added in the future
e.g. paths to files.
2017-01-05 09:58:10 +02:00
Markus Mäkelä
241dbb464a Add framework for declaration of module parameters
The MXS_MODULE structure now contains a member for parameters. This can be
used by the modules to declare accepted parameters, their types and the
default values. Currently only count, integer, boolean, string and enum
values are supported.
2017-01-05 09:58:10 +02:00
Johan Wikman
83eddabebc Add missing newline 2017-01-04 10:53:21 +02:00
Markus Mäkelä
33d98830dd Provide read-only access to loaded modules
The MXS_MODULE structure of each module is now globally exposed by the
`get_module` function. This allows the module information of any module to
be queried.

This information can then be used to validate various things but the main
goal is to provide a way for modules to declare accepted parameters in the
MXS_MODULE structure. This will be done in a later commit.

Also the function documentation is now in the header file. This should
make it easier to read.
2017-01-04 07:39:47 +02:00
Markus Mäkelä
0215ad32a1 Fix double declaration of _XOPEN_SOURCE
The adminusers.c file declared it twice; first explicitly and then
implicitly by including cdefs.h.
2017-01-04 05:55:55 +02:00
Markus Mäkelä
66430a3584 Fix persisted monitors not working
This prevented persisted monitors from being deleted after a restart.
2017-01-03 20:18:15 +02:00
Markus Mäkelä
c96bd64aa8 Rename MODULE_INFO to MXS_MODULE
The MODULE_INFO is now the main object which is used by modules to convey
information to the MaxScale core. The MXS_MODULE name is more apt as it
now contains the actual module definition.

The old MODULES structure was moved into load_utils.c as an internal
implementation and was renamed so that it is not confused with the new
MODULE structure.
2017-01-03 18:01:14 +02:00
Markus Mäkelä
b00e0328d5 Create a macro for module declarations
The modules are now declared with a common macro. This allows future
additions to the module loading process while also making the loaded
symbol name a constant.
2017-01-03 18:01:13 +02:00
Markus Mäkelä
ae0577c695 Move module object inside MODULE_INFO
This allows modules to only expose one entry point with a consistent
signature. In the future, this could be used to implement declarations of
module parameters.
2017-01-03 18:01:13 +02:00
Markus Mäkelä
6c53999c97 Combine ModuleInit and GetModuleObject
The two functions can be combined into one as both are called only
once. This removes the need for the explicit ModuleInit function.
2017-01-03 18:01:13 +02:00
Markus Mäkelä
7df29aa1ec Move version entry point into MODULE_INFO
The MODULE_INFO can easily hold the version information of the
module. This removes the need for a explicit version entry point.
2017-01-03 18:01:13 +02:00
Markus Mäkelä
d3907882d6 Clean up the module handling functions
Cleaned up the loading and unloading of modules. Declared variables closer
to where they are used.
2017-01-03 18:01:13 +02:00
Johan Wikman
78928dc575 Make session_[getUser|get_remote] const correct
- Rename session_getUser to session_get_user
- Change session_get_user and session_get_remote to take a const
  SESSION* as argument and to return a const char*.
- Change server_get_persistent, so that user is passed as const.
- Update all users of these functions as appropriate.
2017-01-02 16:16:37 +02:00
Johan Wikman
18008dec6d Rename mxs_mysql_account_to_pcre
The function is not capable of doing the right thing for an entire
account string, but only separately for user and host names, so the
function name should reflect that.
2016-12-29 11:47:08 +02:00
Johan Wikman
997bec868f Move transforming function to common place
Move function for converting a MySQL account string to an
equivalent PCRE one, from Cache's rules.cc to mysql_utils.
2016-12-29 11:09:06 +02:00
Johan Wikman
c6e155cf2b Move quote triming function to common place
Function for removing MySQL quote characters surrounding a
string moved from Cache's rules.cc to common place and renamed.

The function was now moved to mysql_utils.[h|c], which is in
maxscale-common, and not to the perhaps more appropriate place
protocol/mysql.h, as the latter would have implied that MySQLCommon
would have to be linked to, which actually might be the right thing
to do. However, that has to wait until protocol/mysql.h gets an
overhaul.
2016-12-29 11:09:06 +02:00
Johan Wikman
b40872e600 Prefix le[int|str]-functions with "mxs_" 2016-12-29 10:10:11 +02:00
Johan Wikman
c008d794c7 Add const correctness to mysql_util.h 2016-12-27 15:52:55 +02:00
Markus Mäkelä
47ac20adea Refer to sessions by ID instead of memory address
Using the unique ID for the session is easier to use than an address. This
also allows the removal of all pointer values from the maxadmin output
which is never useful to the end user.
2016-12-22 17:55:05 +02:00
Markus Mäkelä
7cbd62db52 Fix show dbusers
The functionality was broken by the change where the users were moved from
the service to the listener.
2016-12-22 17:55:05 +02:00
Markus Mäkelä
06d362765c Use pending status only with running monitors
If a monitor is stopped, it is OK to modify the state of the server
without putting it into the pending status variable.
2016-12-22 10:03:30 +02:00
Dong Young Yoon
5d1b94de88 assigns the target server before gwbuf_append() 2016-12-20 13:04:01 +02:00
Dong Young Yoon
3e6cbeff19 1. Applied changes suggested from Markus.
2. tpmfilter now prints username of the client instead of the hostname
of the target server.
2016-12-20 13:04:01 +02:00
Markus Mäkelä
ae8c21929f Serialize server weighting parameters
The server weighting parameters couldn't be altered online and they
weren't serialized to disk. Only servers that are created online will have
their weighting parameters persisted to disk.
2016-12-19 18:40:14 +02:00
Markus Mäkelä
180728dde6 Only serialize created servers
Any changes to servers that aren't created online need to be manually
added to the configuration file in order for them to take effect after the
restart.
2016-12-19 18:40:14 +02:00
Johan Wikman
b62db91ab3 Add gwbuf_compare
With gwbuf_compare the content of two GWBUFs can be compared.
2016-12-19 14:55:44 +02:00
Johan Wikman
f929932fc0 Move docs from buffer.c to buffer.h
- Move docs from buffer.c to buffer.h
- Arguments made const-correct.
      gwbuf_length
      gwbuf_count
      gwbuf_copy_data
- Boolean return values changes from int to bool.
      gwbuf_add_property
- Meaningless returnvalue changed from int to void.
      gwbuf_add_hint
- Unused function removed.
      gwbuf_clone_transform
      gwbuf_trim
2016-12-19 11:42:02 +02:00
Johan Wikman
6e6a3e4626 Replace gwbuf_clone_all with gwbuf_clone
gwbuf_clone cloned only the first buffer of a chain of buffers,
which never can be the desired outcome, while gwbuf_clone_all
cloned all buffers.

Now, gwbuf_clone behaves the way gwbuf_clone_all used to behave
and gwbuf_clone_all has been removed.
2016-12-19 11:00:47 +02:00
Markus Mäkelä
875766cf62 Make modutil_create_query parameters const
The parameters to modutil_create_query are not modified so they can be
declared const.
2016-12-19 10:33:55 +02:00
Markus Mäkelä
269a97b2de Fix DECIMAL handling in Avrorouter
The DECIMAL value type is now properly handled in Avrorouter. It is
processed into an Avro double value when before it was ignored and
replaced with a zero integer.
2016-12-19 10:33:55 +02:00
Esa Korhonen
7e9db7ed0c Have server status updates applied during monitor loop
Previously, server status changes from MaxAdmin would be set immediately
as long as the server lock could be acquired. This meant that it might take
several seconds until the next monitor pass is executed. Usually, this was
fine but in some situations we would want the monitor to run immediately
after the change (MXS-740 and Galera). This patch changes the logic of
setting and clearing status bits to a delayed mode: changes are first applied
to a "status_pending"-variable, and only once the monitor runs will the
setting be applied. To reduce the delay, the monitor now has a flag
which is checked during sleep (between short 0.1s naps). If set, the
sleep is cut short.

If a server is not monitored, the status bits are set directly.

There is a small possibility of a race condition: If a monitor is stopped or
destroyed before the pending change is applied, the change is forgotten.
2016-12-19 10:19:23 +02:00
Markus Mäkelä
ac36f04f93 Add 'root_node_as_master' to list of monitor parameters
The configuration processing requires that all parameters for monitors
exist before they are used. This is wrong if we are aiming for a modular
system but is a necessary evil for the time being.
2016-12-17 00:17:49 +02:00
Markus Mäkelä
067d48ddc6 Check if source and destination overlap in serverAddMonUser
The source and destination strings for snprintf must not overlap. A simple
check for the address of the source and destination should solve the case
where they are the same. Behavior is undefined if the pointers aren't the
same but the memory overlaps.
2016-12-16 18:18:04 +02:00
Markus Mäkelä
f69c8ccd0c Use server credentials for monitor permissions checks
When the monitor performs permission checks, it should use the `monuser`
and `monpw` credentials if they are defined.
2016-12-16 18:02:07 +02:00
Markus Mäkelä
bb9b5a87c1 Log a message when persisted configurations are used
If no message is logged, it will be very hard to figure out where some
configurations are coming from. For this reason, it's good to log a
message whenever a persistent configuration change is taken into use.
2016-12-16 10:28:06 +02:00
Esa Korhonen
3a96482c23 Remove unnecessary memory barrier
The memory barrier is not needed here. Declaring poll_msg as volatile
should help with preveting some unwanted optimizations. Most likely
even that is unnecessary.

This came up when testing maxadmin "show servers", which is
surprisingly slow compared to the other commands. This change does
not help because the slowness is caused by the polling loop sleeping.
In a more busy environment the command would probably complete faster.
This should be looked at later.
2016-12-15 15:54:24 +02:00
Markus Mäkelä
f9a7edc7d2 Fix tee filter
With the addition of filter capabilities, the tee filter should work with
all sorts of routers that require at most the RCAP_TYPE_CONTIGUOUS_INPUT
capability.

Due to a recent discovery of the server's capability to process multiple
requests, the filter can safely send data from one service to another
without waiting for the earlier replies.

This also fixes a minor problem with the cloning of DCBs where the backend
DCBs could end up in the wrong thread's pool.
2016-12-14 23:55:33 +02:00
Esa Korhonen
4bd5486924 When printing services also print the related backends
MXS-1060. In MaxAdmin, running "list services" will now list the
backends of each service. When running "show services", the backend
names are now printed (previously just the addresses and protocols).
2016-12-14 09:41:47 +02:00
Markus Makela
a0f6dd8abc Fix crash on double creation of listeners
When the listeners were created twice, MaxScale would crash when the users
were loaded. This is caused by the fact that the DCB for the listener is
NULL for failed listeners.
2016-12-13 09:12:58 +02:00
ekorh475
259e944b3d Server status changes now happen under a lock
MXS-873 To prevent monitors and MaxAdmin from interfering with each other,
changes to the server status flags now happen under a lock. To avoid
interfering with monitor logic, the monitors now acquire locks to all
of their servers at the start of the monitor loop and release them
before sleeping.
2016-12-12 15:04:05 +02:00
Markus Makela
d543ecb483 Remove servers from destroyed monitors
A destroyed monitor should not have any servers added to it. This allows
the servers that once were monitored by a destroyed monitor to be added to
new monitors.
2016-12-12 10:48:53 +02:00
Markus Makela
cb218804ef Detect double monitoring of servers
Adding a server to multiple monitors is forbidden. This should be detected
and reported to the end user.

The information provided by the config_runtime system to the client isn't
as detailed as it could be. Some sort of an error message stack should be
added so that client facing interfaces could properly report the reason
for the failure. Currently the only way to detect the reason of the
failure is to parse the log files.
2016-12-12 10:48:53 +02:00
Markus Makela
312cf69739 Log a message for every online change
All changes made to the configuration should be traceable. This makes the
process of understanding the life-cycle of a specific MaxScale
installation easier.
2016-12-12 10:48:53 +02:00
Markus Makela
49aa23468d Align statistics to cache lines
Aligning the statistics object indices to cache line size reduces the CPU
overhead of gathering the statistics. This allows the statistics to more
accurately measure the polling system without the measurement affecting
the outcome.
2016-12-12 10:48:49 +02:00
Markus Makela
5cb738ae03 Fix minor memory leaks
The main function and monitor creation both leaked a few bytes of memory.
2016-12-09 22:28:35 +02:00
Johan Wikman
855ed415f8 Add support for filters implemented in C++
C++ header files have the .hh-suffix to distinguish them from C
header files, but also to allow a C++ header file (e.g. xyz.hh) for
an existing C header file (e.g. xyz.h).

- cpp.hh        : Basic C++ stuff. Introduces the namespace "maxscale"
                  and its synonym "mxs".
- filter.[hh|cc]: Template class Filter and companion class FilterSession
                  to be used when implementing filters in C++.
- spinlock.h    : Wrapper and lock guard class for SPINLOCK.
2016-12-09 13:08:10 +02:00
Johan Wikman
12f0886ca2 Call destroyInstance after workers have exited
Router and filter instances cannot be destroyed before all worker
threads have exited. Otherwise there is a risk that data gets deleted
while someone might still be accessing it. Further, since all router
and filter instances are created by the main-thread it is better that
they are deleted by that thread as well (and not by whichever thread
happens to execute service_shutdown()). That will reduce the risk that
some unknown assumptions are violated.
2016-12-09 13:00:14 +02:00