Commit Graph

3147 Commits

Author SHA1 Message Date
1be9528227 MXS-1624 Provide initial implemenation of QC caching
The mapping from a canonical statement to the query classification
result is maintained by the class QCInfoCache of which there exist
an instance per thread. That way no locking is needed but the
information will be cached multiple times (but that is a smaller
price to pay). Currently the information is stored in a regular
std::unordered_map, which means that the consumed amount of
memory will just keep on growing unless the number of canonical
statements used by clients happens to have an upper bound.

The LRU cache (that provides means for putting a bound on the
amount of memory used and number of items) used in the cache filter
will be generalized and be taken into use here as well.

The key is now the canonical statement itself, which means that
a fair amount of memory will be used. To preserve memory it might
make sense to use a hashed value instead, although that at least
in principle opens up the possibility for unintended collisions.

This feature will also be made configurable.
2018-07-06 12:12:31 +03:00
d01db42679 MXS-1624 Clean up query_classifier.cc
Minor cleanup:
- Unit variables places in anonymous namespace.
- Unit variables accessed via this_unit struct.

This is the first commit of many where the mapping from canonical
statement to query classification result is introduced.

The mapping is placed above the actual query classifier, so that all
query classifiers will benefit from it.

The mapping will be maintained by thread so that there will not be
any synchronization issues. Further, initially a simple map without
upper boundary will be used; if this is found to provide measurable
benefits, the map will then be replaced with an LRU mechanism so
that it becomes possible to specify just how much memory the mapping
may use.
2018-07-06 12:12:31 +03:00
c89bdb9626 MXS-1823 Replace meaningless eventq info with meaningful
The evq_length file held the returned number of descriptors from
the last epoll_wait() call. As such it is highly temporal and not
particularly meaningful.

That has now been removed and the instead the average number of
returned descriptors is maintained. That information changes slowly
and thus carries some meaning.
2018-07-06 11:22:42 +03:00
702f8aaed4 Merge branch '2.2' into develop 2018-07-05 13:53:14 +03:00
7954de0da6 Always log commit ID
There's no good reason to not include the commit ID in release build
startup messages.
2018-07-05 12:01:38 +03:00
d3c1ec4742 MXS-1664 Add --runtimedir config parameter 2018-07-04 22:38:28 +03:00
44ef4912e8 Merge branch '2.2' into develop 2018-07-03 21:13:41 +03:00
fb1c28c702 MXS-1948: Do round-robin worker assignment
Due to the skewed accept distribution without SO_REUSEPORT, we use
round-robin assignment of workers for new client connections. This
provides better performance as work is more likely to be evenly
distributed across all threads.

Using a least-busy-worker algorithm would provide a more stable result but
this is not trivially simple to implement. For this reason, the
round-robin based approach was chosen for 2.2.
2018-07-03 12:49:59 +03:00
e455e7f15d MXS-1953: Always initialize the GWBUF spinlock
The spinlock in the buffer is used but it was not always initialized. Also
added missing initialization of the SERVER pointer.
2018-07-03 11:32:36 +03:00
7ded2c436f Fix monitor shutdown and restart
Monitor restart was not working.
2018-07-03 10:32:06 +03:00
9d5b8c8de2 Share data between identical session commands
If two or more session commands contain identical buffers, the buffer of
the first session command is shared between the others. This reduces the
amount of memory used to store repeated executions of session commands.

The purging of session command history in readwritesplit was replaced with
session command de-duplication. This was done to prevent problems that
could arise when the order of session commands plays a significant role.
2018-07-02 13:29:21 +03:00
295d59881e Remove spinlocks from GWBUF
The spinlock does not protect from or prevent misuse as buffers must not
be used concurrently by multiple threads.
2018-07-02 13:29:21 +03:00
b59f607471 MXS-1549: Track transaction type in the query classifier
The characteristics of a transaction can now be tracked by the query
classifier. This allows read-only and read-write transaction statistics to
be calculated.
2018-07-02 13:29:17 +03:00
a59c0c61ce Remove depth field from SERVER
It was not really used anymore.
2018-06-29 10:54:34 +03:00
0afcd4b468 Fix test-program failures
Due to recent changes, mxs::MessageQueue::init() must be called
explicitly, if a monitor is created.
2018-06-29 10:43:49 +03:00
dc4a555c70 Merge branch '2.2' into develop 2018-06-28 10:34:41 +03:00
b5fdcf66ab Make test_event.cc more resilient
- Work on both Debian and RedHat systems.
- Ignore test if authentication log cannot be found or cannot be read.
2018-06-27 09:30:31 +03:00
f49c31625d Use derived version of write for session commands
Prepared statements via readwritesplit need to have their IDs mapped from
the internal representation to the backend specific one. The RWBackend
class does this in its write method but the fix in commit
e561c3995c7396cf3749ccdf6a3357d7dd32c856 caused this to be bypassed and
the base version was always used.
2018-06-27 08:49:54 +03:00
f97f422379 Don't use closed backends
Only use backends that are still in use. The COM_STMT_EXECUTE and
COM_STMT_FETCH relationship caused unused backends to be used.
2018-06-27 08:49:21 +03:00
1eddb29d91 MXS-1915 Move Monitors on top of mxs::Worker
Monitors are now workers, so the path for making all interaction
between MaxScale proper and the monitors message based is now
open.
2018-06-26 09:19:46 +03:00
8ea7d8898a MXS-1915 Remove id from mxs::Worker
The id has now been moved from mxs::Worker to mxs::RoutingWorker
and the implications are felt in many places.

The primary need for the id was to be able to access worker specfic
data, maintained outside of a routing worker, when given a worker
(the id is used to index into an array). Slightly related to that
was the need to be able to iterate over all workers. That obviously
implies some kind of collection.

That causes all sorts of issues if there is a need for being able
to create and destroy a worker at runtime. With the id removed from
mxs::Worker all those issues are gone, and its perfectly ok to create
and destory mxs::Workers as needed.

Further, while there is a need to broadcast a particular message to
all _routing_ workers, it hardly makes sense to broadcast a particular
message too _all_ workers. Consequently, only routing workers are kept
in a collection and all static member functions dealing with all
workers (e.g. broadcast) have now been moved to mxs::RoutingWorker.

Now, instead of passing the id around we instead deal directly
with the worker pointer. Later the data in all those external arrays
will be moved into mxs::[Worker|RoutingWorker] so that worker related
data is maintained in exactly one place.
2018-06-26 09:19:46 +03:00
86b5238aaf MXS-1915 Replace worker id with worker pointer
To get rid of the need that a Worker must have an id, we store
in the MXS_POLL_DATA structure a pointer to the owning worker
instead of the id of the owning worker. This also allows some
further cleanup as the need for switching back and forth between
the id and the worker disappears.

The id will be moved from Worker to RoutingWorker as there
currently is a fair amount of code that assumes that the id of
routing workers start from 0.
2018-06-26 09:19:46 +03:00
241c9b645d MXS-1915 Remove unused functions 2018-06-26 09:19:46 +03:00
5cf6a9ed22 MXS-1915 Allow Worker to be used stand-alone
It's no longer necessary to inherit from Worker in order to use
it, but it can now be used in a stand-alone fashion. This fits
the MonitorInstance use-case better.
2018-06-26 09:19:46 +03:00
cc0299aee6 Update change date of 2.3 2018-06-25 10:07:52 +03:00
b8e0c31872 Merge branch '2.2' into develop 2018-06-25 09:37:18 +03:00
6183fab79b MXS-1938: Log query for inconsistent replies
If a session command produces a different result on the slave than it did
on the master, a warning is logged. This warning now also logs the query
that was being executed to make investigation of the problem easier.
2018-06-25 08:44:13 +03:00
3d8f946e19 Take dump_stacktrace into use
MaxScale and tests now both use the same code to dump stacktraces.
2018-06-22 13:59:57 +03:00
7254a7c525 Make maxutils a standalone library
The only way to cleanly separate the maxutils library from the MaxScale
CMake project is to make it a standalone CMake project. With the help of
ExternalProject, it should be relatively easy to use.
2018-06-22 13:59:57 +03:00
b96228f95c Merge branch '2.2' into develop 2018-06-22 10:44:39 +03:00
e561c3995c Use correct write in Backend::execute_session_command
Backend::execute_session_command would use the overridden write method
instead of the Backend::write method that it intended to use. This caused
session commands that did not expect a response to be in a state that
expected a result.

Also fixed RWBackend::write pass the response_type value to
Backend::write.
2018-06-22 10:37:11 +03:00
998798c90c Make test_event more reliable
Look for the expected message several times, with short sleeps in
between. That way we will not sleep more than necessary, yet will
not immediately give up either.
2018-06-21 15:42:50 +03:00
75ddfe4c14 Merge branch '2.2' into develop 2018-06-21 14:02:00 +03:00
45bda0f72e MXS-1936 Make qc_mysqlembedded compatible with qc_sqlite
qc_mysqlembedded must also be updated to handle the new type
QUERY_TYPE_DEALLOC_PREPARE. Some adjustements were also needed
elsewhere.
2018-06-21 12:51:47 +03:00
92b1767fb1 Merge branch '2.2' into develop 2018-06-21 11:45:23 +03:00
396f5d96c2 Merge branch '2.2' into develop 2018-06-20 14:43:03 +03:00
28ae1bf24e MXS-1932: Ignore hidden files in maxscale.cnf.d
All files that are hidden (i.e. start with a period) are now ignored by
the configuration file processing.
2018-06-20 14:41:55 +03:00
68e514f08b Fix test_event
If the logged line is found, it is not an error, if it is not,
it is.
2018-06-20 13:01:20 +03:00
026313fcc7 Clear status bits of server that are down
At the start of the monitor tick, the monitor pending status is set to the
value of the current server status. This allows the informative and
history bits to survive even if a server goes down.

To make sure that no stale state bits are in effect when the post_tick
method is called, the pending status must be cleared of all status bits.
2018-06-18 14:25:05 +03:00
13893cca3d MXS-1914: Move maxscale_shutdown() into the core
The core library now contains the maxscale_shutdown() command. This makes
it possible to resolve all symbols at link time even for administrative
modules.
2018-06-18 12:58:50 +03:00
df24f09ce5 Merge branch '2.2' into develop 2018-06-18 11:39:10 +03:00
6dd479104f MXS-421 Enable the turning on of events 2018-06-18 11:32:50 +03:00
6e3d3c0dcf MXS-421 Test that used facility has an effect
If the facility of an event is LOG_AUTH, it should by default
end up in /var/log/auth.log.
2018-06-18 11:32:50 +03:00
4c1b7f761c MXS-421 Add maxscale::event concept
MaxScale now defines events for which the syslog
facility and level can explicitly be defined by the
administrator. Currently there is only one such
event, namelt AUTHENTICATION_FAILURE.

In a subsequent commit, config.cc will be modified so
that event-related configuration parameters are passed
to event::configure() and in another subsequent commit
the authenticators will be modifed to use this mechanism.

In practice a line like:

   MXS_WARNING("%s: login attempt for user '%s'@[%s]:%s, "
               "authentication failed.",
               dcb->service->name, client_data->user,
               dcb->remote, dcb->path);

will be changed to

    MXS_LOG_EVENT(event::AUTHENTICATION_FAILURE,
                  "%s: login attempt for user '%s'@[%s]:%s, "
                  "authentication failed.",
                  dcb->service->name, client_data->user,
                  dcb->remote, dcb->path);
2018-06-18 11:32:50 +03:00
ca155fbfe9 Merge branch '2.1' into 2.2 2018-06-18 11:32:13 +03:00
8721c9117a Expose function for checking MYSQL connection errors
If a query done via the connector fails, the return value can be inspected
with the function. This helps separate fatal problems from transient ones.
2018-06-16 23:29:39 +03:00
2005164222 Fix slave reconnection logic
Allowing calls to select_connect_backend_servers even when all slaves are
connected solves the debug assertion in select_connect_backend_servers
that happens when the execution of a queued query causes a new connection
to be created.
2018-06-15 16:16:53 +03:00
3ed6411741 Fix debug assert on reconnection with session commands
When a query was routed to a server that must first be connected to, the
expected response count was not updated for the executed session commands.
2018-06-15 16:16:53 +03:00
bed1c60fd4 MXS-421 Allow specifying a facility when logging
In principle a syslog priority consists of a syslog level
bit-or:d with a syslog facility. That's clear from the syslog
man page, but not so clear from the code in syslog.h.

Anyway, to make it possible to log using a specific facility
(instead of the default LOG_USER), we must allow priorities
that include a specified facility.
2018-06-15 12:41:52 +03:00
a983df5a7e Fix testlogthrottling compilation failure
The ifstream constructor for some reason doesn't understand strings.
2018-06-15 11:45:40 +03:00