112 Commits

Author SHA1 Message Date
Markus Mäkelä
d19e5b376d MXS-1032: Add configurable connector plugin directory
The connector plugin directory can now be controlled with the
`connector_plugindir` argument and configuration option. This should allow
the connector to use the system plugins if the versions are binary
compatible.

Replaced calls to mysql_options to mysql_optionsv as the former is
deprecated in Connector-C 3.0 and the latter is supported in Connector-C
2.3.
2017-03-15 09:11:18 +02:00
Markus Mäkelä
6da8cfe97e Fix assignment of master status on failed servers
When the real root master server went down, it still received the master
status bit due to how the replication tree was built. The bit should only
be set for servers that are running.

Also fixed a false state change event when the master status bit was
manually cleared from the downed root master server.
2017-03-12 09:40:21 +02:00
Johan Wikman
49cc2b52e3 Merge branch '2.1.0' into 2.1 2017-02-15 08:44:55 +02:00
Johan Wikman
5648f708af Update license to BSL 1.1 2017-02-14 21:42:28 +02:00
Markus Mäkelä
acd66b4eb3 Fix compiler warnings
Added missing checks for return values of various function calls. Fixed
binlogrouter strerror_r usage and wrong buffer sizes.
2017-02-13 11:44:38 +02:00
Esa Korhonen
1f9b18e3bc Split secrets.h to public and core + miscellaneous cleanup
Also, changed some function names to this_style from thisStyle. More of
this in later commits.
2017-01-27 15:33:52 +02:00
Esa Korhonen
7d51864402 Clean config.h some more
Moved some typedefs to router.h and server.h, changed a few
constants to these enums. Renamed some types in config.h to
remove "Gateway".

There are still some functions in the public header which are
only used in core, but they seem to fit the theme of public functions
so were not moved.
2017-01-25 16:05:51 +02:00
Esa Korhonen
b187afdcf4 Move config_runtime.h and externcmd.h to core
+ some cleanup
2017-01-24 13:05:21 +02:00
Markus Mäkelä
7723641687 Ignore relay master and external slave state changes
When the relay master or external slave states change, they should be
ignored in the current implementation. When the relay master and slave of
external master events are added, the events can be enabled.
2017-01-23 13:38:56 +02:00
Markus Mäkelä
4ee7f4c91d Add some extra debug assertions
The debug assertions help catch false positives in server state change
logic.
2017-01-20 16:57:04 +02:00
Esa Korhonen
6e38276a20 Rename files, removing "gw"-prefix
Also gwdirs.h.in -> paths.h.in
2017-01-20 12:55:52 +02:00
Markus Mäkelä
568239d2b5 Ignore auxiliary server status bits for state changes
The auxiliary status bits for the server were treated as if they changed
the real state of the server. The stale status bits don't affect the real
state of the server so they should be ignored when monitors check for
state changes in servers.
2017-01-20 09:10:44 +02:00
Markus Mäkelä
dbeb208a5c Remove unnecessary function from header
The function was only used in one place.

Also added a debug assertion for the monitor event detection mechanism.
2017-01-19 16:03:05 +02:00
Esa Korhonen
eff34b91fb Move modules.h to core/maxscale
Also remove some unnecessary includes + cleanup
2017-01-19 15:53:25 +02:00
Esa Korhonen
53c5b475ad More cleanup of monitor.h
Move some more functions into core header + miscellaneous cleanup
2017-01-19 15:32:40 +02:00
Esa Korhonen
7ed7f972b1 Divide monitor.h to internal and interface headers similar to filter.h
Definitions and function used by core are in
server/core/maxscale/monitor.h
Definitions and function used by plugins are in
include/maxscale/monitor.h
2017-01-19 09:50:48 +02:00
Esa Korhonen
680401cf8e Rename public types and constants in monitor.h
Preparing to split monitor.h into module and core sections. Also
changed a few comments in monitor.h.
2017-01-17 15:47:13 +02:00
Markus Mäkelä
0b6b9c3d81 Format core source code and headers
Formatted core source code and headers with Astyle.
2017-01-17 14:47:50 +02:00
Markus Mäkelä
d054bc9b04 Split config.h into external and internal parts
The external config.h header defined functions and structures that are
intended to be used by modules. The internal header contains functions
that are used only by the MaxScale core.
2017-01-16 11:02:34 +02:00
Markus Mäkelä
a196420c2d Move monitor script processing and launching into the core
This removes parts of the nearly identical code from all monitors.

The removal of monitor type specific event checking is done based on the
assumption that only the monitor that is monitoring the server can be the
cause for a state change. This removes the need to actually check that the
state change is relevant for each monitor and allows the event handling to
be moved into the core.
2017-01-11 14:21:57 +02:00
Johan Wikman
83eddabebc Add missing newline 2017-01-04 10:53:21 +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ä
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
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
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
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
Markus Makela
b3e31a3da2 Add creation and destruction of monitors to maxadmin
Maxadmin can now create and destroy monitors. The created monitors are not
started as they would be useless without added servers and configuration
parameters.
2016-11-30 12:43:50 +02:00
Markus Makela
55f1bbfce6 Fix monitor alteration and serialization
When the monitor credentials were being written with snprintf, the source
and destination overlapped.

The serialization didn't add a 'type=monitor' line into the configuration.
2016-11-30 12:41:43 +02:00
Markus Makela
4c4bd24a40 Allow module specific monitor parameters to be altered
Module specific parameters can now be altered at runtime. This allows both
the removal and addition of arbitrary monitor parameters.
2016-11-30 12:41:43 +02:00
Markus Makela
07c602d81c Add creation and destruction of monitors
Monitors can now be created and destroyed at runtime. The configurations
for new monitors are persisted to disk.
2016-11-29 15:04:19 +02:00
Markus Makela
8ef99c9066 Move configuration changes to a common file
The config_runtime.h header contains functions that can be used to
manipulate the running configuration. Currently the header contains the
function to create, add, remove and destroy servers.
2016-11-24 10:29:04 +02:00
ekorh475
53637af98f Log monitor script argument values
MXS-843. When a monitor executes an external script in response to
a server event, the execution is logged to the MaxScale main log.
Previously, the log message only contained the script name as given
in the configuration file. Now, the message contains the script name
and argument values as given to the execvp-call.
2016-11-22 14:13:19 +02:00
Markus Makela
72622bc92f MXS-977: Move common diagnostic code to the core
Almost all monitors printed the same diagnostic output inside the
modules. This should be a part of the core, not the modules themselves.
2016-11-17 12:36:44 +02:00
Markus Makela
5d5802a5a0 Merge branch 'develop-2.0-merge' into develop 2016-11-16 12:57:38 +02:00
Markus Makela
5ecd0af68e Add missing NULL pointer check to monitorRemoveServer
The pointer was falsely assumed to be non-NULL.
2016-11-16 11:56:49 +02:00
Markus Makela
3c15b58891 Merge branch '2.0' into develop-2.0-merge 2016-11-15 00:09:24 +02:00
Markus Makela
a17aa28eed Persist changes to the list of monitored servers
When a server is added to a monitor, an supplementary configuration file
is generated to persist this information. This will allow dynamic
modifications to server lists which will survive restarts and unexpected
downtime.

The monitor will only add new servers to its list of monitored
servers. This prevents duplicate entries in the list and makes it safe to
persist all used servers to the supplementary configuration file instead of only the ones that are not listed in the main configuration.
2016-11-14 22:58:26 +02:00
Markus Makela
16e8aa7178 Fix server usage bugs in monitors and servers
The MySQL Monitor did not reset the pointer to the root master reference
which would lead to a crash if the master was removed.

When service details were shown, it listed all servers that existed. Only
servers that haven't been removed or destroyed should be shown.
2016-11-11 10:54:34 +02:00
Markus Makela
261f5fdc36 Enable destruction of servers
The servers can now be destroyed which removes them from the list of
active servers. If the server was not created at runtime, a warning is
logged.
2016-11-11 10:54:32 +02:00
Markus Makela
bbd3e13a54 Only use valid server credentials
The server credentials are only used if both the monuser and monpw
parameters are defined. This is a sort of a bugfix as a monitor connection
could use a username from server but a password from the monitor.
2016-11-10 15:15:10 +02:00
Markus Makela
4b82f83637 Enable online modification of monitors
The monitor parameters can now be changed via maxadmin. These changes are
not persisted to disk yet.
2016-11-10 15:15:10 +02:00
Markus Makela
b51af51365 Allow monitors and services to start without servers
MaxScale can now start without any defined monitors. This allows the core
services to be configured beforehand. With the changes to dynamic
modifications to servers, automatic scaling of slaves is possible.
2016-11-10 15:15:10 +02:00
Markus Makela
dbedf57c9a Add and remove servers for monitors
The `add server` command accepts a server name and either a service name
or a monitor name. It will add servers to services and monitors. Since all
monitors use the MONITOR_SERVER structures directly, the monitors need
to be stopped before new servers are added to them
2016-11-10 15:15:10 +02:00
Markus Makela
7ef8b187b5 Do hangups only after server states have been updated
The hangup code was refactored into a common function which should only be
used after the server states have been updated. This will remove erroneus
connections to already failed servers.
2016-11-09 23:21:54 +02:00
Johan Wikman
1333da0712 Remove skygw_utils.h
The general purpose stuff in skygw_utils.h was moved to utils.h
and the corresponding implementation from skygw_utils.cc to utils.c.
Includes updated accordingly.

Skygw_utils.h is now only used by log_manager and by mlist, which
is only used by log_manager. Consequently, skygw_utils.h was moved
to server/maxscale.

Utils.h needs a separate overhaul.
2016-10-14 19:50:54 +03:00
Johan Wikman
d04cb54b9f maxscale/maxscale_pcre2.h renamed to maxscale/pcre2.h 2016-10-13 22:59:39 +03:00
Johan Wikman
e41589be10 Move headers from server/include to include/maxscale
- Headers now to be included as <maxscale/xyz.h>
- First step, no cleanup of headers has been made. Only moving
  from one place to another + necessary modifications.
2016-10-13 16:19:20 +03:00
Markus Makela
c470813762 MXS-831: Detect new_master events
The new_master events were mistakenly detected as lost_slave events.
2016-09-30 00:01:53 +03:00
Markus Makela
35d4be14d2 Make service and monitor permissions checks optional
MaxScale shouldn't require the service and monitor user checks. It makes
sense to disable the checks to speed up the startup process when the user
knows that the permissions are OK.
2016-09-20 10:30:53 +03:00
Johan Wikman
d7f79942be Merge branch '2.0' into develop 2016-09-09 15:12:58 +03:00