Commit Graph

3527 Commits

Author SHA1 Message Date
dbedf57c9a Add and remove servers for monitors
The `add server` command accepts a server name and either a service name
or a monitor name. It will add servers to services and monitors. Since all
monitors use the MONITOR_SERVER structures directly, the monitors need
to be stopped before new servers are added to them
2016-11-10 15:15:10 +02:00
3b465c0d41 Add online creation of servers
New servers can be created with the new `create server` command. This will
create a new server but it will not add it to any service or monitor.
2016-11-10 15:15:10 +02:00
084aacb11c Fix debugcmd parameter processing
The debugcmd parameter processing didn't actually allow the maximum number
of parameters to be passed to the function. The detailed help text was
never printed and most of them were only duplicates of the short
description.
2016-11-10 15:15:10 +02:00
65886dc386 Check whether server references are active
Before a query is routed to a backend, the status of the server reference
is checked. This allows the servers that are removed from a service to be
ejected from the list of active servers for active sessions.
2016-11-10 15:15:10 +02:00
28fc3d2b83 MXS-922: Add server serialization function
The function serializes a server to a file. This is intended to be used
with dynamically created servers. The output of the server serialization
will eventually be stored in the configuration file directory (default is
/etc/maxscale.cnf.d/) so that created servers persist even after a
restart.
2016-11-10 15:15:10 +02:00
ea0dcea5d6 Clean up instance and session lifecycle functions
The createInstace, newSession, closeSession and freeSession functions were
cleaned up and reorganized to be a bit clearer for the reader. Removed
unnecessary comments and replaced them with ones that explain what's
happening in the code.

Removed unused linked lists from both sessions and instances and replaced
them with better alternatives. This should improve performance since new
session don't have to acquire the instance level lock to put themselves
into the session list.
2016-11-10 15:15:10 +02:00
88dca05dc7 Remove unused code from readwritesplit
There was a lot of extra debug logging behind unused defines. These were
never enabled and some of the code never worked.
2016-11-10 15:15:10 +02:00
26d1986fac Remove BACKEND from schemarouter and clean up code
Removed the use of the BACKEND structure and replaced it with the use of
the SERVER_REF structure of the service. This allows dynamic changes to be
made to the list of servers.

Cleaned up parts of the code and removed obsolete or useless
functions. The schemarouter module could do with some refactoring since it
derives from readwritesplit.
2016-11-10 15:15:10 +02:00
155161a876 Remove BACKEND structure from readconnroute
The BACKEND structure in readconnroute is now replaced with the use of the
SERVER_REF structure of the service. This allows dynamic changes to the
list of servers to be made.
2016-11-10 15:15:10 +02:00
dc8c068936 Modify readwritesplit to understand changes in server references
The readwritesplit now understands that the amount of servers can change
and some of the items in the list of server references aren't in use. This
allows dynamic changes to the number of servers used by readwritesplit.
2016-11-10 15:15:10 +02:00
8982ee3db2 Allow servers to be added and removed from services
Servers can now be added and removed from services which allows routers to
use them with new sessions. The routers don't fully use the new
functionality in the server references which prevents new servers from
being taken into use.
2016-11-10 15:15:10 +02:00
6fe9fda46e MXS-935: Add support for column based rule matching
In addition, test program extended to be able to test the
rule matching. Tests to be extended in a subsequent commit.
2016-11-10 11:24:10 +02:00
bc1c2e1152 Ensure exit is possible
If shutdown has been initiated (via maxadmin or by sending a
SIGINT or SIGTERM) and a SIGTERM is received, the process
is terminated.

If shutdown has been initiated (via maxadmin or by sending a
SIGINT or SIGTERM) and a SIGINT (Ctrl-C) is received, a warning
is printed that shutdown is in progess. Then, if an additional
SIGINT is received, the process is terminated.

So, in practice:
- If MaxScale is running as a daemon, the first SIGTERM initiates
  shutdown and a second one unconditionally terminates the process.
- If MaxScale is running in the console, the first Ctrl-C initiates
  shutdown, the second prints a warning and the third terminates
  the process.

This is to ensure that MaxScale can be forced to exit, in
case some thread is hung for whatever reason, and is thus preventing
the controlled shutdown.
2016-11-10 11:09:59 +02:00
c28ffcf87e Change error message when permissions on .secrets are wrong
If the user running MaxScale could open the .secrets-file and the
file permissions were anything other than owner:read, the
secrets_readkeys() would fail with error message
"Ignoring secrets file <path>, invalid permissions." Now the
message is more accurate in stating the expected permissions.
2016-11-10 09:42:47 +02:00
02ec7e9b17 Wait until housekeeper has finished
When calling hkshutdown(), only a shutdown flag will be set.
In main() we will then actually wait for the housekeeper thread
to finish before exiting.
2016-11-09 15:14:52 +02:00
ef79686a3a Add option to use a unified log file for qlafilter
The qlafilter now has an option to log all messages to a single
file instead of session-specific files. Session ids are printed
to the beginning of the line when using this mode. Documentation
updated to match. Also, added an option to flush after every
write.
2016-11-08 15:31:31 +02:00
689366b6b7 Fix possible writes to closed DCBs
When persistent connections were used, it was possible that the injection
of COM_CHANGE_USER statements caused a crash when a DCB in the wrong state
was accessed.

For MySQL protocol modules, the `data` member of the client DCB points to
the shared session data, a MYSQL_session struct, but for sessions in the
persistent pool, it points to NULL. The boolean, `was_persistent`, tells
whether a DCB was just taken from the pool or it has been in use.

The `was_persistent` status wasn't properly reset for connections that
were put into the pool which caused a COM_CHANGE_USER statement to be
injected for stale connections in the pool which caused a crash when the
NULL `data` member was accessed.
2016-11-08 09:24:00 +02:00
7358d932e6 Fix maxrows CMakeLists.txt
There was an add_subdirectory call to a nonexistent `test` directory.
2016-11-08 09:12:47 +02:00
eaef39c008 Merge branch 'develop' into MXS-930 2016-11-07 16:21:06 +01:00
c36e5f6ba4 C_DEBUG removed and added a check for packetlen < MAXROWS_EOF_PACKET_LEN
C_DEBUG removed.
A check is now made for packetlen < MAXROWS_EOF_PACKET_LEN.
An empty result set, OK, is send in such situation
2016-11-07 16:19:38 +01:00
417d6270d5 Fix assignment of session_id
Previously the session_id incrementation was done after creating
filters, giving the filters a constant zero value for session_id.
Now the incrementation happens before filter creation.
2016-11-07 16:19:56 +02:00
ded551e199 Add function for full memory barrier into maxscale/atomic.h
This allows safer lock-free reads to be done on lists that never shrink in
size. The main use-case for this is to allow servers to be added to a
service without locking the service each time a new session is created.

Synchronizing the memory before adding new components into a list
guarantees that if a session reads from the list and sees the new list
item, the memory pointed by the item is valid.
2016-11-07 14:10:18 +02:00
a163e31b9a Remove BACKEND structure from readwritesplit
The BACKEND structure is no longer created for the instance. This allows
sessions to dynamically create new servers.
2016-11-07 14:10:18 +02:00
a097204c70 MXS-922: Move server weight calculation into the core
The core now does the server weight calculation instead of each router
module doing the same thing.
2016-11-07 14:10:18 +02:00
bf62f8950a Remove qc_get_affected_fields
Function is no longer used and it was quite unoptimal, so now
removed.

qc_get_prepare_name, qc_get_prepare_operation and qc_get_field_info
that were missing from qc_dummy added at the same time.
2016-11-07 12:28:58 +02:00
9fa1a0cfec Replace qc_get_affected_fields with qc_get_field_info
qc_get_affected_fields that returned the fields as one string with
fields interspared with spaces, will be removed.
2016-11-07 11:03:22 +02:00
9f01a4612d EOF flags are now read in case 0xfe
EOF flags are now read in case 0xfe and minor improvements
2016-11-07 10:01:05 +01:00
5b7e5aa36f SERVER_MORE_RESULTS_EXIST is now detected
The filter can detect SERVER_MORE_RESULTS_EXIST which means the server
is sending more result sets: example:

DROP PROCEDURE IF EXISTS multi;
DELIMITER $$
CREATE PROCEDURE multi() BEGIN
  SELECT 1;
  SELECT id FROM t2 limit 40;
  set @a=4;
  SELECT 2;
END$$
DELIMITER ;

MySQL> call multi()
2016-11-04 15:48:14 +01:00
094586adbc Merge branch 'develop' into MXS-930 2016-11-04 15:29:40 +01:00
96547a1c0d Fix failure to exit on configuration error
The check for the success of the configuration file always resulted in a
successful return value even if the loading failed.

In addition to this, a log message referred to the active configuration
when the active configuration was set only after the processing was
complete. Since configuration failures are always fatal, there's no harm
in preemptively setting the active configuration to the one currently
being processed.
2016-11-04 14:53:54 +02:00
f38b510d2b MXS-962: Add nonpositive priority for Galera nodes
If a Galera node has a nonpositive priority, the node will never be chosen
as the master. This gives the user more control over how the master is
chosen.
2016-11-03 22:22:25 +02:00
8778e0c81e Make Users const correct 2016-11-03 09:35:49 +02:00
45f463c438 Require GCC 4.8 for RocksDB
GCC 4.8 is the first GCC version that fully implements C++11
2016-11-03 09:27:58 +02:00
02d28a8d8d Always use format strings in dcb_printf
The luafilter didn't use a format string with dcb_printf which can lead to
unexpected results if the returned string contains printf special
characters.
2016-11-03 09:23:36 +02:00
c652f1330a qc: Add qc_get_field_info
This function returns more detailed information about the fields
of a statement. Supersedes qc_get_affected_fields() that will
be deprecated and removed.

Note that this function now introduced new kind of behaviour; the
returned data belongs to the GWBUF and remains valid for as long as
the GWBUF is alive. That means that unnecessary copying need not
be done.
2016-11-02 15:50:21 +02:00
ab487e687f qc: Remove QUERY_IS_TYPE macro
Explicit call to qc_query_is_type() instead.
2016-11-02 15:50:21 +02:00
8a6e3fb49f Merge branch 'develop' into MXS-930 2016-11-02 08:57:40 +01:00
5085b41d20 Reset persistent MySQL connections
When a persistent connection is taken from the pool, the state is reset
with a COM_CHANGE_USER on the next write. This allows reuse of persistent
connections without having to worry about the state of the MySQL session.
2016-11-01 10:50:07 +02:00
8c20ad5cd0 MXS-304: Support hierarchical reload
'reload config' now also processes all configuration files
of a hierarchy.
2016-10-31 12:48:38 +02:00
f71f41b0b8 MXS-304: Check duplicate sections across all files 2016-10-31 12:48:38 +02:00
2116c1549c MXS-304: Refactor duplicate section detection
Preparatory work for being able to check duplicate sections across
multiple files. Data needed for the checking is held in a separate
object.
2016-10-31 12:48:38 +02:00
daf6f06138 MXS-304: Support nested configuration files
Given a config file "config.cnf", we look for the directory
"config.cnf.d" and recursively in that hierarhcy load all files
whose suffix is ".cnf"; other files are ignored.

Currently duplicate sections are checked on a file by file basis.
That will be changed so that duplicate sections are not allowed
across all the files.
2016-10-31 12:48:38 +02:00
ab372b291b MXS-304: Minor refactoring of config.c
The loading of a single file refactored out into a separate function.
To be used later when multiple files are loaded and processed.
2016-10-31 12:48:38 +02:00
5a1af968d2 Take contiguous input capability into use in filters
The filters which require contiguous input now return the
RCAP_TYPE_CONTIGUOUS_INPUT capability flag.
2016-10-31 08:38:05 +02:00
3c26ea16e2 Add and use FindSQLite.cmake
Added a find_package module for SQLite development libraries.
2016-10-28 12:49:18 +03:00
1be3bb9b8d Minor cleanup of config.[h|c]
- Add const where applicable.
- Cleanup header files.

Fix collateral damage (statistics.c) as well.
2016-10-27 15:55:26 +03:00
bbade8b736 PCRE2_CODE_UNIT_WIDTH must not be defined. 2016-10-27 15:26:41 +03:00
1728e2dc2e Minor cleanup of gateway.c
Pre-parsing of configuration file moved to separate function. To
make it slightly easier to see the forest for the trees.
2016-10-27 14:50:22 +03:00
6c80f2bc0a Cleanup gateway.c include files
- First <maxscale/cdefs.h>
- Then all system, c-runtime, OS include files in alphabetical order.
- Then include files for "3rd-party" software in a loose order of
  importance.
- Then maxscale headers ordered alphabetically.
2016-10-27 14:13:31 +03:00
a390331e42 Feature defines moved to <maxscale/cdefs.h>
Feature defines that affect the available functionality or the
compile time environment should be defined in a common way for
all source.
2016-10-27 14:08:58 +03:00