Commit Graph

3050 Commits

Author SHA1 Message Date
adbc2074de Remove log_manager as a separate component.
Log_manager files are now in server/core and the log manager test
files in server/core/test. The directory log_manager is removed.
2016-02-09 11:17:31 +02:00
4f2a87f732 MXS-22: Shutting down monitor now closes database connections
Shutting down monitors is not supposed to be done ofter so there is no true
benefit from keeping the connections open. With the refactoring of the monitor
interface, this can be done in a centralized place.
2016-02-09 11:12:38 +02:00
9e33f300b0 Added flex/bison based parsing of rules to dbfwfilter
The dbfwfilter now uses flex to tokenize the rules and bison to process those
tokens into a language. This will make the syntax checks more robust and
the rule language easier to maintain. It also makes the processing of rules
easier to understand and removes most of the C language side checks for
correctness.

The old rule processing functions are still left intact and will be removed
at a later point.
2016-02-09 11:00:27 +02:00
6055ba25bf Added logging of matching and non-matching queries to dbfwfilter
When configured to log matching queries, the dbfwfilter will log all queries
that match a rule. The rule name, user name and the query itself are logged.

It is also possible to match all queries that do not match a rule. Only the user
name and query is logged in this mode.
2016-02-09 11:00:27 +02:00
5efd5d8927 Added user configurable actions to dbfwfilter
The dbfwfilter can now either allow, block or ignore queries that match the
configured rules.
2016-02-09 11:00:27 +02:00
9acdd4e70c Fixed tests failing to build
The tests were not linking against the maxscale-common library.
2016-02-09 10:59:11 +02:00
c506559452 MXS-400: Servers that are both master and slave now work with readwritesplit
The check for the server status explicitly denied servers that are both master
and slave from being chosed as candidates for queries. This is only a problem
when a user manually sets the server states to both master and slave.

The monitors resolve the replication topology based on the servers that
the monitors see and this always results in at least one slave server.
2016-02-08 19:44:33 +02:00
4a4f22c9a7 Make query_classifier part of core.
The query classifier interface is now built as an integral
part of MaxScale core.
2016-02-08 11:44:07 +02:00
834d04ed6c Merge branch 'MXS-517' into develop 2016-02-08 11:03:31 +02:00
7ff3a95b28 Reformat maxconfig.h 2016-02-08 10:41:34 +02:00
c579ed7fce Merge remote-tracking branch 'origin/MXS-517' into MXS-517 2016-02-08 10:33:56 +02:00
2f65c3a7b8 MariaDB Connector C is build from source if it is not found on the system
The FindMariaDBConnector.cmake file now checks if the found library actually is
the MariaDB Connector-C library. If the found library is not the MariaDB
Connector-C, it will be built from source.
2016-02-03 11:35:01 +02:00
081bacdc64 Switched to MySQL client library headers for MaxScale
The include directories previously used by MaxScale were from the embedded
library. All parts of MaxScale apart from the query classifier now use
the client libraries.
2016-02-02 14:04:59 +02:00
0d51f78a2a Dbfwfilter now uses PCRE2 regular expressions
Switched from the POSIX regex implementation to PCRE2. This should improve the
filter's performance as well as make the code more manageable.
2016-02-02 12:38:44 +02:00
7bac2f8fab Moved the applying of rules to users to its own function
This makes the function easier to understand as a whole.
2016-02-02 12:38:44 +02:00
2bbe1b068a Allow the query classifier to be specified in maxscale.cnf 2016-02-01 20:44:36 +02:00
e668abec5b Load config before qc is initialized.
That way a query_classifier entry in maxscale.cnf will be available
before the initialization takes place.
2016-02-01 20:38:51 +02:00
bbfcbc18c6 Make it possible to specify query classifier name.
If none provided or if the name is empty, the default query
classifier is loaded.
2016-02-01 19:46:16 +02:00
72f02164fc Reformat maxconfig.h 2016-02-01 19:22:07 +02:00
018e2426f9 Remove MySQL embedded initilization from gateway.c.
Since maxscale-common is linked to the connector-c library
and no longer to the MySql embedded library, mysql_library_init
does not need any parameters.
2016-02-01 18:28:09 +02:00
21b415eec0 Remove MySQL arguments from qc_init.
There can be any sort of library behind qc_init. Hence the arguments
cannot be hardwired to be like the embedded library wants them.

Eventually it might make sense to allow passing arguments from
maxscale.cnf.
2016-02-01 15:53:34 +02:00
fc6f49fe8a Link against Connector-C.
Now, qc_mysqlembedded is linked against MySQL's embedded library,
and MaxScale itself against Connector-C.

So, in order to build MaxScale, Connector-C must be installed.
This has been tested with Connector-C 2.2.1.

The build variable MYSQLCLIENT_LIBRARIES is no longer used.
2016-02-01 15:43:05 +02:00
0c6e9f3def Make query_classifier a wrapper.
The query_classifier library is now only a wrapper that loads an
actual query classifier implementation. Currently it is hardwired
to load qc_mysqlembedded, which implements the query classifier
API using MySQL embedded.

This will be changed, so that the library to load is specified
when qc_init() is called. That will then allow the query classifier
to be specified in the config file.

Currently there seems to be a conflict between the mysql_library_end()
call made in qc_mysqlembedded and the mysql_library_end() call made in
gateway.c. The reason is that they both finalize a shared library.
For the time being mysql_library_end() is not called in gateway.c.
This problem is likely to go away by switching from the client
library to the connector-c library.
2016-02-01 15:43:05 +02:00
0d78b3f8cd Add extern "C" to gwdirs.h.
Fix line-length as well.
2016-02-01 15:25:08 +02:00
7e36e1cbb1 Link against Connector-C.
Now, qc_mysqlembedded is linked against MySQL's embedded library,
and MaxScale itself against Connector-C.

So, in order to build MaxScale, Connector-C must be installed.
This has been tested with Connector-C 2.2.1.

The build variable MYSQLCLIENT_LIBRARIES is no longer used.
2016-01-29 16:50:31 +02:00
e840f92cbb Make query_classifier a wrapper.
The query_classifier library is now only a wrapper that loads an
actual query classifier implementation. Currently it is hardwired
to load qc_mysqlembedded, which implements the query classifier
API using MySQL embedded.

This will be changed, so that the library to load is specified
when qc_init() is called. That will then allow the query classifier
to be specified in the config file.

Currently there seems to be a conflict between the mysql_library_end()
call made in qc_mysqlembedded and the mysql_library_end() call made in
gateway.c. The reason is that they both finalize a shared library.
For the time being mysql_library_end() is not called in gateway.c.
This problem is likely to go away by switching from the client
library to the connector-c library.
2016-01-29 16:35:03 +02:00
475dfb7288 Use common function for setting up MySQL connection.
Earlier the same (or almost the same) code was duplicated in
several places.

A conflicting declaration was also removed. There was no
implementation for that declaration.
2016-01-29 16:30:48 +02:00
d054f5d7bd Cleanup of dbusers.[h|c]
- All functions used only in c-file declared as static.
- All module functions declared.
- A few camelClase names changed to underscore.
2016-01-29 10:54:41 +02:00
5ed58df9f6 Make hashtable const correct.
Hashtable need not modify the filename when loading or saving
the hashtable; consequently the filename can be passed as const.
2016-01-29 10:53:01 +02:00
8fd515ec8b Fixed MM monitor build failure
The MM monitor was using wrong types of arguments to thread_start and
thread_wait.
2016-01-28 13:14:03 +02:00
743a1b1037 Removed unnecessary calls to atomic_add
The polling statistics collection used atomic_add to increment values. This
is not an optimal way to update statistical values. Moved to per thread
values which are summed up when they are read.

Moved the functions used to gather polling statistics to their own file and
created a specific data type for statistics.
2016-01-28 09:55:26 +02:00
0111df3767 Cleaned up the use of thread types
The THREAD type was not used everywhere and pthread_t was used instead.
The thread creation function also returned the address of a stack allocated
value which isn't guaranteed to be usable.
2016-01-27 09:07:55 +02:00
da1a717dd8 Add extern "C" to modules.h. 2016-01-26 14:50:41 +02:00
9a8838474c Add query classifier plugin.
Basic infrastructure added for being able to load query classifier
plugins using the same mechanism other plugins are loaded with.
2016-01-26 10:40:43 +02:00
42b1722e49 Make query classifier self-contained.
Only the query classifier needs the functionality of the embedded
server, while the rest of MaxScale is content with the client
library or Connector/C.

This have now been rearranged so that query-classifier links with
the embedded static library and then explicitly exports its own
functions using the query_classifier.map linker script. That way
query classifier will use the embedded library, while the rest of
maxscale use the client library, and this without conflicts.

Currently, query_classifier is not linked to maxscale-common,
but executables must link to maxscale-common and query_classifier.
2016-01-25 21:43:49 +02:00
0b742977dd Add specific thread main function.
Earlier thread initialization was done in poll_waitevents(),
which was somewhat confusing, since the main thread also calls
into poll_waitevents().

Now there is a specific thread "main" function, which first
performs thread specific initialization and then calls into
poll_waitevents().
2016-01-25 20:41:30 +02:00
80cee351c4 Add platform.h
Platform.h is intended to contain definitions and workarounds
for concepts that depend upon the used compiler and/or platform.

Currently it ensures that /thread_local/ is available irrespective
of whether the source is compiled in pre- or post C11 or C++11 mode.

This file should be included first by all MaxScale headers.
2016-01-25 11:20:16 +02:00
1f241a5ed1 Rearrange libraries and build files.
This is the first change in an attempt to arrange the linking so that
more errors are detected at link-time.

- All files in server/core but for gateway.c are linked to one shared
  library called maxscale-common.
- The files log_manager/log_manager.cc and utils/skygw_utils.cc are
  built into maxscale-common as well.
- MaxScale itself consists now only of gateway.c and is linked with
  maxscale-common.
- All plugins link with maxscale-common.
- All executables link in addition with {EMBEDDED_LIB}.

After this change, the change (MXS-517) where query_classifier is the
only component that uses ${EMBEDDED_LIB} and the rest mysqlclient can
be made much cleaner.

After a few additional steps, all shared libraries can be linked with
the linker flags "-Wl,-z,defs", which directs the linker to resolve
all symbols. That will require that all shared libraries list all the
libraries they need, but will at the same time ensure that any
missing symbols are detected at link-time and not at run-time.
2016-01-22 23:26:17 +02:00
a61cedb1aa Fixed freeing of wrong pointer
The wrong pointer in server_free was used to clear the server parameters.
2016-01-22 18:55:54 +02:00
872d02db3e Finalized configuration processing cleanup
All parts of the configuration processing are now in their own functions.
This allows new objects to be created after MaxScale has started.
2016-01-20 09:25:03 +02:00
508c91be32 Cleaned up monitor configuration processing
Moved the monitor configuration processing into its own function and cleaned
it up.
2016-01-19 14:23:44 +02:00
53ac88a1a1 Cleaned up the process of adding filters and servers to a service
Moved the adding of filters, servers and router options to its own function.
2016-01-19 14:23:44 +02:00
0aaba891a3 Cleaned up server configuration processing
Moved the creation of new servers into a separate function and cleaned up
the configuration processing.
2016-01-19 14:23:44 +02:00
c6dfcb66f5 Cleaned up service configuration processing
Moved the allocation and configuration of services into their own function.
Moved SSL parameter validation into a separate function.
2016-01-19 14:23:44 +02:00
f12be9fea2 MXS-549: Change MaxScale's working directory on startup
MaxScale now changes the working directory to the log directory when it is
started. If this fails, the file system root is used instead.
2016-01-19 13:59:38 +02:00
c2310327fc Fixed idle session processing
The current implementation of idle connection timeouts is not safe. The sessions
are handled in a way which is not thread-safe and the checking is done from
a non-polling thread.

With this change, the checks for the session timeouts are done in one of the
polling threads in a thread-safe manner only if at least one service has enabled
the timing out of idle client connections.
2016-01-19 10:53:55 +02:00
cdeb921b1b Added missing freeing of monitor resources
Monitor servers were not freed.
2016-01-15 21:38:40 +02:00
d41fe5b9c7 Added extra checks to readwritesplit
Added a check that the master server reference is actually in use before
doing anything with it. Also removed a false assertion.
2016-01-15 16:25:05 +02:00
c5947285cf Added missing freeing of filter resources
Filters were not freeing their options or parameters.
2016-01-15 16:24:32 +02:00
1656840417 Added missing freeing of service resources
The service resources weren't freed when the service is freed.
2016-01-15 16:23:41 +02:00