1511 Commits

Author SHA1 Message Date
Markus Mäkelä
c96bd64aa8 Rename MODULE_INFO to MXS_MODULE
The MODULE_INFO is now the main object which is used by modules to convey
information to the MaxScale core. The MXS_MODULE name is more apt as it
now contains the actual module definition.

The old MODULES structure was moved into load_utils.c as an internal
implementation and was renamed so that it is not confused with the new
MODULE structure.
2017-01-03 18:01:14 +02:00
Markus Mäkelä
b00e0328d5 Create a macro for module declarations
The modules are now declared with a common macro. This allows future
additions to the module loading process while also making the loaded
symbol name a constant.
2017-01-03 18:01:13 +02:00
Markus Mäkelä
ae0577c695 Move module object inside MODULE_INFO
This allows modules to only expose one entry point with a consistent
signature. In the future, this could be used to implement declarations of
module parameters.
2017-01-03 18:01:13 +02:00
Markus Mäkelä
7df29aa1ec Move version entry point into MODULE_INFO
The MODULE_INFO can easily hold the version information of the
module. This removes the need for a explicit version entry point.
2017-01-03 18:01:13 +02:00
Johan Wikman
78928dc575 Make session_[getUser|get_remote] const correct
- Rename session_getUser to session_get_user
- Change session_get_user and session_get_remote to take a const
  SESSION* as argument and to return a const char*.
- Change server_get_persistent, so that user is passed as const.
- Update all users of these functions as appropriate.
2017-01-02 16:16:37 +02:00
Johan Wikman
cb0cb4bb09 Add maxscale::Buffer
maxscale::Buffer is a simple C++ wrapper around GWBUF that allows the
latter to be manipulated like an STL compatible collection.
maxscale::Buffer provides both a const and non-const forward iterator,
using which a non-contiguous GWBUF can be traversed and manipulated.
The iterators can be used with any standard C++ algorithm that accepts
forward iterators.
2016-12-29 11:50:42 +02:00
Johan Wikman
18008dec6d Rename mxs_mysql_account_to_pcre
The function is not capable of doing the right thing for an entire
account string, but only separately for user and host names, so the
function name should reflect that.
2016-12-29 11:47:08 +02:00
Johan Wikman
997bec868f Move transforming function to common place
Move function for converting a MySQL account string to an
equivalent PCRE one, from Cache's rules.cc to mysql_utils.
2016-12-29 11:09:06 +02:00
Johan Wikman
c6e155cf2b Move quote triming function to common place
Function for removing MySQL quote characters surrounding a
string moved from Cache's rules.cc to common place and renamed.

The function was now moved to mysql_utils.[h|c], which is in
maxscale-common, and not to the perhaps more appropriate place
protocol/mysql.h, as the latter would have implied that MySQLCommon
would have to be linked to, which actually might be the right thing
to do. However, that has to wait until protocol/mysql.h gets an
overhaul.
2016-12-29 11:09:06 +02:00
Johan Wikman
b40872e600 Prefix le[int|str]-functions with "mxs_" 2016-12-29 10:10:11 +02:00
Johan Wikman
c008d794c7 Add const correctness to mysql_util.h 2016-12-27 15:52:55 +02:00
Markus Mäkelä
7cbd62db52 Fix show dbusers
The functionality was broken by the change where the users were moved from
the service to the listener.
2016-12-22 17:55:05 +02:00
Dong Young Yoon
3e6cbeff19 1. Applied changes suggested from Markus.
2. tpmfilter now prints username of the client instead of the hostname
of the target server.
2016-12-20 13:04:01 +02:00
Dong Young Yoon
7776d55963 tpmfilter now prints which server the query has been executed on. 2016-12-20 13:04:01 +02:00
Markus Mäkelä
ae8c21929f Serialize server weighting parameters
The server weighting parameters couldn't be altered online and they
weren't serialized to disk. Only servers that are created online will have
their weighting parameters persisted to disk.
2016-12-19 18:40:14 +02:00
Markus Mäkelä
180728dde6 Only serialize created servers
Any changes to servers that aren't created online need to be manually
added to the configuration file in order for them to take effect after the
restart.
2016-12-19 18:40:14 +02:00
Johan Wikman
b62db91ab3 Add gwbuf_compare
With gwbuf_compare the content of two GWBUFs can be compared.
2016-12-19 14:55:44 +02:00
Johan Wikman
f929932fc0 Move docs from buffer.c to buffer.h
- Move docs from buffer.c to buffer.h
- Arguments made const-correct.
      gwbuf_length
      gwbuf_count
      gwbuf_copy_data
- Boolean return values changes from int to bool.
      gwbuf_add_property
- Meaningless returnvalue changed from int to void.
      gwbuf_add_hint
- Unused function removed.
      gwbuf_clone_transform
      gwbuf_trim
2016-12-19 11:42:02 +02:00
Johan Wikman
6e6a3e4626 Replace gwbuf_clone_all with gwbuf_clone
gwbuf_clone cloned only the first buffer of a chain of buffers,
which never can be the desired outcome, while gwbuf_clone_all
cloned all buffers.

Now, gwbuf_clone behaves the way gwbuf_clone_all used to behave
and gwbuf_clone_all has been removed.
2016-12-19 11:00:47 +02:00
Markus Mäkelä
875766cf62 Make modutil_create_query parameters const
The parameters to modutil_create_query are not modified so they can be
declared const.
2016-12-19 10:33:55 +02:00
Markus Mäkelä
269a97b2de Fix DECIMAL handling in Avrorouter
The DECIMAL value type is now properly handled in Avrorouter. It is
processed into an Avro double value when before it was ignored and
replaced with a zero integer.
2016-12-19 10:33:55 +02:00
Esa Korhonen
7e9db7ed0c Have server status updates applied during monitor loop
Previously, server status changes from MaxAdmin would be set immediately
as long as the server lock could be acquired. This meant that it might take
several seconds until the next monitor pass is executed. Usually, this was
fine but in some situations we would want the monitor to run immediately
after the change (MXS-740 and Galera). This patch changes the logic of
setting and clearing status bits to a delayed mode: changes are first applied
to a "status_pending"-variable, and only once the monitor runs will the
setting be applied. To reduce the delay, the monitor now has a flag
which is checked during sleep (between short 0.1s naps). If set, the
sleep is cut short.

If a server is not monitored, the status bits are set directly.

There is a small possibility of a race condition: If a monitor is stopped or
destroyed before the pending change is applied, the change is forgotten.
2016-12-19 10:19:23 +02:00
Johan Wikman
4239182aa0 Fix diagnostics on filter template
Diagnostics can be required on both instance and session level,
so both cases need to be handled explicitly.

In addition, some reinterpret_casts were changed into static_casts.
Reinterpret_cast needs to be used with the instance, which is a
void** but static_cast is sufficient for the session, which is void*.
2016-12-13 12:28:31 +02:00
Markus Makela
a0f6dd8abc Fix crash on double creation of listeners
When the listeners were created twice, MaxScale would crash when the users
were loaded. This is caused by the fact that the DCB for the listener is
NULL for failed listeners.
2016-12-13 09:12:58 +02:00
ekorh475
259e944b3d Server status changes now happen under a lock
MXS-873 To prevent monitors and MaxAdmin from interfering with each other,
changes to the server status flags now happen under a lock. To avoid
interfering with monitor logic, the monitors now acquire locks to all
of their servers at the start of the monitor loop and release them
before sleeping.
2016-12-12 15:04:05 +02:00
Markus Makela
106f482f45 Add result set buffering to MySQLBackend
The backend MySQL protocol module now supports a new routing capability
which allows result sets to be gathered into one buffer before they are
routed onward. This should not be used by modules that expect large
result sets as the result set is buffered in memory.

Adding a limit on how large of a result set could be buffered would allow
relatively safe use of this routing capability without compromising the
stability of the system.
2016-12-12 10:48:53 +02:00
Markus Makela
cb218804ef Detect double monitoring of servers
Adding a server to multiple monitors is forbidden. This should be detected
and reported to the end user.

The information provided by the config_runtime system to the client isn't
as detailed as it could be. Some sort of an error message stack should be
added so that client facing interfaces could properly report the reason
for the failure. Currently the only way to detect the reason of the
failure is to parse the log files.
2016-12-12 10:48:53 +02:00
Markus Makela
49aa23468d Align statistics to cache lines
Aligning the statistics object indices to cache line size reduces the CPU
overhead of gathering the statistics. This allows the statistics to more
accurately measure the polling system without the measurement affecting
the outcome.
2016-12-12 10:48:49 +02:00
Johan Wikman
ce94170eae Rename maxscale/cpp.hh to maxscale/cppdefs.hh
Just like every c-header must include maxscale/cdefs.h as the first
file, every C++-header must include maxscale/cppdefs.hh as its first
header.
2016-12-09 13:08:10 +02:00
Johan Wikman
855ed415f8 Add support for filters implemented in C++
C++ header files have the .hh-suffix to distinguish them from C
header files, but also to allow a C++ header file (e.g. xyz.hh) for
an existing C header file (e.g. xyz.h).

- cpp.hh        : Basic C++ stuff. Introduces the namespace "maxscale"
                  and its synonym "mxs".
- filter.[hh|cc]: Template class Filter and companion class FilterSession
                  to be used when implementing filters in C++.
- spinlock.h    : Wrapper and lock guard class for SPINLOCK.
2016-12-09 13:08:10 +02:00
Johan Wikman
777ea3ef43 Make config_truth_value() const correct 2016-12-08 14:58:48 +02:00
Markus Makela
d42ef8ed13 Combine and rename session statement functions
There was no real need to have two separate functions for getting the
stored buffer and the target server. Combining them into one allows it to
be handled in a nicer way.
2016-12-08 10:07:48 +02:00
Markus Makela
03e06727e8 Fix order of function declarations in session.h
A function was used before it was declared.
2016-12-07 10:58:01 +02:00
Markus Makela
8d539d9afb Improve transaction tracking fix
The previous fix can be implemented with less changes to actual code.
2016-12-07 10:39:16 +02:00
Markus Makela
6f7f8cae39 Add storing of statements to session
Statements can now be stored in the session object. This enables the
retrieval of these statements at a later time. These will be used by
readwritesplit to reroute failed reads to backup slaves.
2016-12-06 20:27:51 +02:00
Markus Makela
6d7e419ed4 Improve --config-check mode
The configuration checking now detects bad router options. This allows for
better coverage of the configuration with only the --config-check flag.
2016-12-05 13:18:20 +02:00
Markus Makela
9df3f154cf Detect duplicate objects
Creating a monitor or a listener twice is now detected and the proper
error is printed.
2016-12-03 11:31:18 +02:00
Markus Makela
a4bc575353 Remove direct freeing of sessions
Sessions are now always freed by releasing the last reference to it.
2016-12-02 15:19:44 +02:00
Markus Makela
adbd666991 Change module command parameter types
This commit introduces safe session references that can be handled without
holding locks. This allows the safe searching of sessions with the unique
ID of the session.

Remove the use of raw pointers passed as strings. Change the comments of
the argument types and add more details to the parsing function
documentation.
2016-12-02 14:26:56 +02:00
Johan Wikman
a6df875495 Make filter const correct and use snake case
CamelCase is still in use with the printing functions.
2016-12-01 15:20:34 +02:00
Markus Makela
4c4bd24a40 Allow module specific monitor parameters to be altered
Module specific parameters can now be altered at runtime. This allows both
the removal and addition of arbitrary monitor parameters.
2016-11-30 12:41:43 +02:00
Markus Makela
0689b3df39 Improve the polling statistics
The statistics of the polling system no longer match the implementation it
measures. Modified the statistics to better represent the new system by
calculating the number of epoll events each thread receives.
2016-11-30 10:28:23 +02:00
Markus Makela
7cbbc6f8f7 Add a mechanism to synchronize persistent pool counts
The polling system now has a concept of messages. This can be used to send
a synchronous message to the polling system which waits for all threads to
process the message before returning.

Currently this is used to flush unused DCBs when server persistent
statistics are reported.
2016-11-30 10:28:23 +02:00
Markus Makela
5aa791d16e Move persistent connections to thread specific lists
Making the lists of persistent DCBs thread specific is both a bug fix and
a performance enhancement. There was a small window where a non-owner
thread could receive events for a DCB. By partitioning the DCBs into
thread specific lists, this is avoided by removing the possibility of DCBs
moving between threads.
2016-11-30 10:28:23 +02:00
Markus Makela
b32af705e6 Extend routing capabilities
The routing capabilities now define the type of output the reply
processing chain expects. Currently, this only consists of two
capabilities; complete packet output and contiguous buffer output. The
latter implies the former.
2016-11-30 10:28:23 +02:00
Markus Makela
43f248927e Move thread related members of DCB into a substructure
The `thread` structure of a DCB now contains all the members that relate
to thread ownership of the DCB.
2016-11-30 10:28:23 +02:00
Markus Makela
2efa862944 Remove listmanager code
The code prevented scaling by imposing global spinlocks for the DCBs and
SESSIONs. Removing this list means that a thread-local list must be taken
into use to replace it.
2016-11-30 10:28:23 +02:00
Markus Makela
e53b9585dd Add mapping function for DCBs
The dcb_foreach allows a function to be mapped to all DCBs in
MaxScale. This allows the list of DCBs to be iterated in a safe manner
without having to worry about internal locking of the DCB mechanism.
2016-11-30 10:28:23 +02:00
Markus Makela
ed280aa81b Use client DCB to route requests
Using internal DCBs for query routing wasn't needed as the client DCB
could be used. This could also be done by simply routing the query again
with routeQuery.
2016-11-30 10:28:23 +02:00
Markus Makela
5067f3594a Adapt session timeout checks to a per thread model
Each thread will now check their own list of DCBs for timed out sessions.
2016-11-30 10:28:23 +02:00