2695 Commits

Author SHA1 Message Date
Markus Mäkelä
0c8e68fd05 Rename and overload adding of session commands
As the session commands are always appended to the end of the list, the
name should reflect that action. For this reason, the function was renamed
to append_session_command.

Readwritesplit supports replacement of slave servers by storing all
executed session commands in a list. To make the copying of this list a
bit cleaner, an overload for a list of session commands was added. This
will allow relatively smooth addition of server replacement to all router
modules that use the Backend class.
2017-06-22 10:40:17 +03:00
Markus Mäkelä
1f31cfdfd7 Add more session command related functions to Backend
The class now allows simpler construction of session commands by
overloading the add_session_command with a version that accepts a const
reference to a shared pointer. This removes the need to copy the
references to the source buffer by calling gwbuf_clone.

Exposed the first session command as a const reference to allow
interaction with it. Currently, it is planned to be used to get the
session command position of each backend.
2017-06-22 10:40:17 +03:00
Markus Mäkelä
c3c905f745 Add is_active helper to Backend
The Backend now provides a helper function for checking if the SERFER_REF
is still active.

Also renamed the close_type enum values.
2017-06-22 10:40:16 +03:00
Markus Mäkelä
5a5effdf7a Take Backend into use in rwsplit_select_backends.cc
This is the first step to taking the Backend class into use. It is now
used in rwsplit_select_backends.cc and readwritesplit.hh. The module is
not yet functional and doesn't even compile.

Added some helper functions to the Backend class to get easier access to
the server referenced by the SERVER_REF and to check the state of the
backend.
2017-06-22 10:40:16 +03:00
Markus Mäkelä
1fcb62895e Add fatal failure checking method to Backend
The method allows the caller to check whether the backend has suffered a
fatal failure.
2017-06-22 10:40:16 +03:00
Markus Mäkelä
18993bc8ca Refactor Backend class states
The states are now internal to the Backend class. This simplifies the use
of the class by moving the burder of state tracking to the class
itself.

Refactored the way the schemarouter uses the Backend class.

Also fixed a memory leak in the schemarouter when `ignore_databases_regex`
was used..
2017-06-22 10:40:16 +03:00
Markus Mäkelä
bbfd9ce136 Move Backend and SessionCommand classes to the core
Using the same implementation of the Backend and SessionCommand classes in
both schemarouter and readwritesplit will prevent duplication of code.

This commit only splits the generic parts of the class to a Backend class
which the schemarouter then extends. The session commands for both routers
are similar so they require no special handling.
2017-06-22 10:40:16 +03:00
Johan Wikman
33fe89772a MXS-1249: Return service version
Since it is now a single value, the service version can be returned
as a return value instead of via an out-argument. More convenient to
use that way.
2017-06-21 13:28:59 +03:00
Johan Wikman
dcfe118457 MXS-1249: Qc, the server version is passed as a single integer
To be compatible with how the version is managed elsewhere.
2017-06-21 13:28:59 +03:00
Johan Wikman
997416ab82 MXS-1249: Server version stored as uint64_t value
That allows the version to be updated and read atomically. If
major/minor/patch are stored as separate variables, you can get an
inconsistent set. Now it may be out of date by the time it is used,
but it will never be internally inconsistent.
2017-06-21 13:28:59 +03:00
Johan Wikman
4e73aecdef MXS-1249: Modifications after rebase on develop 2017-06-21 13:28:59 +03:00
Johan Wikman
1034cc51be MXS-1249: Qc, allow setting the server version
In the case of qc_sqlite, the server version may affect how statements
are parsed.
2017-06-21 13:28:59 +03:00
Johan Wikman
b8702b8d95 MXS-1249: Add function for getting the "version" of a service
The behaviour of the query classifier needs to change depending
on the version of the servers of a service. With this function
"some" version of the service can be obtained.
2017-06-21 13:28:59 +03:00
Johan Wikman
d927f1d3c6 MXS-1249: Add utility function for setting the server version
Add utility function for setting the server version from a
MySQL handle.
2017-06-21 13:28:59 +03:00
Johan Wikman
0d784da0ee MXS-1249: Prepare for storing version in server structure
The behaviour of the query classifier needs to be different
depending on the actual version of the server. There is already
a human readable string, but for programmatic use it needs to
be in a format that can easily be parsed.
2017-06-21 13:28:59 +03:00
Markus Mäkelä
4a298b4024 Return NULL if no regex parameter is defined
If no regex type parameters are defined and a compiled pattern is
requested, the function will return a NULL value. This allows code that
directly calls the config_get_compiled_regex function to work without
doing additional checks for the presence of optional parameters.
2017-06-21 10:13:47 +03:00
Markus Mäkelä
d546d77401 Fix debug assert when closing internal DCB
Internal DCBs don't have file descriptors so the debug assertion needs to
be altered.
2017-06-20 10:46:33 +03:00
Johan Wikman
d68d3072a8 Make atomic_load_-functions const correct 2017-06-19 14:37:20 +03:00
Johan Wikman
3e39ec906e Change server version from char pointer to char array
With this change, it is no longer possible that the server version
is deallocated at the very moment it is read. There is still a race,
but it's mostly harmless.
2017-06-19 14:05:26 +03:00
Johan Wikman
32cd28daf2 Rename MAX_SERVER_NAME_LEN to MAX_SERVER_ADDRESS_LEN 2017-06-19 14:05:26 +03:00
Esa Korhonen
77a692e0c3 Set minimun VLA size to 1 2017-06-16 10:17:27 +03:00
Esa Korhonen
3260069ed8 Fix compile error on Centos7 2017-06-15 15:17:33 +03:00
Esa Korhonen
81eeed55aa Add generic debug flag to MaxScale
MXS-1282. The flags "-g=arglist" or "--debug=arglist" activate
the debug settings specified in the comma-separated list arglist.
Currently, the setting "disable-module-unloading", which prevents
modules (.so-files) from being unloaded at exit, is supported. This
allows Valgrind to produce line numbers for leak reports when the
memory was allocated in a module. The setting "enable-module-unloading"
is also available, but this is activated by default.

The debug arguments and their actions are defined in a structure
array, so adding more is straightforward.
2017-06-15 11:23:34 +03:00
Esa Korhonen
39c6328e9b Refactor config_get_compiled_regex_capcount()
The function now returns the compiled code or null or error. Also,
instead of capcount, it writes the ovector size. The ovector pointer
can be null. Removed the other config_get_compiled_regex()-function
and replaced it with the refactored function since they are almost
identical.
2017-06-12 10:56:00 +03:00
Markus Mäkelä
2778056212 MXS-1220: Enable admin authentication by default
The admin interface now uses HTTP BA authentication by default. This will
prevent unrestricted access to the REST API but the authentication is by
no means secure and the HTTPS mode for the REST API should be enabled for
all production systems.
2017-06-12 10:08:25 +03:00
Markus Mäkelä
53d7c57982 MXS-1220: Add error descriptions to REST API module commands
The module command calls that fail can now display additional information
in the form of an error object.
2017-06-12 10:08:25 +03:00
Markus Mäkelä
45afbda100 Add descriptions to module commands
Each module command has to describe what it does. This should make module
commands self-documenting to some degree.
2017-06-12 10:08:25 +03:00
Markus Mäkelä
b3c1e15f22 MXS-1220: Add output for module commands
The module commands can now produce JSON formatted output which is passed
to the caller. The output should conform to the JSON API as closely as
possible.

Currently, the REST API wraps all JSON produced by module commands inside
a meta-object of the following type:

  {
    "meta": <output of module command>
  }

This allows the output to be JSON API conformant without modifying the
modules and allows incremental updates to code.
2017-06-12 10:08:25 +03:00
Esa Korhonen
66a45fc37e MXS_MODULE_PARAM_REGEX and QUOTED_STRING now accept non-enclosed values
This is for backwards compatibility to allow current modules to use
the automatically compiled regex parameters. The enforcement should
be restored in a later version. A warning is output for every non-
enclosed regex.

Similar changes are also applied for QUOTED_STRING.
2017-06-09 12:59:11 +03:00
Markus Mäkelä
92fa613f93 Use worker messages for fake events
Fake events now use worker messages to trigger execution of the events.
2017-06-07 10:36:26 +03:00
Markus Mäkelä
e4a004097e MXS-1220: Add support for PATCH
The PATCH method should now be used instead the PUT method to update
resources.  As PUT request bodies should represent complete resources, the
use of PUT to update resources is no longer supported.

Altered tests to use PATCH instead of PUT for updating resources.
2017-06-05 13:37:08 +03:00
Markus Mäkelä
09a445f1b7 Fix monitor credentials parameter names
The `monitoruser` and `monitorpw` parameters were mislabeled as `monuser`
and `monpw`. To allow backwards compatibility, the `monuser` and `monpw`
still work as aliases for the correct commands.
2017-06-05 13:20:16 +03:00
Esa Korhonen
47b7f1c69c Add automatically compiled PCRE2_REGEX config parameter type
The regex strings are compiled automatically. During file parsing,
the string is compiled once using default settings to check that
the pattern is valid. Once a module asks for the compiled pcre2_code,
the pattern is compiled again with module given settings.

The regex string in the config file should be enclosed within '/ ... /'
2017-06-05 09:42:42 +03:00
Markus Mäkelä
d59e98e238 MXS-1267: Remove DCB cloning
The DCB cloning is no longer needed as the tee filter now does the session
branching by simulating a local client connection.
2017-06-02 13:07:02 +03:00
Markus Mäkelä
19c4016e65 MXS-1220: Add to_string to HttpRequest
Allowing requests to be converted to raw HTTP requests allows them to be
propagated to other instances of MaxScale. This should allow multiple
MaxScales to perform the same action in a coherent manner.

A simple clustering mechanism needs to be added to make MaxScale aware of
other instances.
2017-06-02 12:52:33 +03:00
Markus Mäkelä
ba546fcd21 MXS-1220: Add execution of module commands to REST API
The module command self links now point to an endpoint that executes the
module command. Depending on the type of the module command, either a GET
or a POST request must be made.
2017-06-02 12:52:33 +03:00
Johan Wikman
f546a17e77 Update change date of 2.2 2017-06-01 10:24:20 +03:00
Markus Mäkelä
7baa52b763 Make modulecmd_argtype_to_str return values constant
The function needlessly allocated memory for the type strings.
2017-05-29 19:27:45 +03:00
Markus Mäkelä
948a059004 MXS-1220: Add module commands to /maxscale/modules
The module commands are now exposed as an additional sub-resource for the
module type.
2017-05-29 19:27:45 +03:00
Markus Mäkelä
4c2560b5a6 MXS-1220: Pretty-print by default
The REST API now pretty-prints by default. This is done to make it easier
to use the API with browsers that don't have an integrated REST API
client.
2017-05-29 19:27:45 +03:00
Esa Korhonen
88bf361e61 Add MXS_MODULE_PARAM_QUOTEDSTRING configuration value type
A quoted string is a string enclosed in '"':s. This makes it clear
where the string begins and ends, avoiding ambiguity with whitespace.
After the config file has been loaded, the '"':s at the beginning
and at the end of the string are erased. Querying the config value
with config_get_string() will return this de-quoted value.

For example, if the config file reads 'my_string="test""', the actual
string will be 'test"'.
2017-05-29 16:15:49 +03:00
Markus Mäkelä
5c512a3945 Fix atomic code for pre-4.7 GCC versions
The CAS operation used the wrong function and the atomic_store operations
compiled into inadequate assembly on x86 and ARMv7.
2017-05-26 09:57:01 +03:00
Markus Mäkelä
b6b108c8d5 MXS-1220: Fix possible crash on NULL option value
When a request option without a value is given, microhttpd exposes this as
key with a NULL value.
2017-05-26 08:52:38 +03:00
Markus Mäkelä
6b8b19b439 MXS-1220: Add PUT support for /maxscale/ resource
The /maxscale/ resource now supports PUT requests which modify core
parameters. As not all parameters can be changed at runtime, only
modifications to parameters that support runtime configuration are
allowed.
2017-05-24 15:05:11 +03:00
Markus Mäkelä
3fd82ebae6 MXS-1220: Add alter maxscale MaxAdmin command
A set of the core MaxScale parameters can now be altered at runtime. This
set consists of the authentication timeouts and the admin interface
authentication. Other parameters either can't be modified due to internal
limitations or aren't sensible to modify at runtime.
2017-05-24 15:05:11 +03:00
Markus Mäkelä
69be4d263f MXS-1220: Add admin interface parameters to /maxscale/ resource
The admin interface parameters are now a part of the /maxscale/ resource.
2017-05-24 15:05:11 +03:00
Markus Mäkelä
1067fd352c MXS-1220: Add creation and deletion of admin users
Admin users can now be created via the REST API. This allows remote
management of the administrative interface itself.
2017-05-24 15:05:11 +03:00
Markus Mäkelä
ead9059eeb MXS-1220: Add /users/ resource
The /users/ resource shows all user accounts that can be used with
MaxScale. This resource is further split into two resource collections,
/users/inet and /users/unix, which contain the network users and Linux
accounts respectively.
2017-05-24 15:05:10 +03:00
Markus Mäkelä
7fc2d25cf2 MXS-1220: Allow new REST API users to be created
The REST API now uses the same users as MaxAdmin network interface. This
allows them to be created with MaxAdmin.

The next step is to add user creation to the REST API.
2017-05-24 15:05:10 +03:00
Markus Mäkelä
db78eae9a8 MXS-1220: Use thread-local buffer for errors
The runtime error buffer is now a thread-local buffer. This fixes the
build failure on older systems where the compiler doesn't allow
thread-local non-POD objects to be created.

Also expanded some of the JSON validation functions so that they provide
better errors.
2017-05-24 15:05:10 +03:00