2695 Commits

Author SHA1 Message Date
Markus Mäkelä
b80f394cd0 Use explicit types
Use uint64_t instead of unsigned. This guarantees that the size of the
type is the same across all platforms.
2017-11-14 16:53:09 +02:00
Johan Wikman
b2b72474d9 Initialize thread as well in test_trxtracking 2017-11-10 14:45:54 +02:00
Johan Wikman
6cc8bc36c1 Initialize in test_dcb
Make necessary initializations in test_dcb.
2017-11-10 14:45:54 +02:00
Johan Wikman
f2b9525032 Initialize thread as well in test_trxcompare 2017-11-10 14:45:54 +02:00
Johan Wikman
f152c118cb Name core tests consistently
Now, given a concept xyz,
* the main test file is called test_xyz.cc
* the executable is called test_xyz, and
* the ctest test is called text_xyz.
2017-11-10 14:45:54 +02:00
Johan Wikman
e68f16b099 Merge branch '2.2' into 2.2-mrm 2017-11-09 09:41:58 +02:00
Johan Wikman
3dbd201a86 MXS-1478 Provide daemon flag
With "--daemon" or "-n" MaxScale can now be told to run in daemon
mode, that is, it forks and the parent exits. This is the default
behaviour, but a flag to this effect is needed if the default
behaviour is changed.
2017-11-09 09:34:23 +02:00
Johan Wikman
0558a2195d MXS-1479 By default, refuse to run as root
MaxScale now refuses to run as root. However, it is possible to
start MaxScale as root, as long as a user to run MaxScale as is
provided as a command line argument.

It is possible to run as root by invoking MaxScale as root and
by specifying the MaxScale user to be root.
2017-11-08 16:03:05 +02:00
Johan Wikman
3a35d49ffe Merge branch '2.2' into 2.2-mrm 2017-11-08 10:44:35 +02:00
Johan Wikman
42d9064b04 Remoeve queuemanager.[h|cc] 2017-11-08 10:44:14 +02:00
Johan Wikman
b1b78a5be7 Remove references to QUEUE_CONFIG
Only used in conjunction with queued connections, which are not
enabled anyway. Once that comes on the table again, better to use
some standard data structures.
2017-11-08 10:44:14 +02:00
Johan Wikman
d7b8e95234 MXS-1489 Create mechanism for running concurrent tasks
This commit introduces maxscale::future, maxscale::packaged_task
and maxscale::thread that are modeled after C++11 std::future,
std::packaged_task and std::thread as described here:
http://en.cppreference.com/w/cpp/thread

The standard classes rely upon rvalue references (and move
constructors) introduced by C++11. As the C++ compilers we must use
are pre-C++11 that feature is obviously not present. The absence of
rvalue references is circumvented by implementing regular copy
constructors and assignment operators as if the arguments were rvalue
references.

In practice the above means that when one of these objects are copied,
the state is _moved_ rendering the copied object in default initialized
state. Some care is needed to ensure that unintended copying does not
occur.
2017-11-07 12:03:09 +02:00
Markus Mäkelä
3a78b716b8 Merge branch '2.2' into 2.2-mrm 2017-10-30 11:06:34 +02:00
Markus Mäkelä
a971aa25da Merge branch '2.1' into 2.2 2017-10-30 11:01:19 +02:00
Markus Mäkelä
551bb81929 Loosen the atomicity requirement for the passive parameter
As the passive parameter is only used by the failover and the failover can
only be initiated by the monitor, there is no true need to synchronize the
reads and write of this parameter.

As all runtime changes are protected by the runtime lock, only partial
reads are of concern. For the supported platforms, this is not a practical
problem and it only confuses the reader when other variables are modified
without atomic operations.
2017-10-27 15:31:46 +03:00
Markus Mäkelä
600509be4a Fix master failure tracking
The master failure was assumed to be the only master related event for
each monitoring loop. If the master was switched by an external actor, the
monitor tracking would be out of sync.
2017-10-27 15:31:46 +03:00
Markus Mäkelä
0bc439641a Add helper function for reading values by field name
The helper function provides map-like access to row values. This is used
to retrieve the values for all MariaDB 10.0+ versions as there are
differences in the returned results between 10.1 and 10.2.
2017-10-27 15:31:46 +03:00
Markus Mäkelä
2d1e5f46fa Remove use of timestamps in failover code
Using timestamps to detect whether MaxScale was active or passive can
cause problems if multiple events happen at the same time. This can be
avoided by separating events into actively observed and passively observed
events. This clarifies the logic by removing the ambiguity of timestamps.

As the monitoring threads are separate from the worker threads, it is
prudent to use atomic operations to modify and read the state of the
MaxScale. This will impose an happens-before relation between MaxScale
being set into passive mode and events being classified as being passively
observed.
2017-10-27 15:31:46 +03:00
Esa Korhonen
63c7550196 MXS-1490 Prepare for failover functionality addition
Moved mon_process_failover() from monitor.cc to mysql_mon.cc. Renamed
some functions and variables related to previous failover functionality
to avoid confusion.
2017-10-25 12:24:29 +03:00
Markus Mäkelä
cd9a84d762 Add tests for direct relationship updating
The tests check that direct updates to the relationships endpoints work.
2017-10-23 19:37:24 +03:00
Markus Mäkelä
6918842585 Add direct relationship updating to REST API
The JSON API specification states that all resources must support direct
modification of resource relationships by providing only the definition
for a particular relationship type to a /:type/:id/relationships/:type
endpoint.

The relevant part of the JSON API specification:

    http://jsonapi.org/format/#crud-updating-to-many-relationships
2017-10-23 19:37:24 +03:00
Markus Mäkelä
7111724851 Fix REST API monitor relationship test
The test did not properly move the relationships from the old monitor to
the new one. The test to passed as the relationship modification was not
really tested.
2017-10-23 19:37:24 +03:00
Markus Mäkelä
b7b50959ac Update REST API tests
Extended the relationship checks in the REST API tests to actually verify
that the returned objects represent what is expected.
2017-10-23 19:37:24 +03:00
Markus Mäkelä
582a65f77c Do not return empty relationships
If no relationships of a particular type are defined for a resource, the
key for that relationship should not be defined.
2017-10-23 19:37:24 +03:00
Markus Mäkelä
d371ecb30f Only remove explicitly deleted relationships
Only when a relationship is defined as a null JSON value, it should be
deleted. If it is missing, it should be ignored.
2017-10-23 19:37:24 +03:00
Markus Mäkelä
0b1e2ae0a5 Improve error messages for service parameter changes
Made the error messages clearer when an attempt to change service
parameters that cannot be altered at runtime is made.
2017-10-23 17:34:11 +03:00
Markus Mäkelä
ff8916046c Add link to documentation in --help output
The link points to the MaxScale 2.1 documentation root.
2017-10-21 14:55:56 +03:00
Johan Wikman
d1df1837a4 MXS-1464 When pre-parsing, only check maxscale section
When pre-parsing the configuration file, the existence of environment
variables is only done for the [maxscale] section. For other sections
a nicer error message is obtained if the comlplaint is made when the
configuration file is actually loaded.

Mechanism for providing custom error message from the pre-parsing
function added.
2017-10-12 14:56:09 +03:00
Johan Wikman
22f4b02b44 MXS-1464 Substitute environment variables
If 'substitute_variables' has been set to true, then the value of
a parameter like `some_param=$SOME_VAR' is replaced with the value
of the environment variable 'SOME_VAR'.

It is a fatal error to refer to a variable that does not exist.
2017-10-12 14:56:09 +03:00
Johan Wikman
1666c9f0b6 MXS-1464 Add config 'substitute_variables'
With this variables set to true, if $VAR is used as a value in the
configuration file, then `$VAR` will be replaced with the value of
the environment variable VAR.
2017-10-12 14:56:09 +03:00
Markus Mäkelä
9c03a785ce Fix resultset handling with binary data
When binary data was processed, it was possible that the values were
misinterpreted as OK packets which caused debug assertions to trigger.

In addition to this, readwritesplit did not handle the case when all
packets were routed individually.
2017-10-12 12:29:43 +03:00
Markus Mäkelä
5cea0ede95 Fix hang on multi-statemet query
If multiple queries that only generate OK packets were executed, the
result returned by the server would consist of a chain of OK packets. This
special case needs to be handled by the modutil_count_signal_packets.

The current implementation is very ugly as it simulates a result with at
least one resultset in it. A better implementation would hide it behind a
simple boolean return value and an internal state object.
2017-10-12 12:29:43 +03:00
Markus Mäkelä
05e057a703 Fix buffer length calculation in modutil_count_signal_packets
The optimization of the buffer iteration did not decrement the total
buffer length.
2017-10-12 12:29:43 +03:00
Markus Mäkelä
97d0cc7482 Fix multi-statement execution in readwritesplit
A multi-statements can return multiple resultsets in one response. To
accommodate for this, both the readwritesplit and modutil code must be
altered.

By ignoring complete resultsets in readwritesplit, the code can deduce
whether a result is complete or not.
2017-10-12 12:29:43 +03:00
Markus Mäkelä
3afc89ae80 Fix debug assertion in modutil_count_signal_packets
The original offset needs to be separately tracked to assert that an OK
packet is not the first packet in the buffer. The functional offset into
the buffer is modified to reduce the need to iterate over buffers that
have already been processed.
2017-10-12 12:29:43 +03:00
Markus Mäkelä
426f80c8ef Fix muti-result handling in modutil_count_signal_packets
The function assumed that the buffer would not contain a trailing OK
packet that completes a multi-result response.
2017-10-12 12:29:43 +03:00
Markus Mäkelä
a04843da9d Add function for logging buffer contents as hex
The gwbuf_hexdump write the contents of the buffer into the info log. This
is quite helpful for debugging of protocol related problems.
2017-10-12 12:29:43 +03:00
Markus Mäkelä
f3b0245c0b Return results as sets of packets
Returning the results of a query as a set of packets is currently more
efficient. This is mainly due to the fact that each individual packet for
single packet routing is allocated from the heap which causes a
significant loss in performance.

Took the new capability into use in readwritesplit and modified the
reply_is_complete function to work with non-contiguous results.
2017-10-12 12:29:43 +03:00
Markus Mäkelä
0e7f592bd7 Add file names and line numbers to stacktraces
The GLIBC backtrace functionality doesn't generate file names and line
numbers in the generated stacktrace. This can to be done manually by
executing a set of system commands.

Conceptually doing non-signal-safe operations in a signal handler is very
wrong but as stacktraces are only printed when something has gone horribly
wrong, there is no real need to worry about making things worse.

As a safeguard for fatal errors while the stacktrace is being generated,
it is first dumped into the standard error output of the process. This
will function even if malloc is corrupted.
2017-10-12 12:29:43 +03:00
Johan Wikman
5d18ab86ea Allocate shared buffer and its data in one chunk
The GWBUF shared buffer and its data is now allocated in one
chunk so that the data directly follows the shared buffer.
That way, creating a GWBUF will involve 2 and not 3 calls to
malloc and freeing one will involve 2 and not 3 calls to free.
2017-10-12 12:29:43 +03:00
Markus Mäkelä
6c5fa071d5 Inline backend related functions
Inlined the getter/setter type functions that are often used. Profiling
shows that inlining the RWBackend get/set functions for the reply state
manipulation reduces the relative cost of the function to acceptable
levels. Inlining the Backend state function did not have as large an
effect but it appears contribute a slight performance boost.
2017-10-12 12:29:43 +03:00
Johan Wikman
5a585b1c8a Fix buffer overflow in test program 2017-10-12 12:29:43 +03:00
Markus Mäkelä
eac6d239fc MXS-1468: Fix created monitor serialization
When servers were added to monitors that were created at runtime, the
server list serialization overwrote the original persisted configuration
of the monitor. To solve this problem, the serialization of the server
list and the monitor parameters were combined.
2017-10-11 11:30:58 +03:00
Markus Mäkelä
88325a9d36 Fix resultset handling with binary data
When binary data was processed, it was possible that the values were
misinterpreted as OK packets which caused debug assertions to trigger.

In addition to this, readwritesplit did not handle the case when all
packets were routed individually.
2017-10-11 09:19:40 +03:00
Markus Mäkelä
c3627c83be Fix hang on multi-statemet query
If multiple queries that only generate OK packets were executed, the
result returned by the server would consist of a chain of OK packets. This
special case needs to be handled by the modutil_count_signal_packets.

The current implementation is very ugly as it simulates a result with at
least one resultset in it. A better implementation would hide it behind a
simple boolean return value and an internal state object.
2017-10-11 09:19:40 +03:00
Markus Mäkelä
820e86ac7d Fix buffer length calculation in modutil_count_signal_packets
The optimization of the buffer iteration did not decrement the total
buffer length.
2017-10-11 09:19:40 +03:00
Markus Mäkelä
42cb6bbff7 Fix multi-statement execution in readwritesplit
A multi-statements can return multiple resultsets in one response. To
accommodate for this, both the readwritesplit and modutil code must be
altered.

By ignoring complete resultsets in readwritesplit, the code can deduce
whether a result is complete or not.
2017-10-10 08:25:18 +03:00
Markus Mäkelä
d9922ac895 Fix debug assertion in modutil_count_signal_packets
The original offset needs to be separately tracked to assert that an OK
packet is not the first packet in the buffer. The functional offset into
the buffer is modified to reduce the need to iterate over buffers that
have already been processed.
2017-10-10 07:25:47 +03:00
Markus Mäkelä
cdf68ab86e Fix muti-result handling in modutil_count_signal_packets
The function assumed that the buffer would not contain a trailing OK
packet that completes a multi-result response.
2017-10-10 07:14:05 +03:00
Markus Mäkelä
139b974306 Add function for logging buffer contents as hex
The gwbuf_hexdump write the contents of the buffer into the info log. This
is quite helpful for debugging of protocol related problems.
2017-10-10 07:11:37 +03:00