1511 Commits

Author SHA1 Message Date
Markus Makela
30927455ef Add each DCB to the owning thread's list
Each DCB needs to be added to the owning thread's list so that they can be
iterated through. As sessions always have a client DCB, the sessions don't
need to be added to a similar per thread list.

This change fixes a problem with dcb_hangup_foreach that the removal of
the list manager introduced. Now the hangup events are properly injected
for the DCBs that connect to the server in question.
2016-11-30 10:28:23 +02:00
Markus Makela
abc0681248 Temporarily disable listmanager debug checks
Since the listmanager code isn't used, the debug assertions will always
fail. They should be disabled until the listmanager code can converted to
the per-thread model.
2016-11-30 10:28:22 +02:00
Markus Makela
076b810c1e Create thread specific zombie queues
Because each thread has their own epoll file descriptor and only one
thread can process a DCB, it makes sense to move to a per thread zombie
queue. This removes one of the last restrictions on scalability.
2016-11-30 10:28:22 +02:00
Markus Makela
8efdaa1ea6 Move fake events to a thread-specific queue
The fake poll events are now stored in thread specific queues. This
removes the need for the poll event queue.
2016-11-30 10:28:22 +02:00
Markus Makela
b79210c760 Create thread specific epoll instances
Having a unique epoll instance for each thread allows a lot of the locking
from poll.c to be removed. The downside to this is that each session can
have only one thread processing events for it which might reduce
performance with very low client counts.
2016-11-30 10:28:22 +02:00
Markus Makela
07c602d81c Add creation and destruction of monitors
Monitors can now be created and destroyed at runtime. The configurations
for new monitors are persisted to disk.
2016-11-29 15:04:19 +02:00
Markus Makela
4ff4e69592 Add stopping and starting of listeners to maxadmin
Listeners can now be stopped and started individually.
2016-11-29 15:04:19 +02:00
Markus Makela
691989ff04 Split the service header into internal and external parts
The service header in include/maxscale/ contains the public part of the
service API. These functions can be safely used by the modules.

The internal header located in service/core/maxscale/ is used by the core
to initialize MaxScale at startup or to provide other services in a more
controlled way (the config_runtime, for example).
2016-11-28 14:37:26 +02:00
Markus Makela
88677946f8 Add destruction of listeners
The listeners aren't really destroyed and are only stopped. Further
changes are required so that they won't be started again once they have
been destroyed.
2016-11-28 14:37:26 +02:00
Markus Makela
6ea4e50f2c Clean up service.h
Most of the service header functions now contain the relevant
documentation. Cleaned up small parts of it and renamed functions to be
more consistent.
2016-11-28 14:37:26 +02:00
Markus Makela
e31afa28e4 Serialize created listeners to disk
The created listeners are now stored to disk like created servers
are. This allows them to be used even after a restart.

Currently, the listeners cannot be deleted and need to be manually
removed.
2016-11-24 15:22:55 +02:00
Johan Wikman
265aacaf15 GWBUF_DATA(...) explicitly returns uint8_t* 2016-11-24 13:31:29 +02:00
Johan Wikman
04753bbb76 Make MODULE_INFO const correct 2016-11-24 13:11:03 +02:00
Markus Makela
e8af6908c1 Allow creation of listener at runtime
Listeners can now be created and started at runtime. If SSL is to be used,
the required parameters must be present.
2016-11-24 10:29:04 +02:00
Markus Makela
b24a28285c Make listener creation const-correct
The parameters passed to functions that create new listeners are now of
type const char*.
2016-11-24 10:29:04 +02:00
Markus Makela
ff54771cd1 Store old server SSL configurations
If the SSL configuration of a server was altered successfully, it would
overwrite an existing configuration leading to a true memory
leak. Converting the SSL_LISTENER structure to a list allows it to store
the old configurations without leaking the memory.

This has no functional benefits apart from storing references which could
aid in debugging. In the future, the discarded configurations could be
freed once all connections that use it are closed.
2016-11-24 10:29:04 +02:00
Markus Makela
498395cd3d Add monitor alteration to config_runtime.h
Moved the monitor alteration to config_runtime.c.
2016-11-24 10:29:04 +02:00
Markus Makela
e75a27e8db Add server alteration to config_runtime.h
Moved the alteration of servers done in debugcmd.c to config_runtime.c and
altered them to be better suited as API functions.
2016-11-24 10:29:04 +02:00
Markus Makela
8ef99c9066 Move configuration changes to a common file
The config_runtime.h header contains functions that can be used to
manipulate the running configuration. Currently the header contains the
function to create, add, remove and destroy servers.
2016-11-24 10:29:04 +02:00
Johan Wikman
6d1265ade1 Length of a packet requires 32 bit. 2016-11-23 13:53:06 +02:00
Markus Makela
502eba8b4f Fix OK packet generation
The packet was generated with the wrong number of elements due to usage of
sizeof on an integer where the correct type was an uint8_t.

This only fixes the malformed packets but does not fix the root cause of
the problem. The affected rows and last insert ID are length encoded
integers which should be handled. The current code treats them as one byte
fields.
2016-11-23 10:37:42 +02:00
Johan Wikman
83ffdcf4ed Change defines into inline functions
To prevent bugs caused by pointers having the wrong type (e.g. uint32_t
instead of uint8_t), some macros are changed into inline functions so that
the normal type-checking is performed.

The macros MYSQL_GET_ERRCODE, MYSQL_GET_STMTOK_NPARAM, MYSQL_GET_STMTOK_NATTR,
and MYSQL_GET_NATTR were not changed, because they may be too specific to
be present in a general purpose header in the first place.
2016-11-23 10:14:50 +02:00
Markus Makela
3b5b616edf MXS-929: Add descriptions to module command arguments
Each argument now has a description describing what it does and what it's
used for.
2016-11-22 10:46:34 +02:00
Markus Makela
4137d58dd5 MXS-929: Implement DCB and SESSION pointer handling
DCBs and SESSIONs can be passed either as raw pointers or as the string
representations of them.

The preferred way to pass them is to use the raw pointer types. This
removes the need to convert the pointer to string form and back.
2016-11-22 10:46:34 +02:00
Markus Makela
d68172260d MXS-929: Add mapping function for module commands
The modulecmd_foreach function allows commands to be iterated without having
to manage the locking of the system. This allows the commands to be easily
iterated and gathered into filtered lists without having to build it into
the module command system itself.
2016-11-22 10:46:34 +02:00
Markus Makela
4a142b1ca9 MXS-929: Add errors to the modulecmd system
The modules can now return human-readable error messages to the caller of
the function. The internals of the modulecmd system also use this to
return errors to the users.

The error messages can be retrieved with a common error function which
should make it easy to use in various clients.
2016-11-22 10:46:34 +02:00
Markus Makela
4603e71987 MXS-929: Add domain function registration
A module can register a function to a domain. These function can then be
called by external actors enabling the modules to expand their
functionality beyond the module API. Each module should use its own domain
e.g the library name.

Currently, the functions do not return results. The possible next step
would be to alter the function entry point to return a result set of
sorts. This would allow the modules to convey structured information to
the client information which would handle the formatting of the result.

Although this sounds good, it is not required for the implementation of
MXS-929.
2016-11-22 10:46:34 +02:00
Johan Wikman
9e4ee0323d Merge branch '2.0' into develop 2016-11-21 12:23:30 +02:00
Markus Makela
3c15b58891 Merge branch '2.0' into develop-2.0-merge 2016-11-15 00:09:24 +02:00
Markus Makela
878d01e276 Persist server changes to services
When a service is added or removed from a service, a supplementary
configuration file is created. This allows MaxScale to survive restars and
unexpected downtime even if runtime changes to the servers of a service
have been made.

With these changes, it is possible to start MaxScale without any servers,
create servers, add the created servers to services and monitors and
restart Maxscale without losing the runtime configuration changes.
2016-11-14 22:58:26 +02:00
Markus Makela
a17aa28eed Persist changes to the list of monitored servers
When a server is added to a monitor, an supplementary configuration file
is generated to persist this information. This will allow dynamic
modifications to server lists which will survive restarts and unexpected
downtime.

The monitor will only add new servers to its list of monitored
servers. This prevents duplicate entries in the list and makes it safe to
persist all used servers to the supplementary configuration file instead of only the ones that are not listed in the main configuration.
2016-11-14 22:58:26 +02:00
Markus Makela
8b692b0754 Add SSL support for created servers
Servers created at runtime can now be configured to use SSL. The
configuration is only possible if the server is not in use.

The `alter server` command in maxadmin now takes a list of `key=value`
strings. This allows the user to define multiple alter operations with one
command.
2016-11-14 22:58:26 +02:00
Markus Makela
b893ca7ba8 Move configuration context processing into subfunctions
The functions allow simple operations on configuration context
objects. This makes it easier to understand what the code does and allows
reuse of the configuration processing code.
2016-11-14 22:58:26 +02:00
Johan Wikman
15e9652c46 qc: Provide information about field usage
Together with the field names, now qc_get_field_info also returns
field usage information, that is, in what context a field is used.
This allows, for instance, the cache to take action if a a particular
field is selected (SELECT a FROM ...), but not if it is used in a
GROUP BY clause (...GROUP BY a).

This caused a significant modifications of qc_mysqlembedded that
earlier did not walk the parse-tree, but instead looped over of a
list of st_select_lex instances that, the name notwithstanding,
also contain information about other things but SELECTs. The former
approach lost all contextual information, so it was not possible
to know where a particular field was used.

Now the parse tree is walked, which means that the contextual
information is known, and thus the field usage can be updated.
2016-11-14 09:35:16 +02:00
Markus Makela
03951fff11 Remove FAKE_CODE from use
This functionality is not used in tests and parts of it didn't work. Since
it is not actively maintained or even used, it is better to remove it.
2016-11-11 12:17:22 +02:00
Markus Makela
2fcfc102be Abstract server active checks
The checks for the server active status are now hidden behind a
macro. This allows for the conditions of the activity to change without
having to alter the code that uses it.
2016-11-11 11:35:13 +02:00
Markus Makela
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
Markus Makela
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
Markus Makela
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
Markus Makela
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
MassimilianoPinto
2334c663e0 Merge branch 'develop' into MXS-936 2016-11-10 15:42:09 +01:00
Markus Makela
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
Markus Makela
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
Markus Makela
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
Markus Makela
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
Markus Makela
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
Markus Makela
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
Markus Makela
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
Markus Makela
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
MassimilianoPinto
21add3a8b4 Merge branch 'develop' into MXS-936 2016-11-10 12:02:40 +01:00