9932 Commits

Author SHA1 Message Date
Esa Korhonen
5112cb4cfc MXS-1703: Stop monitor before reading class data
In theory, the value of m_master could change between reading it to
local variable and stopping monitor. To be on the safe side, stop the
monitor first.
2018-03-20 15:46:06 +02:00
Esa Korhonen
09a22b26c8 MXS-1703 Fix uninitialized pointer in manual switchover
If the current master was given by user, maxscale would crash.
2018-03-20 14:30:15 +02:00
Markus Mäkelä
e4efc29297
MXS-1702: Process comments when canonicalizing
The canonicalization process now strips non-executable comments from the
SQL and replaces all constants in executable comments.

Enabled the comment test and updated expected output of the select and
alter tests.
2018-03-20 13:53:55 +02:00
Markus Mäkelä
9fe25c8003
MXS-1702: Update tests
Updated tests with new expected output. Also took new function into use
and removed the old one.

Since the comment removal isn't added yet, one of the tests is expected to
fail and it is temporarily disabled.
2018-03-20 13:53:55 +02:00
Markus Mäkelä
a627e342f3
MXS-1702: Fix minor canonicalization bugs
Allow hexadecimal digits if a 0x prefix has been seen. Squash repeating
whitespace and remove quotes from quoted strings.
2018-03-20 13:53:55 +02:00
Markus Mäkelä
8d3f02b8a4
MXS-1702: Canonicalize negative numbers
The new canonicalization function now processes negative numbers
correctly. It uses a look-behind operation to detect whether the operation
is a negation of a number or a subtraction from another value.
2018-03-20 13:53:55 +02:00
Markus Mäkelä
75fadd711a
MXS-1702: Add new canonicalization function
The function uses a hand-written parser that picks out the values and
replaces them with question marks. This function is not yet able to
process negative values; a `-?` token will be generated for all negative
numbers.

The new function will canonicalize the query in such a way that string and
number constants cannot be distinguished which means that it won't pass
the current test cases.
2018-03-20 13:53:55 +02:00
Markus Mäkelä
a03e8d46f0
MXS-1702: Rename tests
The test naming now follows the common convention.
2018-03-20 13:53:55 +02:00
Markus Mäkelä
e90c29cce2
MXS-1702: Clean up and convert test to C++
Cleaned up and updated the test; the code was written with a pre-C99
standard in mind.

Added a get() method into mxs::Buffer to make it easier to use with
non-C++ functions.
2018-03-20 13:53:54 +02:00
Markus Mäkelä
cb170eb88e
MXS-1702: Move canonicalization test into core
Moved the test into the core where it belongs.
2018-03-20 13:53:54 +02:00
Markus Mäkelä
3e0b3db65e
MXS-359: Fix master_failure_mode=fail_instantly
The connection was not closed when master_failure_mode=fail_instantly was
used. This caused rwsplit_readonly to fail.
2018-03-20 13:42:25 +02:00
Markus Mäkelä
0fde6e501d
Don't treat EINTR as an error
When the epoll_wait call returns with an error and errno is set to EINTR,
no warning should be logged as this is correct behavior.
2018-03-20 13:42:25 +02:00
Markus Mäkelä
e45759d35d
Skip scanning of OK packets if preparing statement
The OK packet that a COM_STMT_PREPARE returns is not a normal OK packet
and need to be skipped as the packet layout is different.
2018-03-20 13:42:25 +02:00
Markus Mäkelä
10a9d70851
Get service capabilities from a better source
The DCB pointer in the MySQLProtocol struct doesn't appear to be updated
in all cases which causes it to be an unreliable source. As the session
itself is always available and it always has the service pointer properly
set, it should be used instead.

Also removed the dead protocol compression code and replaced the
parameters with the service capability bits.
2018-03-20 13:42:25 +02:00
Markus Mäkelä
20c5ca1619
Make session state change tracking conditional
By making it conditional, we prevent the problems that arise when the
replication protocol is used in combination with the session state change
tracking. In addition to this, it prevents unnecessary work for routers
and filters that don't need it.
2018-03-20 13:42:24 +02:00
Markus Mäkelä
f525822472
Merge branch '2.2' into develop 2018-03-20 13:14:54 +02:00
Markus Mäkelä
04ca9658c5
Use correct executable name
The test executable name had a typo in it.
2018-03-20 13:11:52 +02:00
Johan Wikman
ad05019445 Avoid clashes with TRUE/FALSE
TRUE/FALSE may be visible as defines. Consequently better
not to use them as names.
2018-03-20 13:10:31 +02:00
Markus Mäkelä
0b89bc167a
Correct listener port and socket documentation
Remove the old paragraph and added a note about defining separate
listeners for UNIX domain sockets and network ports.

Also fixed the example listener definition.
2018-03-20 13:07:28 +02:00
Markus Mäkelä
39dff20a0a
Use correct callback function in MySQLAuth
The JSON diagnostics function used the non-JSON version of the callback.
2018-03-20 13:07:27 +02:00
Markus Mäkelä
dcf9d7f152
Fix calls to diagnostics_json
Add missing listener JSON diagnostics call. Check that the
diagnostics_json function exists before calling it.

As the protocol modules don't have diagnostics functions, they aren't
called.

Replace hard-coded strings with constant parameters. This makes it
slightly cleaner.
2018-03-20 13:07:27 +02:00
Markus Mäkelä
94f29a11c5
MXS-1724: Reimplement core dump detection
Reimplemented the core dump detection for 2.2.
2018-03-20 13:06:20 +02:00
Markus Mäkelä
b0e0a79b46
Merge branch '2.1' into 2.2 2018-03-20 12:38:23 +02:00
Markus Mäkelä
28e4133669
Add missing jansson dependency on maxscale-common
The Jansson library must be built or must exist before MaxScale.
2018-03-20 12:35:06 +02:00
Markus Mäkelä
02368473f7
Fix failover_mysqlmon
The test should stop MaxScale when it is fixing the replication to prevent
the triggering of the standalone master detection.

Also removed leading spaces from the messages and fixed a possible crash with a
NULL value given to `ssh_node`.
2018-03-20 10:59:08 +02:00
Markus Mäkelä
64ccb67897
Mark crashing tests as failed
If a test generates a core dump, it is marked as a failure.
2018-03-20 10:59:08 +02:00
Johan Wikman
2dacd0c9a4 Add Changelog and Releasenotes to 2.1.15 2018-03-20 09:29:53 +02:00
Esa Korhonen
1bef791572 MXS-1703 Miscellaneous cleanup
1. Move some remaining class data private.
2. Linebreak long lines.
3. Move current master autoselection inside class method.
4. Remove single-use constant #defines.
5. Monitor status is only written inside loop.
2018-03-19 16:08:28 +02:00
Esa Korhonen
aa260cf6cf MXS-1716 Reduce the amount of duplicate elements in users db for PAM
The database-level query now only takes rows with either a global
select privileges or non-null database privileges. The table-level
query only accepts non-null databases and no global privileges,
as users with global select are added by the previous section.
2018-03-19 15:09:36 +02:00
Esa Korhonen
04666b4b31 MXS-1716 Add diagnostic functions to PAM Authenticator
The functions print the user information. Normal version just prints
user@host, the json-version prints the whole array.
2018-03-19 11:02:14 +02:00
Esa Korhonen
4a6fc6b1c8 MXS-1703 Rearrange functions and methods
Lots of cleanup, but mostly distributing functions/methods to correct files.
2018-03-16 18:35:17 +02:00
Timofey Turenko
022c226d4b
Mxs 1665 keepalived masterdown test (#171)
* add keepalived_masterdown test

* add missing cnfs
2018-03-16 15:14:14 +02:00
Johan Wikman
3331eb9eb6 MXS-1475 Fix typos 2018-03-16 14:34:04 +02:00
Johan Wikman
749f43a70e MXS-1475 Add system test for @maxscale.cache.(soft_ttl|hard_ttl) 2018-03-16 14:34:04 +02:00
Johan Wikman
51251fd9f3 MXS-1475 Introduce @maxscale.cache.[soft_ttl|hard_ttl]
Now it is possible to control the soft and hard ttl of the
cache on a session basis. That is, it is possible to use
different TTLs for different SELECTs.
2018-03-16 14:34:04 +02:00
Johan Wikman
2c49f90bc4 MXS-1475 Allow caller to specify (soft|hard) TTL
As the TTL is checked at lookup time, it need not be hardwired
when the storage instance is created. With this changed it is
possible to introduce @maxscale.cache.(soft|hard)_ttl user
variables using which a client can control what TTL should be
applied for a particular kind of data, which is requested by
MXS-1475.
2018-03-16 14:34:04 +02:00
Johan Wikman
0ef902621d MXS-1475 Update cache entry if originally present
In case the entry in the cache can not be used because the hard
TTL has kicked in, we fetch the data and update the cache
irrespected of the value if @maxscale.cache.populate. That way
an entry that once was put in the cache, will remain in the cache
(as long as there is space).
2018-03-16 14:34:04 +02:00
Johan Wikman
4ce894d24d MXS-1475 Report if hard TTL has hit in
If an entry is not returned because the hard TTL had hit in,
we tell about it so that the caller can act differently in that
case.
2018-03-16 14:34:04 +02:00
Johan Wikman
38d20c1575 MXS-1475 Remove all traces of RocsDB cache storage
Some API changes are needed and it's not time well spent to
update the RocksDB storage implementation.
2018-03-16 14:34:04 +02:00
Johan Wikman
2ec19e2358 MXS-1475 Add test case for @maxscale.cache.[use|populate]
Also extend logging.
2018-03-16 14:34:04 +02:00
Johan Wikman
82b55ff362 MXS-1475 Add @maxscale.cache.[populate|use]
The earlier @maxscale.cache.enabled has now been replaced with
@maxscale.cache.populate and @maxscale.cache.use that provide
for more flexibility.

With the former it is possible to control in what circumstances
the cache is populated and with the latter one when it is used.
Together they can be used for having a completely client driven
caching.
2018-03-16 14:34:04 +02:00
Johan Wikman
34dd8a52bb MXS-1475 Allow the setting on N vars with one stmt
With this change, the following will be possible.

SET @maxscale.cache.populate=false, @maxscale.cache.use=true;
2018-03-16 14:34:04 +02:00
Johan Wikman
805e3578a2 MXS-1475 Address review issues
- Clean up session header.
- Add test case
2018-03-16 14:34:04 +02:00
Johan Wikman
23b8939e20 MXS-1475 Update cache documentation 2018-03-16 14:34:04 +02:00
Johan Wikman
2d20a19f12 MXS-1475 Act accordingly if cache disabled
If caching is dynamically disabled, then CACHE_USE_AND_POPULATE is
turned into CACHE_POPULATE leading to the cache being refreshed but
not used.
2018-03-16 14:34:04 +02:00
Johan Wikman
090892db4c MXS-1475 Add 'enabled' parameter to Cache filter
With 'enabled' it can be specified whether the cache should initially
be enabled or disabled. Useful as it is now possible to enable/disable
the cache dynamically.
2018-03-16 14:34:04 +02:00
Johan Wikman
71c8a327b2 MXS-1475 Introduce variable @maxscale.cache.enabled
With the variable @maxscale.cache.enabled the caching can be
enabled/disabled at runtime.

In a subsequent commit, the variable will actually be used.
2018-03-16 14:34:04 +02:00
Johan Wikman
2434482dc6 MXS-1475 Attempt to set unknown MXS user variable causes error
By causing an error if an unknown MaxScale user variable is set,
the user will become aware of typos etc.
2018-03-16 14:34:04 +02:00
Johan Wikman
872a51a376 MXS-1475 Enable MaxScale specific user variables
With the changes in this commit it is possible to add and remove
MaxScale specific user variables. A MaxScale specific user variable
is a user variable that is interpreted by MaxScale and that
potentially changes the behaviour of MaxScale.

MaxScale specific user variables are of the format "@maxscale.x.y"
where "@maxscale" is a mandatory prefix, x a scope identifying the
component that handles the variable and y the component specific
variable. So, a variable might be called e.g. "@maxscale.cache.enabled".
The scope "core" is reserved (although not enforced yet) to MaxScale
itself.

The idea is that although MaxScale catches these, they are passed
through to the server. The benefit of this is that we do not need to
detect e.g. "SELECT @maxscale.cache.enabled", but can let the result
be returned from the server.

The interpretation of a provided value is handled by the component that
adds the variable. In a subsequent commit, it will be possible for a
component to reject a value, which will then cause an error to be
returned to the client.

There are 3 new functions:

- session_add_variable() using which a variable is added,
- session_remove_variable() using which a variable is removed, and
- session_set_variable_value().

The two former ones are to be called by components, the last one by
the protocol that catches the "set @maxscale..." statements.
2018-03-16 14:34:04 +02:00
Johan Wikman
5dfa0c1226 MXS-1475 Take SetParser and SqlModeParser into use
These changes are the first in the route toward supporting
MaxScale specific variables such as

    set @MAXSCALE.CACHE.ENABLED=TRUE
2018-03-16 14:34:04 +02:00