Commit Graph

283 Commits

Author SHA1 Message Date
5a306aa20a MXS-2005: Use log manager only after initialization
The log manager functions must not be used before it is initialized.
2018-08-14 14:57:34 +03:00
4fdec4d1f3 MXS-2004 Replace pthread_self() with std::this_thread::get_id() 2018-08-13 13:38:39 +03:00
2dd9e3e382 MXS-2004 Remove remaining dependency on maxscale/thread.h
Replaced with explicit dependency on pthread.h. Acceptable since
this is effectively for debugging purposes and could at some point
be removed entirelly.
2018-08-13 13:38:39 +03:00
b408894f6d MXS-2004 Remove dependency of maxscale/thread.h 2018-08-13 13:38:39 +03:00
70fa300fe1 Remove unnecessary mxs_log_flush_sync calls
The calls were unnecessary in the context where they were made.
2018-08-13 10:28:02 +03:00
710f2d3c79 Unify unit test naming
The tests now all use snake_case naming.
2018-08-06 21:20:29 +03:00
b20decfe1c MXS-1929: Output const strings from serviceGetUser
The values aren't meant to be modified by the caller.
2018-08-06 21:20:29 +03:00
4c7a5017bc MXS-1929: Create internal server representation
The server now has an internal C++ version that extends the public one.
2018-08-06 21:20:29 +03:00
ec420332ea MXS-1929: Take ResultSet into use
Replaced the previous RESULTSET with the new implementation. As the new
ResultSet doesn't have a JSON streaming capability, the MaxInfo JSON
interface has been removed. This should not be a big problem as the REST
API offers the same information in a more secure and structured way.
2018-07-31 22:50:08 +03:00
3be975ba5d Fix fixing of std::string object names
Comparing two fixed std::strings would have equal C strings but comparing
with operator== they would be different. This was a result of the string
modification done by fix_object_name.

Converted the internal header into a C++ header, added std::string
overload and fixed use of the function.
2018-07-31 09:41:15 +03:00
cca7757090 MXS-1929: Take internal Service struct into use
The internals now mostly refer to the Service struct instead of the public
SERVICE struct.
2018-07-31 09:41:13 +03:00
f10eab4406 MXS-1929: Fix binlogrouter unit test failure
The test failed because router instances are now created when the service
is allocated. In addition to this, a debug assertion was hit when a
service was freed if the router instance creation failed.
2018-07-31 09:41:07 +03:00
4e8ac8dd4f Fix explicit server allocation
The test cases allocated servers in a way that doesn't comfortably suit
the way the servers are now allocated. Adding a helper C++ class to load
module defaults makes it easier to do explicit server initialization in
tests.

The binlogrouter was also fixed in this commit as it uses servers much
like a test would use.
2018-07-17 11:52:21 +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
e963f4e82b Fix reading of past-the-end memory
The buffer that binlogrouter allocated for the error message was too
small. ASAN happened to catch this.
2018-07-17 11:52:16 +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
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
e353d14550 Prepare binlogrouter for removal of router_options
To prepare the router's for the eventual removal of the router_options
parameter, the API option arguments should not be used. The parameters can
be substituted by tokenizing the value of the parameter that is still
stored as a part of the service.
2018-07-11 14:08:55 +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
cc0299aee6 Update change date of 2.3 2018-06-25 10:07:52 +03:00
d094e93209 Rename conflicting objects
The START_ENCRYPTION_EVENT is the name of an object that is exposed by the
Connector-C.
2018-06-08 12:18:13 +03:00
880db1353a Merge branch '2.2' into develop 2018-06-07 14:39:16 +03:00
0dd7448586 MXS-1709 Fix memory leaks in unit tests 2018-06-06 22:59:52 +03:00
5a3bbf0d15 Move binlog event processing into a separate file
This clarifies what parts of the router are specific to the binlogrouter
and what are common between the binlogrouter and avrorouter.

Ideally, the two modules would use the same infrastructure to handle the
processing of replication events. This is the first, albeit small, step
towards making the code in the binlogrouter the common infrastructure.
2018-05-28 10:32:18 +03:00
16d2ff9564 Set read and execute permissions for all paths
If a path requires read or execute permission, it is granted to all. This
keeps path parameters in line with other directories that MaxScale
creates.
2018-05-28 10:32:16 +03:00
77c713baa6 Remove manual revision notes and extra files
Removed the manually written revision notes that were in some files. Also
removed the README and STATUS files which were present.
2018-05-28 10:32:14 +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
1f6cc6db8a MXS-1840 Compile all routers as C++
Minimal changes, only what is needed in order to make it compile.
2018-05-07 14:06:22 +03:00
5d010ff712 Cleanup SERVER struct
Removed one unused field. Rearranged others, clarified comments.
2018-04-27 10:48:56 +03:00
caa964fa57 Merge branch '2.2' into develop 2018-04-24 13:57:50 +03:00
5cf56c7c0f Merge branch '2.1' into 2.2 2018-04-24 12:39:22 +03:00
bafe8f5eeb MXS-1618 Use right type for the return value of getopt_long
getopt_long returns an 'int'. If 'char' is used on a big-endian
platform you'll end up with an infinite loop.
2018-04-24 12:31:08 +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
a2b78d40cf Merge branch '2.2' into develop 2018-04-18 08:00:48 +03:00
ad15f4d4be Fix binlogrouter build failures with GCC 8
GCC 8 appears to have improved the snprintf truncation detection which
revealed problems in the binlogrouter.
2018-04-17 21:55:47 +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
c70216390f MXS-1506: Combine housekeeper task types
The tasks themselves now control whether they are executed again. To
compare it to the old system, oneshot tasks now return `false` and
repeating tasks return `true`.

Letting the housekeeper remove the tasks makes the code simpler and
removes the possibility of the task being removed while it is being
executed. It does introduce a deadlock possibility if a housekeeper
function is called inside a housekeeper task.
2018-04-10 15:29:30 +03:00
b33f464eea MXS-1506: Make heartbeat reads atomic
The old hkheartbeat variable was changed to the mxs_clock() function that
simply wraps an atomic load of the variable. This allows it to be
correctly read by MaxScale as well as opening up the possibility of
converting the value load to a relaxed memory order read.

Renamed the header and associated macros. Removed inclusion of the
heartbeat header from the housekeeper header and added it to the files
that were missing it.
2018-04-10 15:29:29 +03:00
f54bbdf73b Fix -Werror=format-truncation= warnings in blr_slave.c
The errors were caused by the fact that the server name
MAX_SERVER_NAME_LEN is 1024 bytes long whereas the buffer was 251 bytes.
2018-03-08 11:28:05 +02:00
3dfb972d87 Merge branch '2.1' into 2.2 2018-01-30 16:28:11 +02:00
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
c85f83fa2b Fix strcpy overlap in binlogrouter
The source and destination buffers could overlap which is why an
intermediate buffer is required.
2018-01-23 09:26:22 +02:00
47184ea46d Fix build failure on Ubuntu 17.10
The sprintf calls failed due to a warning about possible buffer
overflow. Curiously enough, the same warnings do appear on Fedora 26 but
only when the calls are changed to snprintf.
2018-01-17 14:06:19 +02:00
200657e2f6 Pre-load binlogrouter modules for the test
The test loads multiple modules in one call so we have to pre-load them
one by one to make sure that they are all present regardless of the
locations where the individual modules were built.
2018-01-03 08:56:41 +02:00
f810ce9ea3 Fix binlogrouter unit test failure
The test used LD_LIBRARY_PATH to find the module instead of using an
explicit path.
2018-01-02 11:22:39 +02:00
8ef681d8cd Fix trivial memory leaks
Fixed trivial memory leaks detected by ASAN when running internal test
suite.
2017-12-27 11:56:39 +02:00
79afaa447e Merge branch '2.1' into 2.2 2017-12-12 13:23:02 +02:00
4b9bb9e65f Assign service pointer in BLR DCBs
The DCBs that were manually allocated by the binlogrouter were not
assigned the service pointers.
2017-12-12 08:47:02 +02:00