Commit Graph

60 Commits

Author SHA1 Message Date
df94ef990c Use module-type parameters for servers
The server base objects now use the module-type parameters for generic
configuration.
2018-07-17 11:52:20 +03:00
d28b1c9d1d Validate SSL parameters via the module-type parameters
The configuration system that modules use allows the SSL parameter
validation to be simplified. It should also provide more consistent error
messages for similar types of errors.

The SSL_LISTENER initialization is now done in one step. There was no good
reason to do it in two separate steps for listeners but in one step for
servers.

The `ssl` parameter now also accepts boolean values. As the parameter
behaves like a boolean and looks like a boolean, it ought to be a
boolean. It still accepts the custom `required` and `disabled` values
simply for backwards compatibility.

Also added the missing freeing functions for the SSL_LISTENER type. This
prevents failed SSL_LISTENER creations from leaking memory.
2018-07-17 11:52:20 +03:00
177f7357e0 Use module-style parameters with filters
Filters now use the module-style parameters to automate the type checking
and default value assignment.
2018-07-17 11:52:19 +03:00
5fdf82a508 Only warn about whitespace in section names
The warnings were logged even when the fix_section_name function was used
to fix non-section names.
2018-07-17 11:52:15 +03:00
4a0ace2a72 Use module-style parameters with monitors
The common monitor parameters are now stored as module-style
parameters. This makes the error reporting as well as the type checks for
the parameters consistent with parameters declared by the modules.
2018-07-17 11:52:15 +03:00
f807c21242 Treat service parameters as module parameters
The same mechanism that is used for modules can be used for the
configuration of the core objects. This removes the need for the redundant
code that validates various values that is already present in the code
that modules use.
2018-07-17 11:52:14 +03:00
e2fb0093b1 Merge branch '2.2' into develop 2018-07-12 19:38:40 +03:00
71c736faec Initialize router parameters in service_alloc
By moving the router parameter initialization into service_alloc, the
creation of a new service can be simplified to a single function call.
2018-07-11 14:08:56 +03:00
81527894ee Remove filter options
None of the filters used the options. The filter API version was already
incremented once for 2.3 so there's no need to increment it again.
2018-07-11 14:08:56 +03:00
cbb8c68770 Remove router_options
Relaced router_options with configuration parameters in the createInstance
router entry point. The same needs to be done for the filter API as barely
any filters use the feature.

Some routers (binlogrouter) still support router_options but using it is
deprecated. This had to be done as their use wasn't deprecated in 2.2.
2018-07-11 14:08:56 +03:00
b320217212 Remove configuration reloading
Removed the deprecated configuration reloading code. Added a entry into
the release notes that states this and the fact that it was deprecated in
2.2.
2018-07-11 14:08:54 +03:00
904b7d9d39 Remove unused service code
The code was not used and is not needed.
2018-07-11 14:08:54 +03:00
313bb0a5b4 Fix alteration of new router parameters
If a router parameter has no default value, the previous value would be
returned as an empty string. A debug assertion would be triggered when a
parameter of this type was altered.

When a new router parameter is encountered and the alteration fails, the
modified value in the service need to be removed. Previously, the new
value would have been stored in the service with an empty value which
would have caused problems.
2018-07-11 14:08:53 +03:00
77a1417479 Replace TR1 headers with standard headers
Now that the C++11 standard is the default one, we can remove the TR1
headers and classes.
2018-07-11 14:08:46 +03:00
28ceb1bad8 Take router reconfiguration into use
The router parameters can now be reconfigured at runtime if the router
supports it. Both MaxAdmin and the REST API support it.
2018-07-11 14:08:46 +03:00
2df5763b6c Add configuration exporting
The runtime configuration of a MaxScale can now be exported to a single
file. This allows modifications made via runtime configuration commands to
be "committed" for later use.
2018-07-07 09:28:50 +03:00
bfd3d2975d Merge branch '2.2' into develop 2018-07-06 14:56:19 +03:00
33fa9b26fe Make version counter in mlist_t volatile
The log manager is the only one that uses the mlist_t versioned list. The
counter that keeps track of the version number was not modified using
atomic operations meaning that the compiler is free to optimize away parts
of the lock-free versioning mechanism that uses it.

To prevent this optimization, the variable is declared volatile. A rewrite
is direly needed but it cannot be done in 2.2.
2018-07-05 12:47: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
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
241c9b645d MXS-1915 Remove unused functions 2018-06-26 09:19:46 +03:00
cc0299aee6 Update change date of 2.3 2018-06-25 10:07:52 +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
0d73530ff3 Merge branch '2.2' into develop 2018-06-08 11:30:55 +03:00
a7dd2127d6 Merge branch '2.1' into 2.2 2018-06-08 11:21:35 +03:00
643fc825fa MXS-553: Provide full session to DCB mapping
By storing a link to the backend DCBs in the session object itself, we can
reach all related objects from the session. This removes the need to
iterate over all DCBs to find the set of related DCBs.
2018-05-22 17:46:24 +03:00
42c10cfa1c MXS-1848 Move Worker from internal to public include dir
maxscale::Worker needs to be public if monitors should be
implementable using it.
2018-05-14 10:10:18 +03:00
12035289f4 Remove server authenticator options
Was unused. A warning is printed if the parameter is defined. Any value is ignored.
2018-05-08 14:18:00 +03:00
bf2a97812d MXS-1848 Destroy all monitors at system shutdown 2018-05-07 14:08:36 +03:00
851cefefc6 MXS-1848 monitor_[alloc|free]() -> monitor_[create|destroy]
As these will call the createInstance and destroyInstance functions
of the monitor, they are more appropriately named like this.
2018-05-07 14:08:36 +03:00
510eb7ec7c MXS-1848 Change monitorCamelCase to monitor_snake_case 2018-05-07 14:08:36 +03:00
83f3d6d71d MXS-1848 Rename monitorDestroy to monitor_deactivate
MonitorDestroy() (renamed to monitor_destroy()) will be used for
actually destroying the monitor instance, that is, execute
destroyInstance() on the loaded module instance and freeing the
the monitor instance.

TODO: monitor_deactivate() could do all the stuff which is currently
      done to the monitor in config_runtime(), instead of just
      turning off the flag.
2018-05-07 14:07:05 +03:00
62a3dd664d MXS-1755 Warn about unknown global configuration entries.
MXS_WARNING for unknown entries. Later to become an error (in 2.4).
2018-04-27 18:41:01 +03:00
df1fc49ac3 Add config parameter removal
Config parameters can now be removed. Grouped the related functions closer
to each other in config.cc.
2018-04-27 12:00:33 +03:00
8f87f0fc6f Merge branch '2.2' into develop 2018-04-24 09:37:02 +03:00
7820158f93 Properly fix string truncation in snprint_timestamp
The length of the timestamp string had a practical meaning. The correct
fix was to always use the length passed as the parameter.
2018-04-23 18:21:58 +03:00
f4bdf3012d Merge branch '2.2' into develop 2018-04-23 14:20:32 +03:00
d67320e06a Fix more GCC 8 build failures
Fixed string truncation warnings by reducing max parameter lengths by one
where applicable. The binlogrouter filename lengths are slightly different
so using memcpy to work around the warnings is an adequate "solution"
until the root of the problem is solved.

Removed unnecessary CMake policy settings from qc_sqlite. Adding a
self-dependency on the source file of an external project has no effect
and only caused warnings to be logged.
2018-04-23 14:02:54 +03:00
ac7d1198fb MXS-1754 Alter order of parameters
When providing pointer to instance and pointer to member function
of the class of the instance, the pointer to the member function
should be first and the pointer to the instance second.
2018-04-23 13:58:00 +03:00
cbd7e51dd8 MXS-1754 Identify delayed calls using id and not tag
When a delayed call is scheduled for execution, the caller is
now returned a unique id using which the delayed call can be
cancelled.
2018-04-23 13:58:00 +03:00
51d41b312b MXS-1754 Implement delayed call cancellation
There's now double bookkeeping:
- All delayed calls are in a map whose key is the next
  invocation time. Since it's a map (and not an unordered_map)
  it's sorted just the way we want to have it.
- In addition, there's an unordered set for each tag.

With this arrangement we can easily invoke the delayed calls
in the right order and be able to efficiently remove all
delayed calls related to a particular tag.
2018-04-23 13:58:00 +03:00
cb3a98dee8 MXS-1754 Use std::multimap instead of std::priority_queue
When canceling, a DelayedCall instance must be removed from the
collection holding all delayed calls. Consequently priority_queue
cannot be used as it 1) does not provide access to the underlying
collection and 2) the underlying collection (vector or deque)
is a bad choise if items in the middle needs to be removed.
2018-04-23 13:58:00 +03:00
a84e369a97 MXS-1754 Use signed types for expressing milliseconds 2018-04-23 13:58:00 +03:00
be9504ac94 MXS-1754 Add possibility to cancel delayed calls
The interface for canceling calls is now geared towards the needs
of sessions. Basically the idea is as follows:

class MyFilterSession : public maxscale::FilterSession
{
    ...
    int MyFilterSession::routeQuery(GWBUF* pPacket)
    {
       ...
       if (needs_to_be_delayed())
       {
           Worker* pWorker = Worker::current();
           void* pTag = this;
           pWorker->delayed_call(5000, pTag, this,
                                 &MyFilterSession::delayed_routeQuery,
                                 pPacket);
           return 1;
       }
       ...
    }

    bool MyFilterSession::delayed_routeQuery(Worker::Call:action_t action,
                                             GWBUF* pPacket)
    {
        if (action == Worker::Call::EXECUTE)
        {
            routeQuery(pPacket);
        }
        else
        {
            ss_dassert(action == Worker::Call::CANCEL);
            gwbuf_free(pPacket);
        }
        return false;
    }

    ~MyFilterSession()
    {
        void* pTag = this;
        Worker::current()->cancel_delayed_calls(pTag);
    }
}

The alternative, returning some key that the caller must keep
around seems more cumbersome for the general case.
2018-04-23 13:58:00 +03:00
84b2156508 MXS-1754 Add delayed calling to Worker
It's now possible to provide Worker with a function to call
at a later time. It's possible to provide a function or a
member function (with the object), taking zero or one argument
of any kind. The argument must be copyable.

There's currently no way to cancel a call, which must be added
as typically the delayed calling is associated with a session
and if the session is closed before the delayed call is made,
bad things are likely to happen.
2018-04-23 13:58:00 +03:00
bf7d3f7594 MXS-1754 Add Worker::Timer class
Worker::Timer class and Worker::DelegatingTimer templates are
timers built on top of timerfd_create(2). As such they consume
descriptor and hence cannot be created independently for each
timer need.

Each Worker has now a private timer member variable on top of
which a general timer mechanism will be provided.
2018-04-23 13:58:00 +03:00
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
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
ec33fcf87d Merge branch '2.2' into develop 2018-04-13 14:53:00 +03:00