1375 Commits

Author SHA1 Message Date
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
Markus Makela
f4e3ca2c87 Merge branch '2.0.2' into develop 2016-11-23 11:24:34 +02:00
Markus Makela
0a7d1390b6 MXS-929: Add module command calls to maxadmin
The maxadmin interface now supports calls to registered module
functions. It is also capable of listing all the registered functions.
2016-11-23 11:14:31 +02:00
Markus Makela
1432677406 Fix regression in prepared statement routing
The prepared statements were router according to the real type instead of
being router to the master. This was caused by the change in the route
target function.
2016-11-21 23:05:46 +02:00
Johan Wikman
9e4ee0323d Merge branch '2.0' into develop 2016-11-21 12:23:30 +02:00
ekorh475
de4ea067cf Fix for MXS-968
This commit adds a free() to null_auth_free_client_data, which plugs
the memory leak in maxinfo.

Also, this commit fixes some segfaults when multiple threads are
running status_row() or variable_row(). The functions use
statically allocated index variables, which often go out-of-bounds
in concurrent use. This fix changes the indexes to thread-specific
variables, with allocating and deallocating. This does seem to slow
the functions down somewhat.
2016-11-18 18:57:57 +02:00
ekorh475
5198c3e456 Run astyle on httpd.c and maxinfo_exec.c 2016-11-18 18:49:21 +02:00
Markus Makela
696d103ed0 Allow servers to be removed from multiple objects
Since servers can be added to multiple objects, it only makes sense to be
able to remove them from multiple objects.
2016-11-17 12:37:50 +02:00
Markus Makela
ae339f174c Allow servers to be added to multiple objects at one time
The maxadmin interface to add servers to objects now allows a maximum of
11 objects to be listed. This will make it simpler to add a server to both
a monitor and a service in one command.
2016-11-17 12:37:50 +02:00
MassimilianoPinto
cd31b2c2c3 Merge branch 'develop' into binlog_server_wait_data 2016-11-16 15:08:17 +01:00
MassimilianoPinto
3b7eec8655 The hole is created only with BLR_EVENT_DONE master_event_state
This fix allows the gap detection and the writing of an IGNORABLE event
only if master_event_state == BLR_EVENT_DONE.

Note: The hole is not being created if the event is bigger than 16MB
2016-11-16 15:06:24 +01:00
Johan Wikman
27247bea4e Now use maxscale_shutdown()
shutdown_server() has been renamed to maxscale_shutdown().
2016-11-16 15:35:32 +02:00
Markus Makela
5aefd35df9 MXS-969: Detect user variable modifications
With the use_sql_variables_in=master option, readwritesplit should route
all user variable modifications and reads with user variables to the
master.

Previously, the modification of user variables was grouped into generic
system variables which caused all modifications to system variables to go
to the master only. The router requires a finer grained distiction between
normal system variable modifications and user variable modifications.

With the improvements to the query classifier, readwritesplit now properly
routes all user variable operations to the master and other system
variable modifications to all servers.
2016-11-16 15:26:06 +02:00
Markus Makela
44a55d231f Merge commit 'a7c21eee88c3c2530c06fea8a20c718004eed244' into develop-2.0-merge 2016-11-16 12:57:23 +02:00
Markus Makela
a7c21eee88 Always treat master failures as fatal errors
When a connection to the master fails, readwritesplit should always treat
it the same way. Previously, if a connection to the master was lost but it
hadn't lost the master status, the failure would be treated like a slave
server failure.
2016-11-15 22:18:26 +02:00
MassimilianoPinto
d530779cf3 Merge branch 'develop' into binlog_server_wait_data 2016-11-15 14:00:52 +01:00
Markus Makela
3c15b58891 Merge branch '2.0' into develop-2.0-merge 2016-11-15 00:09:24 +02:00
Markus Makela
2202ec7a33 Allow multiple monitor alterations at one time
The monitor alteration now also uses a list of key-value pairs. This
allows multiple changes to be made in one command.
2016-11-14 22:58:26 +02:00
Markus Makela
f18cf407a7 Improve maxadmin error messages
The error messages now report more detailed information about the expected
number of arguments to commands.
2016-11-14 22:58:26 +02:00
Markus Makela
a5bb02bd14 Expect at least two arguments for create server
When a server is created in server_create, it sets the port to the default
of 3306 if no explicit port is defined. The code that called this function
still expected a minimum of three arguments: name, address and port.
2016-11-14 22:58:26 +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
MassimilianoPinto
deda1c844e Develop branch update
Develop branch update
2016-11-14 17:44:39 +01:00
Markus Makela
da129025eb Use common backend closing function
The backend references now use a common closing function so that all
variables are reset to proper states. The stored queries weren't always
freed and they would leak memory if left open.
2016-11-14 16:14:20 +02:00
Markus Makela
ba4ab9d35f Remove sorting of backends with qsort
The backends are no longer sorted with qsort. This removes the possibility
of stale backend references.
2016-11-14 15:01:41 +02:00
MassimilianoPinto
2b2d2cc679 Merge from develop
Merge from develop
2016-11-14 09:43:54 +01: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
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
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
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
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
Markus Makela
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
Markus Makela
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
Markus Makela
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
Markus Makela
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
Markus Makela
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
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
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
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
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
MassimilianoPinto
21add3a8b4 Merge branch 'develop' into MXS-936 2016-11-10 12:02:40 +01:00
MassimilianoPinto
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
MassimilianoPinto
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
Johan Wikman
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