Commit Graph

13213 Commits

Author SHA1 Message Date
3870fac600 MXS-2402 MXS-2396 '*' should be blocked only if there are rules
If there are no rules for the current user, then '*' should be
allowed in UNIONS and when defining variables.
2019-03-25 15:24:35 +02:00
25f8931384 MXS-2402 Reject if masked field is referred to in UNION select
If the second or subsequent select of a UNION statement refers to
a field to be masked, then the statement must be rejected.
2019-03-25 15:24:35 +02:00
ca8350ae35 MXS-2402 Document and handle 'check_unions' parameter
Only parameter handling, no actual functionality.
2019-03-25 15:24:35 +02:00
f37340e9fd MXS-2397 Provide context information for fields
The query classifier now returns contextual information for a fields;
does it appear in the (right hand side) of a UNION or in a SUBQUERY.
2019-03-25 15:24:35 +02:00
bf5f80b13b Fix ClustrixMonitor
The cluster check can only be made after the monitor has been
started. If done when monitor is configured it will at startup
be done when services are not yet available and hence they will
not be populated with the dynamically discovered servers.
2019-03-25 13:56:39 +02:00
382ddf3ea1 Update bug673 to expect new behavior
Since whitespace in object names is now disallowed, the test must be
adjusted accordingly.
2019-03-25 12:37:11 +02:00
c70dc23211 Fix processing of path parameters
Instead of the first character of the string being compared to the value
the whole string was compared.
2019-03-25 12:37:11 +02:00
4880edd373 Fix removal of servers from monitors
The last server wasn't removed as the set of relationships was empty. In
addition to this, changes to relationships via the relations endpoint
wasn't reflected by the monitor parameters.
2019-03-25 12:37:11 +02:00
9bb5e12413 Fix monitor creation and alteration
If a monitor was created at runtime, it was missing some parameters that
were assumed to be always present. In addition to that, the parameters
weren't validated against the list of common and module parameters.

Since the monitors always reconstruct the server list, the new servers can
be stored as a parameter. To make this possible, the
server_relationship_to_parameter helper function is needed.

This commit fixes the MaxCtrl test suite failures but does not fix the
failures in the REST API test suite.
2019-03-25 12:37:11 +02:00
2f634264dc Merge branch '2.3' into develop 2019-03-22 13:39:52 +02:00
4c6306e363 Merge commit '5cdba97ec7ee7f1ef74249b952774adf1b111464' into develop 2019-03-22 13:25:58 +02:00
75c6ef2dc8 Fix mxs_json_error usage
The function takes printf style arguments which means the format string
must be a string constant.
2019-03-22 12:52:56 +02:00
fadbdc7514 Merge branch '2.2' into 2.3 2019-03-22 12:11:24 +02:00
5cdba97ec7 Merge commit '216eb904c557509ea5a3216e68e274df957ab807' into 2.3 2019-03-22 10:48:31 +02:00
c57682291f Add missing json_api.hh header
The json_api.hh was not renamed but removed.
2019-03-22 02:05:36 +02:00
114c172387 Fix examplefilter
It used the old configuration parameter code.
2019-03-21 18:39:40 +02:00
bf2d6673bc Merge branch '2.3' into develop 2019-03-21 18:23:27 +02:00
40df519be4 Never reactivate monitors
Reactivating monitors shouldn't be done as it's simpler to actually
destroy and create a new one. The performance of reactivation is
insignificant compared to the possible inconsistency problems it allows.
2019-03-21 18:19:10 +02:00
203bba0e1d Add support for multiple runtime error messages
Storing all the runtime errors makes it possible to return all of them
them via the REST API. MaxAdmin will still only show the latest error but
MaxCtrl will now show all errors if more than one error occurs.
2019-03-21 18:19:10 +02:00
74eeb64fba Don't close connections to servers being drained
The connections to servers being drained should not be closed like they
should be for servers in maintenance mode. The change in functionality
between 2.3 and develop caused the connections to be discarded if the
server was in either maintenance or drain mode.
2019-03-21 18:19:10 +02:00
8ed192892a Make worker-local data lookups faster
By using a std::vector to store the keys, the cost of key lookup goes down
in comparison with std::unordered_map. The downside is the increase in
memory use in certain situations but given the fact that the intended
purpose of worker-local data is to store global data, this is unlikely to
have observable negative side-effects. Depending on the implementations of
std::vector and std::unordered_map, the use of std::vector could even
result in a smaller memory footprint.
2019-03-21 18:19:10 +02:00
494a8a660a Improve RoutingWorker utilities
Added an overload to execute_concurrently that takes an std::function as a
parameter and added a const version of operator* for rworker_local. Also
removed the std::move of the return value in rworker_local::values as it
can prevent RVO from taking place.
2019-03-21 18:19:09 +02:00
0130bc16e2 Fix monitor alteration
Alterations to monitors are now done with all changes present in the first
call to configure. This fixes the case where two parameters depended on
each other and one would get configured before the other.
2019-03-21 18:19:09 +02:00
60917238c3 Format config.cc and config_runtime.cc 2019-03-21 18:19:09 +02:00
be13cbc751 Fix parameter declaration formatting
Uncrustify always forced insertion of tabs which led to mangled formatting
of the parameters. Placing each part on a separate line seems to work
better and produce a more readable output.
2019-03-21 18:19:09 +02:00
c2fc80f122 Fix monitor creation
When the monitor was created, no parameters were passed to it.
2019-03-21 18:19:09 +02:00
0f1bc60431 Fix masking and dwfwfilter compilation
The filters were broken by the merge.
2019-03-21 18:18:33 +02:00
9bc721afb6 Merge commit '11ee74bad327e7fb15e8388d20e7838b9e49cadf' into 2.3 2019-03-21 17:52:42 +02:00
3448a36b68 Fix runtime config error generation
The error string was passed as the format string.
2019-03-21 17:48:47 +02:00
9236ace077 MXS-2355 If client is using the wrong authenticator, attempt a switch
Some SQL clients may default to a different authentication plugin than
"mysql_native_password". Since this is the only one supported by MySQL-
authenticator, the client is instructed to swap its plugin.
2019-03-21 17:07:09 +02:00
216eb904c5 MXS-1991 Allow replication_user and replication_password be set runtime
Because runtime changes are performed one at a time, adding replication credentials
to a mariadbmon which didn't have any would cause an error to be printed, and
the monitor would not start.

This is now fixed by allowing replication_user without replication_password. This
is not an ideal solution as a configuration file with only replication_user would be
accepted. Also, when adding the credentials to a monitor, replication_user must be
given first to avoid the error.
2019-03-21 17:06:24 +02:00
559b786533 MXS-2398 Handle MariaDB specific comments
Same approach as with regular comments:
- /*M! STMT */ are always parsed.
- /*M!###### STMT */ are never parsed.
2019-03-21 14:57:24 +02:00
11ee74bad3 Free the readwritesplit query queue
If the queue isn't empty when the session closes, the queue would leak.
2019-03-21 11:22:40 +02:00
2c4228db47 MXS-2400 Extend examplefilter
Added more comments. Also the filter now demonstrates how to
1) read configuration parameters
2) react to queries and replies
3) handle shared filter data
4) print diagnostics output
5) add log entries

As the filter is already built and moved to the library directory,
it is immediately usable. This should be helpful with assignments.
2019-03-21 11:02:16 +02:00
2ba7e63e7e Merge branch '2.3' into develop 2019-03-21 09:26:06 +02:00
65b4ac7c1b MXS-2389 Handle MariaDB comment correctly
A non version specific executable comment, such as "/*! SELECT 1; */"
is during classification handled as if it would not be a comment. That
is, the contained statement will *always* be parsed.

A version specific executable comment, such as "/*!99999 CREATE PROCEDURE
 bypass BEGIN */ SELECT ... " is during classification handled as it would
be a general comment. That is, the contained statement will *never* be
parsed.

In addition, in the latter case the parse result will never be better than
QC_QUERY_PARTIALLY_PARSED. The rationale is that since the comment is version
specific, we cannot know how the server will actually interpret the statement.

This will have an impact on the masking filter and the database firewall that
now will reject statements containing _version specific_ executable comments.
2019-03-20 16:17:50 +02:00
9b27d7f24b MXS-2396 Reject use of masked var in variable definition
E.g.

   set @a = (SELECT fld FROM table);

will be rejected if 'fld' is a field that should be masked.
2019-03-20 15:11:58 +02:00
eb0f3ebe81 MXS-2396 Cleanup conceptually 2019-03-20 15:11:58 +02:00
7bb3cc6535 MXS-2396 Make preparations for adding additional checks 2019-03-20 15:11:58 +02:00
76ac63096c MXS-2396 Add check_user_variables configuration parameter
The masking filter should check for things like

    set @ssn = (SELECT ssn FROM users WHERE id = 1);

so that

    select @ssn;

is not possible.
2019-03-20 15:11:58 +02:00
09ae5d741c MXS-2384 Update servers concurrently in MariaDB-Monitor
All servers are now updated in their own threads simultaneously. This
should reduce the possibility of having significantly different gtid:s
shown for different servers.
2019-03-20 10:40:45 +02:00
3ac1b40b63 MXS-2271 Refactor disk space checking
The functions are now in MonitorServer. Disk space can only be checked
during specific ticks. If a server misses a tick (e.g. is down) it will
be checked after disk_space_check_interval has passed.
2019-03-20 10:40:45 +02:00
0b77c3f05f MXS-2324: Prevent stack overflow with large results
If a result consists of only OK packets, they would be processed
recursively which most of the time leads to a stack overflow. This can be
prevented by consuming all OK packets in the result in one go.
2019-03-20 10:29:03 +02:00
a6f52b008f MXS-2390 Firewall should reject statements prepared from var
Currently no practical way for checking what the statement
actually does and thus blanket rejection is the only alternative.
2019-03-19 15:53:46 +02:00
cc3891a43c Fix test_modulecmd
The test created a mariadbmonitor without a valid configuration. The
test worked before because only the base monitor configuration was checked.
2019-03-19 15:04:42 +02:00
6b14479b6c MXS-2271 Rename MXS_MONITORED_SERVER to MonitorServer 2019-03-19 13:32:38 +02:00
09d9570c7e MXS-2392 MXS-2390 Add new test cases
Checks that prepared statements are checked.
2019-03-19 13:09:16 +02:00
8e0ee34a94 MXS-2392 MXS-2390 Handle prepared statements in masking filter
- Check textual prepared statements for use of columns to be masked
  in conjunction with functions.
- Check binary prepared statements for use of columns to be masked
  in conjunction with functions.
- Prevent creation of textual prepared statement from variable.
2019-03-19 12:31:08 +02:00
7f1c44cf62 MXS-2393 Reject statement that cannot be parsed completely
As the masking filter must reject statements that use columns to be
masked as arguments to functions, a statement that cannot be fully
parsed must be rejected. Unless a statement can be fully parsed we
cannot know whether such usage occurs.
2019-03-19 10:47:37 +02:00
c393d633fe MXS-2394 Accept substitute_variables
'substitute_variables' was not listed amongst the symbols that
are pre-parsed, which meant that it was always rejected.
2019-03-19 09:35:18 +02:00