177 Commits

Author SHA1 Message Date
Esa Korhonen
78cc5b2445 Move packet_tracker.cc under maxscale
It depends on MaxScale-types. This also removes the maxsql-pcre2-dependency.
2019-09-18 12:19:09 +03:00
Markus Mäkelä
44d1b821c3
Merge branch '2.3' into develop 2019-06-03 13:54:55 +03:00
Markus Mäkelä
4e6ca33053
Add UBSAN flag to builds
The -DWITH_UBSAN flag enables the undefined behavior detection provided by
GCC.
2019-05-31 14:01:14 +03:00
Esa Korhonen
fadbc0b1ae Separate Monitor management to its own file
Allows better separation of file local data. Also allows moving monitor-
related code from config_runtime.cc.
2019-04-25 12:32:41 +03:00
Johan Wikman
09702ab0a0 MXS-2346 Provide new configuration mechanism
The configuration mechanism consists of the following concepts:

Specification
  Specifies the available configuration parameters of a module,
  their names and their types.
Param
  Specifies a parameter, its name and its type.
Type
  Specifies the type of a configuration parameters; Bool, Size,
  Count, etc.
Configuration
  Specifies the configuration values of a particular instance of
  the module. Configuration walks hand in hand with Specification,
  the latter specifies what the former should contain.

A Specification is capable of configuring a Configuration from a
MXS_CONFIG_PARAMETER, checking in the process that all parameters
are of the correct type and that the required parameters are present.

A Specification is capable of persisting itself so that it later
can be read back.

The mechanism is closed for modification but open for extension in
the sense that if a module requires a custom parameter, all it needs
to do is to derive one class from Param and another from Type.

The canonical way for using this mechanism is as follows. Consider
a module xyx that has three parameters; a parameter called
"enabled" that is of boolean type, a parameter called "period"
that is of duration type, and a parameter "cache" that is of
size type. That would be declared as follows:

    // xyz.hh
    class XYZSession;

    class XYZ : public maxscale::Filter<XYZ, XYZSession>
    {
    public:
        static XYZ* create(const char* zName, MXS_CONFIG_PARAMETER* pParams);

    private:
        XYZ();

        static config::Specification                       s_specification;
        static config::ParamBool                           s_enabled;
        static config::ParamDuration<std::chrono::seconds> s_period;
        static config::ParamSize                           s_cache;

        config::Configuration                              m_configuration;
        config::Bool                                       m_enabled;
        config::Duration<std::chrono::seconds>             m_period;
        config::Size                                       m_cache;
    };

    // xyz.cc

    config::Specification XYZ::s_specification(MXS_MODULE_NAME);

    config::ParamBool XYZ::s_enabled(
        &s_specification,
        "enabled",
        "Specifies whether ... should be enabled or not."
        );
    config::ParamDuration<std::chrono::seconds> XYZ::s_period(
        &s_specification,
        "period",
        "Specifies the period. Rounded to the nearest second."
        );
    config::ParamSize XYZ::s_cache(
        &s_specification,
        "cache",
        "Specifies the size of the internal cache."
        );

    XYZ::XYZ()
        : m_configuration(&s_specification)
        , m_enabled(&m_configuration, &s_enabled)
        , m_period(&m_configuration, &s_period)
        , m_cache(&m_configuration, &s_cache)
    {
    }

    XYZ* XYZ::create(const char* zName, MXS_CONFIG_PARAMETER* pParams)
    {
        XYZ* pXyz = new XYZ;

        if (!s_specification.configure(pXyz->m_configuration, pParams))
        {
            delete pXyz;
            pXyz = nullptr;
        }

        return pXyz;
    }
2019-04-12 15:03:02 +03:00
Markus Mäkelä
1c3a5bda83
Merge branch '2.3' into develop 2019-03-11 12:29:56 +02:00
Markus Mäkelä
247e558ffa
Fix tls-model exposure to other modules
The flag was propagated to other modules that depend on it.
2019-03-08 12:10:31 +02:00
Markus Mäkelä
6038f1f386
Merge branch '2.3' into develop 2019-02-01 13:55:54 +02:00
Markus Mäkelä
08dd55a26a
Use -ftls-model=initial-exec with maxscale-common
Resolving the relocations right at startup reduces the cost of using
thread-local variables.
2019-02-01 13:20:44 +02:00
Johan Wikman
6ba2cb61df MXS-2218 Implement housekeeper in terms of MainWorker 2019-01-08 16:01:36 +02:00
Johan Wikman
10216524ab MXS-2218 Add skeleton MainWorker
First step in the introduction of a MainWorker. When finished, all
routing workers will run in separate threads (currently one runs in
the main thread), and the main worker run in the main thread.

Housekeeper will disappear and to the extent housekeeping tasks are
needed (where applicable they will be changed into delayed calls)
they will be run by the main worker.
2019-01-08 16:01:36 +02:00
Esa Korhonen
760f2ff34c Move alloc.cc to maxbase
Only renames the functions. Macro names are left as is to keep the diff
small.
2018-12-03 10:20:45 +02:00
Esa Korhonen
0c7e737eb7 Move some mysql/mariadb utilities to maxutils
Can be used in system tests later on.
2018-11-30 13:03:37 +02:00
Esa Korhonen
17d46d9166 Compile maxkeys and maxpasswd as C++ 2018-11-30 10:59:32 +02:00
Niclas Antti
c692c864e2 MXS-2078 Take new statistics into use 2018-11-08 10:44:32 +02:00
Markus Mäkelä
8b9fdaa0cb
Remove HTTP functionality
It wasn't used so it can be removed.
2018-10-03 08:41:45 +03:00
Markus Mäkelä
bb8245d2c1
Merge branch '2.2' into develop 2018-09-30 21:26:47 +03:00
Markus Mäkelä
fc1e36429c
MXS-2067: Replace SPINLOCK with pthread_mutex_t
Replaced the SPINLOCK implementation with pthread_mutex_t. The SPINLOCK
interface is still used and will be removed later on.
2018-09-28 12:18:23 +03:00
Markus Mäkelä
104a6d1bfb
Explicitly link against ASAN libraries
Some systems (Ubuntu Trusty) require explicit linking against ASAN
libraries.
2018-09-28 11:05:51 +03:00
Markus Mäkelä
09a64753f1
MXS-2068: Move RWBackend into mysqlcommon
This cleanly allows multiple modules to use it.
2018-09-26 09:43:25 +03:00
Markus Mäkelä
58c0b4f5f4
MXS-1632: Remove the unused statistics code
The statistics code was almost completely unused.
2018-09-10 14:14:20 +03:00
Markus Mäkelä
f8fb9510c9
Add HTTP GET function
The function performs a HTTP GET on a URL and returns the HTTP response.
2018-08-23 15:46:45 +03:00
Johan Wikman
88c3cd567d Remove HASHTABLE
Not used anyware, should have been removed ages ago.
2018-08-22 10:48:12 +03:00
Johan Wikman
88f1795412 MXS-2008 Move Worker and MessageQueue to maxbase 2018-08-21 10:02:39 +03:00
Johan Wikman
d8255d0cac MXS-2017 Move maxscale::Semaphore to maxbase::Semaphore 2018-08-17 15:53:54 +03:00
Markus Mäkelä
f09afa2967
Combine regression test suite and main CMake projects
Combining the projects makes it easier to use common components. This
fixes the build failure of maxutils due to missing jansson definitions.
2018-08-17 14:29:28 +03:00
Johan Wikman
cf0aeed516 MXS-2014 Rename log_manager.h to log.h
There's nothing resembling a manager anymore.
2018-08-17 10:59:37 +03:00
Johan Wikman
f3f802cabe MXS-2008 Move maxscale/atomic.h to maxbase/atomic.h 2018-08-15 08:44:39 +03:00
Markus Mäkelä
c543525c1b
MXS-2005: Move Logger into maxutils
Moved the logger into the maxutils library as it is a generic
utility. Also moved mxs_strerror into it as it depends on it.
2018-08-14 14:57:34 +03:00
Markus Mäkelä
39ce6c624f
MXS-2005: Remove unused code
Removed skygw_utils and relate files along with the old log manager
code. Also removed file flushing due to it being redundant; messages are
written to the file immediately. Adjusted tests to accommodate this
change.
2018-08-14 14:57:33 +03:00
Markus Mäkelä
fd5a2305e4
MXS-2005: Take Logger into use in log_manager
The log manager now uses the logger type for logging. Removed some of the
code that depended on the renamed functions to make it compile. The next
step is to remove all unused code in the log manager.
2018-08-14 14:57:33 +03:00
Johan Wikman
0c56be1e58 MXS-2004 Remove maxscale/thread.h and server/core/thread.cc
Not used anymore.
2018-08-13 13:38:39 +03:00
Markus Mäkelä
2852530893
Use standard RNG
The custom random number generator can now be replaced with a C++11
RNG. This greatly improves the reliability and trustworthiness of it.

In addition to this, the conversion of the RNG to a thread-local object
removes the race condition that was present in the previous
implementation. It also theoretically improves performance by a tiny bit.
2018-08-13 10:37:48 +03:00
Markus Mäkelä
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
Markus Mäkelä
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
Johan Wikman
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
Johan Wikman
75b5f57d51 MXS-1775 Add function for obtaining the server disk space
From 10.1.32, 10.2.14 and 10.3.6 onwards, there is an
information_schema plugin called DISKS using which information
about the disk space situation on the server can be obtained.

Subsequent commits will add configuration options for specifying
limits and take the functionality in use in monitors where it makes
sense.
2018-05-15 11:09:52 +03:00
Johan Wikman
b36f6faa7e MXS-1754 Reintroduce maxscale::Worker
Worker is now the base class of all workers. It has a message
queue and can be run in a thread of its own, or in the calling
thread. Worker can not be used as such, but a concrete worker
class must be derived from it. Currently there is only one
concrete class RoutingWorker.

There is some overlapping in functionality between Worker and
RoutingWorker, as there is e.g. a need for broadcasting a
message to all routing workers, but not to other workers.

Currently other workers can not be created as the array for
holding the pointers to the workers is exactly as large as
there will be RoutingWorkers. That will be changed so that
the maximum number of threads is hardwired to some ridiculous
value such as 128. That's the first step in the path towards
a situation where the number of worker threads can be changed
at runtime.
2018-04-16 14:53:08 +03:00
Johan Wikman
230876cd69 MXS-1754 Rename mxs::Worker to mxs::RoutingWorker
A new class mxs::Worker will be introduced and mxs::RoutingWorker
will be inherited from that. mxs::Worker will basically only be a
thread with a message-loop.

Once available, all current non-worker threads (but the one
implicitly created by microhttpd) can be creating by inheriting
from that; in practice that means the housekeeping thread, all
monitor threads and possibly the logging thread.

The benefit of this arrangement is that there then will be a general
mechanism for cross thread communication without having to use any
shared data structures.
2018-04-16 14:53:08 +03:00
Johan Wikman
1556bac6e4 MXS-1625 Add QueryClassifier class
This is the first step in providing a QueryClassifier class
that is capable of performing context dependent query classification,
where the context is essentially the session state.
2018-04-03 16:02:18 +03: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
Johan Wikman
6410b4f19a MXS-1633 Turn off collecting of sqlite3 memstats
According to customer reports collecting the statistics has a significant
impact on the performance. As we don't need that information we can just
as well turn off that.

Further, since maxscale-common now links to the sqlite3-library, no
module needs to do that explicitly.
2018-01-30 13:58:37 +02:00
Markus Mäkelä
6054fa0957 Add dependency on libmicrohttpd for maxscale-common
The core library needs to be built after libmicrohttpd.
2017-11-22 18:37:45 +02:00
Johan Wikman
42d9064b04 Remoeve queuemanager.[h|cc] 2017-11-08 10:44:14 +02:00
Markus Mäkelä
854c4a1ed3 Add support for non-glibc systems
MaxScale can now be built on systems that use an alternative libc
implementation e.g. musl.
2017-08-02 11:51:55 +03:00
Markus Mäkelä
61241f9e07 Remove old feedback system
The feedback system wasn't used and was starting to cause problems on
Debian 9 where the libcurl required different version of OpenSSL than what
MaxScale was linked against.
2017-07-10 16:03:50 +03:00
MassimilianoPinto
cb57e10761 Develop merge
Develop merge
2017-06-29 15:34:22 +02: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
Markus Mäkelä
75e7ac35ed MXS-1220: Always build libmicrohttpd
This allows MaxScale to use the PATCH functionality that's only in the
newer versions of the library. It also removes some of the problems that
exist with older systems that don't support all of the options.
2017-05-24 15:05:10 +03:00
Markus Mäkelä
ca62749f25 MXS-1220: Factor out common code from JSON object creation
The JSON objects that are created from the various core MaxScale objects
share a lot of common code. Moving this into a separate files removes the
redundant code.
2017-05-09 15:32:41 +03:00