Commit Graph

3553 Commits

Author SHA1 Message Date
08ebb88aec Make server creation simpler
Server creation and allocation are now the same apart from the fact that
allocation only adds the server to the running configuration where as the
creation of a server also persist it to disk.

The server serialization should not be seen through the server.h API. This
allows the serialization method to change without actually having to
change the interfaces.
2016-11-11 10:54:34 +02:00
16e8aa7178 Fix server usage bugs in monitors and servers
The MySQL Monitor did not reset the pointer to the root master reference
which would lead to a crash if the master was removed.

When service details were shown, it listed all servers that existed. Only
servers that haven't been removed or destroyed should be shown.
2016-11-11 10:54:34 +02:00
e67a829daf Take server destruction into use
The servers can now be destroyed with the `destroy server NAME` maxadmin
command.
2016-11-11 10:54:33 +02:00
261f5fdc36 Enable destruction of servers
The servers can now be destroyed which removes them from the list of
active servers. If the server was not created at runtime, a warning is
logged.
2016-11-11 10:54:32 +02:00
f0082256f5 Only print servers that aren't destroyed
If a server were to be destroyed, it should not show up among
non-destroyed servers. Even though the servers aren't actually destroyed,
it hides unnecessary information from the user.
2016-11-11 10:47:47 +02:00
7499630614 MXS-576 Check for negative values for config settings
Previously, negative values were allowed for persistpoolmax and
persistmaxtime. Now they cause an error. Also, monitor_interval
allowed negative (or zero) values, which were then implicitly cast to
unsigned, causing unintended behaviour. Now this causes a warning
and the default value is used.
2016-11-11 10:07:10 +02:00
2334c663e0 Merge branch 'develop' into MXS-936 2016-11-10 15:42:09 +01:00
c9218351b8 MXS-922: Serialize created servers
When a server is created via MaxAdmin, it will be serialized to disk. This
allows created servers to be retained through a restart of MaxScale.

Currently, all serialized objects are stored in one folder and there is no
structure in the created files. In the future, servers could be created
under a `servers` subdirectory so that it is easier to see what was
added. Whether there is a need for this will be seen.
2016-11-10 15:15:10 +02:00
bbd3e13a54 Only use valid server credentials
The server credentials are only used if both the monuser and monpw
parameters are defined. This is a sort of a bugfix as a monitor connection
could use a username from server but a password from the monitor.
2016-11-10 15:15:10 +02:00
c08a637564 Fix array usage with servers
The server monuser and monpw members were used with the assumption that
they could be NULL. This is no longer true since they were converted to
arrays.

The name member of the server was freed leading to a crash when the server
unit test was run.
2016-11-10 15:15:10 +02:00
aefa5c4c57 Add configurable persistdir
The persisted configuration file directory is now configurable.
2016-11-10 15:15:10 +02:00
6847ed1c37 Create and read persisted config dir
The persisted configuration directory is created and/or read when MaxScale
starts. This allows the servers created at runtime to be recreated when
MaxScale is restarted.
2016-11-10 15:15:10 +02:00
ec894f41b8 Store persisted config directory
The persisted configuration subdirectory will be used to store changes to
the configuration. The gwdirs.h header now supports setting and getting
the value for this directory.
2016-11-10 15:15:10 +02:00
4b82f83637 Enable online modification of monitors
The monitor parameters can now be changed via maxadmin. These changes are
not persisted to disk yet.
2016-11-10 15:15:10 +02:00
35d2959395 Enable online modification of servers
The address, port, monuser and monpw parameters of an existing server can
be changed at runtime. The support for enabling SSL will come in a later
commit.

Allowing servers to be modified could also be done by destroying and
recreating them. Since the servers are never actually destroyed, it is
better to allow the alteration of the existing ones.
2016-11-10 15:15:10 +02:00
b51af51365 Allow monitors and services to start without servers
MaxScale can now start without any defined monitors. This allows the core
services to be configured beforehand. With the changes to dynamic
modifications to servers, automatic scaling of slaves is possible.
2016-11-10 15:15:10 +02:00
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
12dba14c5c MXS-936: fixed compilation error with "debug" build
MXS-936: fixed compilation error with "debug" build
2016-11-10 13:22:26 +01:00
21add3a8b4 Merge branch 'develop' into MXS-936 2016-11-10 12:02:40 +01:00
77946b6adc MXS-936: destroyInstance of binlog server is now updated
MXS-936: destroyInstance of binlog server was not updated: not it takes
the ROUTER * parameter.
2016-11-10 12:01:41 +01: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
e9030f71bd MXS-936: AVRO shutdown update
AVRO shutdown detection is only in the loop that processes new files.

Flushing and status saving is done anyway
2016-11-10 10:16:39 +01: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
62049a5bb4 MXS-936: AVRO converter_func update
MXS-936: AVRO converter_func update: added new checks for pending
shutdown
2016-11-09 17:26:28 +01:00
802152d7d3 MXS-936: avro router converter routine handles shutdown
MXS-936: avro router converter routine handles shutdown
2016-11-09 16:26:05 +01:00
da152353dd Merge branch 'develop' into MXS-936 2016-11-09 16:21:40 +01: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
4e36e86820 MXS-936: destroyInstance added for filters
MXS-936: destroyInstance added for filters
2016-11-08 17:09:49 +01: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
61f0603e39 MXS-936: destroyInstance interface change
MXS-936: destroyInstance interface change
2016-11-08 14:07:48 +01:00
de18f25cb8 MXS-936: add shutdown hooks
First part: add shutdown hooks for routers.

Binlog is the first one with a  destroyInstance() routine
2016-11-08 11:12:37 +01: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