2025 Commits

Author SHA1 Message Date
Markus Makela
c08a637564 Fix array usage with servers
The server monuser and monpw members were used with the assumption that
they could be NULL. This is no longer true since they were converted to
arrays.

The name member of the server was freed leading to a crash when the server
unit test was run.
2016-11-10 15:15:10 +02:00
Markus Makela
aefa5c4c57 Add configurable persistdir
The persisted configuration file directory is now configurable.
2016-11-10 15:15:10 +02:00
Markus Makela
6847ed1c37 Create and read persisted config dir
The persisted configuration directory is created and/or read when MaxScale
starts. This allows the servers created at runtime to be recreated when
MaxScale is restarted.
2016-11-10 15:15:10 +02:00
Markus Makela
ec894f41b8 Store persisted config directory
The persisted configuration subdirectory will be used to store changes to
the configuration. The gwdirs.h header now supports setting and getting
the value for this directory.
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
35d2959395 Enable online modification of servers
The address, port, monuser and monpw parameters of an existing server can
be changed at runtime. The support for enabling SSL will come in a later
commit.

Allowing servers to be modified could also be done by destroying and
recreating them. Since the servers are never actually destroyed, it is
better to allow the alteration of the existing ones.
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
28fc3d2b83 MXS-922: Add server serialization function
The function serializes a server to a file. This is intended to be used
with dynamically created servers. The output of the server serialization
will eventually be stored in the configuration file directory (default is
/etc/maxscale.cnf.d/) so that created servers persist even after a
restart.
2016-11-10 15:15:10 +02:00
Markus Makela
8982ee3db2 Allow servers to be added and removed from services
Servers can now be added and removed from services which allows routers to
use them with new sessions. The routers don't fully use the new
functionality in the server references which prevents new servers from
being taken into use.
2016-11-10 15:15:10 +02:00
MassimilianoPinto
21add3a8b4 Merge branch 'develop' into MXS-936 2016-11-10 12:02:40 +01:00
Johan Wikman
bc1c2e1152 Ensure exit is possible
If shutdown has been initiated (via maxadmin or by sending a
SIGINT or SIGTERM) and a SIGTERM is received, the process
is terminated.

If shutdown has been initiated (via maxadmin or by sending a
SIGINT or SIGTERM) and a SIGINT (Ctrl-C) is received, a warning
is printed that shutdown is in progess. Then, if an additional
SIGINT is received, the process is terminated.

So, in practice:
- If MaxScale is running as a daemon, the first SIGTERM initiates
  shutdown and a second one unconditionally terminates the process.
- If MaxScale is running in the console, the first Ctrl-C initiates
  shutdown, the second prints a warning and the third terminates
  the process.

This is to ensure that MaxScale can be forced to exit, in
case some thread is hung for whatever reason, and is thus preventing
the controlled shutdown.
2016-11-10 11:09:59 +02:00
ekorh475
c28ffcf87e Change error message when permissions on .secrets are wrong
If the user running MaxScale could open the .secrets-file and the
file permissions were anything other than owner:read, the
secrets_readkeys() would fail with error message
"Ignoring secrets file <path>, invalid permissions." Now the
message is more accurate in stating the expected permissions.
2016-11-10 09:42:47 +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
MassimilianoPinto
da152353dd Merge branch 'develop' into MXS-936 2016-11-09 16:21:40 +01:00
Johan Wikman
02ec7e9b17 Wait until housekeeper has finished
When calling hkshutdown(), only a shutdown flag will be set.
In main() we will then actually wait for the housekeeper thread
to finish before exiting.
2016-11-09 15:14:52 +02:00
Markus Makela
7f500feb9d MXS-710: Fix regression
MaxScale would crash if two or more listeners used the same service and
one of the listeners failed to start.
2016-11-09 06:44:37 +02:00
MassimilianoPinto
4e36e86820 MXS-936: destroyInstance added for filters
MXS-936: destroyInstance added for filters
2016-11-08 17:09:49 +01:00
Markus Makela
5d930585f9 Use TLS for connector connections
The monitors and services didn't use TLS when they connected to the
backend servers. Since there has been no proof of instability, TLS should
be enabled.
2016-11-08 15:21:58 +02:00
MassimilianoPinto
61f0603e39 MXS-936: destroyInstance interface change
MXS-936: destroyInstance interface change
2016-11-08 14:07:48 +01:00
MassimilianoPinto
de18f25cb8 MXS-936: add shutdown hooks
First part: add shutdown hooks for routers.

Binlog is the first one with a  destroyInstance() routine
2016-11-08 11:12:37 +01:00
Markus Makela
689366b6b7 Fix possible writes to closed DCBs
When persistent connections were used, it was possible that the injection
of COM_CHANGE_USER statements caused a crash when a DCB in the wrong state
was accessed.

For MySQL protocol modules, the `data` member of the client DCB points to
the shared session data, a MYSQL_session struct, but for sessions in the
persistent pool, it points to NULL. The boolean, `was_persistent`, tells
whether a DCB was just taken from the pool or it has been in use.

The `was_persistent` status wasn't properly reset for connections that
were put into the pool which caused a COM_CHANGE_USER statement to be
injected for stale connections in the pool which caused a crash when the
NULL `data` member was accessed.
2016-11-08 09:24:00 +02:00
ekorh475
417d6270d5 Fix assignment of session_id
Previously the session_id incrementation was done after creating
filters, giving the filters a constant zero value for session_id.
Now the incrementation happens before filter creation.
2016-11-07 16:19:56 +02:00
Markus Makela
ded551e199 Add function for full memory barrier into maxscale/atomic.h
This allows safer lock-free reads to be done on lists that never shrink in
size. The main use-case for this is to allow servers to be added to a
service without locking the service each time a new session is created.

Synchronizing the memory before adding new components into a list
guarantees that if a session reads from the list and sees the new list
item, the memory pointed by the item is valid.
2016-11-07 14:10:18 +02:00
Markus Makela
a163e31b9a Remove BACKEND structure from readwritesplit
The BACKEND structure is no longer created for the instance. This allows
sessions to dynamically create new servers.
2016-11-07 14:10:18 +02:00
Markus Makela
a097204c70 MXS-922: Move server weight calculation into the core
The core now does the server weight calculation instead of each router
module doing the same thing.
2016-11-07 14:10:18 +02:00
Johan Wikman
bf62f8950a Remove qc_get_affected_fields
Function is no longer used and it was quite unoptimal, so now
removed.

qc_get_prepare_name, qc_get_prepare_operation and qc_get_field_info
that were missing from qc_dummy added at the same time.
2016-11-07 12:28:58 +02:00
Markus Makela
c30d0dfc9d Add more error logging to DCB handling
If an illegal DCB close is done with a backend DCB, it will log the server
where it was connected. This allows us to know whether the DCB was
connected to a master or a slave.

Added more debug assertions to readwritesplit code. The DCBs should never
enter the DCB_STATE_DISCONNECTED.

Removed useless debug log messages. The messages usually just flood the
logs with no use to the developers.
2016-11-05 11:28:18 +02:00
Markus Makela
96547a1c0d Fix failure to exit on configuration error
The check for the success of the configuration file always resulted in a
successful return value even if the loading failed.

In addition to this, a log message referred to the active configuration
when the active configuration was set only after the processing was
complete. Since configuration failures are always fatal, there's no harm
in preemptively setting the active configuration to the one currently
being processed.
2016-11-04 14:53:54 +02:00
Johan Wikman
8778e0c81e Make Users const correct 2016-11-03 09:35:49 +02:00
Johan Wikman
c652f1330a qc: Add qc_get_field_info
This function returns more detailed information about the fields
of a statement. Supersedes qc_get_affected_fields() that will
be deprecated and removed.

Note that this function now introduced new kind of behaviour; the
returned data belongs to the GWBUF and remains valid for as long as
the GWBUF is alive. That means that unnecessary copying need not
be done.
2016-11-02 15:50:21 +02:00
Markus Makela
5085b41d20 Reset persistent MySQL connections
When a persistent connection is taken from the pool, the state is reset
with a COM_CHANGE_USER on the next write. This allows reuse of persistent
connections without having to worry about the state of the MySQL session.
2016-11-01 10:50:07 +02:00
Johan Wikman
8c20ad5cd0 MXS-304: Support hierarchical reload
'reload config' now also processes all configuration files
of a hierarchy.
2016-10-31 12:48:38 +02:00
Johan Wikman
f71f41b0b8 MXS-304: Check duplicate sections across all files 2016-10-31 12:48:38 +02:00
Johan Wikman
2116c1549c MXS-304: Refactor duplicate section detection
Preparatory work for being able to check duplicate sections across
multiple files. Data needed for the checking is held in a separate
object.
2016-10-31 12:48:38 +02:00
Johan Wikman
daf6f06138 MXS-304: Support nested configuration files
Given a config file "config.cnf", we look for the directory
"config.cnf.d" and recursively in that hierarhcy load all files
whose suffix is ".cnf"; other files are ignored.

Currently duplicate sections are checked on a file by file basis.
That will be changed so that duplicate sections are not allowed
across all the files.
2016-10-31 12:48:38 +02:00
Johan Wikman
ab372b291b MXS-304: Minor refactoring of config.c
The loading of a single file refactored out into a separate function.
To be used later when multiple files are loaded and processed.
2016-10-31 12:48:38 +02:00
Johan Wikman
1be3bb9b8d Minor cleanup of config.[h|c]
- Add const where applicable.
- Cleanup header files.

Fix collateral damage (statistics.c) as well.
2016-10-27 15:55:26 +03:00
Johan Wikman
1728e2dc2e Minor cleanup of gateway.c
Pre-parsing of configuration file moved to separate function. To
make it slightly easier to see the forest for the trees.
2016-10-27 14:50:22 +03:00
Johan Wikman
6c80f2bc0a Cleanup gateway.c include files
- First <maxscale/cdefs.h>
- Then all system, c-runtime, OS include files in alphabetical order.
- Then include files for "3rd-party" software in a loose order of
  importance.
- Then maxscale headers ordered alphabetically.
2016-10-27 14:13:31 +03:00
Johan Wikman
a390331e42 Feature defines moved to <maxscale/cdefs.h>
Feature defines that affect the available functionality or the
compile time environment should be defined in a common way for
all source.
2016-10-27 14:08:58 +03:00
Johan Wikman
7499c1e1bf qc: Add minimal support for qc_get_prepare_name
If the query is a PREPARE or EXECUTE statement, then qc_get_prepare_name
will return the name of the prepared statement.
2016-10-26 14:36:37 +03:00
Johan Wikman
19e017e499 QC: Documentation cleaned up and moved to header 2016-10-26 14:22:41 +03:00
Johan Wikman
dc97de57c2 qc: Some minor cleanup
- qc_types_to_string renamed to qc_typemask_to_string
- qc_get_qtype_str removed, duplicate of qc_typemask_to_string
2016-10-26 10:21:11 +03:00
Johan Wikman
f961f87e5e Update autocommit mode and transaction state
The transaction state only reflects explicitly started transactions.
Thus, by looking at the autocommit mode and the transaction state a
component can figure out whether the current statement will be committed
or not.
2016-10-25 16:21:31 +03:00
Johan Wikman
bd18a7d8ed Add service capabilities
The service capabilities are the union of the capabilities of the
router and all filters.
2016-10-24 15:13:16 +03:00
Johan Wikman
3915b4e7c7 Exclude MXS_DEBUG in release builds
Now, MXS_DEBUG turns into a nop in release builds.
2016-10-24 14:00:51 +03:00
Johan Wikman
1a2e0ba3ee Check log priority before logging
With this change, whether something should be logged or, that is,
whether the used log priority is enabled or not, is checked before
the logging function is called. That should save a few cycles.

Now mxs_log_message() always logs a message, without consideration
for whether the priority is enabled or not. The inline function
mxs_log_is_priority_enabled() returns true if a particular priority
is enabled and the MXS_LOG_MESSAGE() macro (that MXS_ERROR etc. are
expanded into) call that before calling the actual logging function.
2016-10-24 14:00:51 +03:00
Markus Makela
d961864635 Fix tests and limit internal test set size
Some of the tests depended on a working installation where modules are all
located at the default paths. These tests now explicitly set the module
directory which fixes the immediate problem.

Disabled the starting of services in the service test as this will fail
with real modules. The dummy internal modules aren't build and should be
removed in a later commit. In general, it might be better to do service
level testing outside the internal test suite.
2016-10-24 13:16:59 +03:00
Markus Makela
cff90ffee8 Fix HTTPD protocol authentication
The HTTPD protocol mistakenly assumed that the `authenticator` parameter
of a listener would be NULL if the default authenticator is used.

Recent changes modified it so that the value is never NULL and
`NullAuthDeny` would be used for protocols which did not implement the
auth_default entry point.
2016-10-24 13:16:59 +03:00