190 Commits

Author SHA1 Message Date
Markus Mäkelä
ff8916046c Add link to documentation in --help output
The link points to the MaxScale 2.1 documentation root.
2017-10-21 14:55:56 +03:00
Johan Wikman
d1df1837a4 MXS-1464 When pre-parsing, only check maxscale section
When pre-parsing the configuration file, the existence of environment
variables is only done for the [maxscale] section. For other sections
a nicer error message is obtained if the comlplaint is made when the
configuration file is actually loaded.

Mechanism for providing custom error message from the pre-parsing
function added.
2017-10-12 14:56:09 +03:00
Johan Wikman
1666c9f0b6 MXS-1464 Add config 'substitute_variables'
With this variables set to true, if $VAR is used as a value in the
configuration file, then `$VAR` will be replaced with the value of
the environment variable VAR.
2017-10-12 14:56:09 +03:00
Markus Mäkelä
0e7f592bd7 Add file names and line numbers to stacktraces
The GLIBC backtrace functionality doesn't generate file names and line
numbers in the generated stacktrace. This can to be done manually by
executing a set of system commands.

Conceptually doing non-signal-safe operations in a signal handler is very
wrong but as stacktraces are only printed when something has gone horribly
wrong, there is no real need to worry about making things worse.

As a safeguard for fatal errors while the stacktrace is being generated,
it is first dumped into the standard error output of the process. This
will function even if malloc is corrupted.
2017-10-12 12:29:43 +03:00
Markus Mäkelä
3015e6c97d Add file names and line numbers to stacktraces
The GLIBC backtrace functionality doesn't generate file names and line
numbers in the generated stacktrace. This can to be done manually by
executing a set of system commands.

Conceptually doing non-signal-safe operations in a signal handler is very
wrong but as stacktraces are only printed when something has gone horribly
wrong, there is no real need to worry about making things worse.

As a safeguard for fatal errors while the stacktrace is being generated,
it is first dumped into the standard error output of the process. This
will function even if malloc is corrupted.
2017-10-09 16:14:36 +03:00
Markus Mäkelä
8c3c103060 Merge branch '2.2' into 2.2-mrm 2017-10-03 14:52:21 +03:00
Markus Mäkelä
cd83aa40db Stop monitors first when shutting down
As monitors aren't synchronized with the worker threads, they need to be
shut down first.
2017-10-03 14:47:16 +03:00
Markus Mäkelä
bd39284f9c Merge branch '2.1' into 2.2 2017-10-03 14:30:06 +03:00
Johan Wikman
438b4e0341 Merge branch '2.2' into 2.2-mrm 2017-10-02 15:49:08 +03:00
Markus Mäkelä
69557c650e Fix stack trace generation
The stack traces weren't logged as the LOG_ALERT priority wasn't enabled
by default. As an alert is intended to be something that must leave a
trace somewhere, and as such, it must not be possible to disable it. For
this reason, it is acceptable to always log the message if the priority is
LOG_ALERT.

Added the -rdynamic linker flag so that all symbols are exported when
linking MaxScale.

As the stack trace is printed in a signal handler, the first attempt
should be to print the stack trace to the standard output. This way the
output is printed before an attempt to use malloc is made when it is
logged to the logfile.
2017-09-30 12:37:40 +03:00
Markus Mäkelä
c6623337b6 Stop monitors first when shutting down
As monitors aren't synchronized with the worker threads, they need to be
shut down first.
2017-09-29 21:11:07 +03:00
Johan Wikman
89d1f81e37 Merge branch '2.2' into 2.2-mrm 2017-09-28 15:19:20 +03:00
Markus Mäkelä
895d950da0 Format all source files with Astyle
Formatted all source files Astyle.
2017-09-28 07:04:21 +03:00
Markus Mäkelä
1d2ba10a68 MXS-1446: Add passive parameter
The `passive` parameter can be given in the configuration file or on the
command line. It is displayed in the diagnostic output and changes to it
are persisted.

The variable itself does nothing.
2017-09-27 19:32:58 +03:00
Markus Mäkelä
bc510a1ad9 MXS-1446: Minor refactoring of gateway.cc
Cleaned up parts of the main function and moved the global configuration
initialization to the very beginning of the main function.
2017-09-27 19:32:58 +03:00
Johan Wikman
1b009f94cf Merge branch '2.1' into develop
MXS-1377
2017-09-20 11:08:48 +03:00
Johan Wikman
9d9cffe4c7 MXS-1377 Always delete the pid-file
Earlier the pid-file was deleted only if the MaxScale startup
succeeded and MaxScale exited in normal fashion.
2017-09-20 10:57:13 +03:00
Markus Mäkelä
4f7606ebc0 MXS-1405: Execute EXTERNCMD synchronously
The execution of external commands in MaxScale by monitors needs to be
synchronous in order to prevent the unintended detection of state changes.
2017-09-13 22:51:53 +03:00
Johan Wikman
a1d4f25392 Remove erroneous include 2017-09-07 16:56:19 +03:00
Markus Mäkelä
d931787e2e Use _exit when daemonizing the process
The original process should use _exit if the forking of the child process
is successful. This makes sure that the exit handlers are called only when
the daemon process exits.
2017-09-04 17:56:34 +03:00
Johan Wikman
2da7a93473 Destroy workers after services
The workers need to be destroyed only after services have been
to ensure that they are around in case the destruction of services
involves the closing of dcbs.
2017-09-04 16:01:42 +03:00
Johan Wikman
68b7d88fa1 Check return value of freopen
Otherwise compilation fails in release mode.
2017-08-30 14:36:51 +03:00
Markus Mäkelä
0e89e445f2 Bind admin interface to IPv4 if IPv6 fails
The default interface for the admin interface is the IPv6 address '::'
which corresponds to the IPv4 address '0.0.0.0'. If the system doesn't
support IPv6, then an attempt to bind on IPv4 should be made.
2017-08-25 13:54:10 +03:00
Markus Mäkelä
19bae79784 Allow redirection of stdout/strerr
Added a debug option that allows stdout and stderr to be redirected to a
file. This helps with the use of ASAN which prints all of its findings to
stderr.
2017-08-18 10:27:28 +03:00
Johan Wikman
49ba1f8fa0 MXS-1360 Add 'thread_stack_size' configuration value
Using the 'thread_stack_size' configuration value, the stack size
of the worker threads can be adjusted.
2017-08-14 15:31:00 +03:00
Johan Wikman
e9b2a560b8 MXS-1360 Make it possible to specify thread stack size
It is now possible to specify the thread stack size to be used,
when a new thread is created. This will subsequently be used
for allowing the stack size to be specified for worker threads.
2017-08-14 15:24:16 +03:00
Markus Mäkelä
854c4a1ed3 Add support for non-glibc systems
MaxScale can now be built on systems that use an alternative libc
implementation e.g. musl.
2017-08-02 11:51:55 +03:00
Markus Mäkelä
469b432ebe Detect and handle OpenSSL 1.1
OpenSSL 1.1 supports most of the native threading libraries, including
pthread. This means that only versions before 1.1 need the thread handling
code.
2017-06-30 10:42:20 +03:00
MassimilianoPinto
cb57e10761 Develop merge
Develop merge
2017-06-29 15:34:22 +02:00
Esa Korhonen
77a692e0c3 Set minimun VLA size to 1 2017-06-16 10:17:27 +03:00
Esa Korhonen
3260069ed8 Fix compile error on Centos7 2017-06-15 15:17:33 +03:00
Esa Korhonen
81eeed55aa Add generic debug flag to MaxScale
MXS-1282. The flags "-g=arglist" or "--debug=arglist" activate
the debug settings specified in the comma-separated list arglist.
Currently, the setting "disable-module-unloading", which prevents
modules (.so-files) from being unloaded at exit, is supported. This
allows Valgrind to produce line numbers for leak reports when the
memory was allocated in a module. The setting "enable-module-unloading"
is also available, but this is activated by default.

The debug arguments and their actions are defined in a structure
array, so adding more is straightforward.
2017-06-15 11:23:34 +03:00
Johan Wikman
f546a17e77 Update change date of 2.2 2017-06-01 10:24:20 +03:00
Markus Mäkelä
ead9059eeb MXS-1220: Add /users/ resource
The /users/ resource shows all user accounts that can be used with
MaxScale. This resource is further split into two resource collections,
/users/inet and /users/unix, which contain the network users and Linux
accounts respectively.
2017-05-24 15:05:10 +03:00
Markus Mäkelä
ca7b24f6fa MXS-1220: Allow admin interface to be disabled
Allowing the admin interface to be disabled completely makes it possible
to remove any security concerns that could arise from its use.
2017-05-14 10:06:02 +03:00
Markus Mäkelä
4ed4773d91 MXS-1220: Allow binding to a specific address
The admin interface can now bind to a specific network interface.
2017-05-04 09:17:50 +03:00
Markus Mäkelä
23b6fb3e6d MXS-1220: Create separate admin thread
When MaxScale is started, a separate thread for the administrative
interface is started. This allows the worker threads to handle client
requests while the administrative thread handles the lower priority
administrative requests.

The administrative interface responds to all request with a 200 OK HTTP
response. This allows the administrative interface itself to be tested.
2017-05-04 09:10:31 +03:00
Johan Wikman
ab31cd4b1a Use O_DIRECT, but only if available.
TODO: The kernel version should be looked up at startup and made
      generally available so that it is readily available for
      anybody interested.
2017-05-03 13:39:26 +03:00
Johan Wikman
a27bec5e88 Add return value to Worker::init()
Cleaner to return status than exit upon failure.
2017-04-21 19:57:45 +03:00
Johan Wikman
f1e99a475a Remove unneded worker C-API 2017-04-20 13:51:16 +03:00
Johan Wikman
b89cf62d38 Sorting out merge from 2.1 2017-04-20 13:51:16 +03:00
Johan Wikman
5138032fe5 Add shutdown support
The shutdown is now performed so that a shutdown message is
sent to all workers. When the workers receive that message, they
turn on a shutdown flag, which subsequently is checked in the poll
loop.
2017-04-20 13:51:16 +03:00
Johan Wikman
016ed89b3e Move worker thread management to worker
The worker threads are now started by the workers themselves.
2017-04-20 13:51:16 +03:00
Johan Wikman
72977128f7 Introduce private worker header 2017-04-20 13:51:16 +03:00
Johan Wikman
bb6e0767cc Add first version of MXS_WORKER
MXS_WORKER is an abstraction of a worker aka worker thread.
It has a pipe whose read descriptor is added to the worker/thread
specific poll set and a write descriptor used for sending messages
to the worker.

The worker exposes a function mxs_worker_post_message using which
messages can be sent to the worker. These messages can be sent from
any thread but will be delivered on the thread dedicated for the
worker.

To illustrate how it works, maxadmin has been provided with a new
command "ping workers" that sends a message to every worker, which
then logs a message to the log.

Additional refactoring are needed, since there currently are overlaps
and undesirable interactions between the poll mechanism, the thread
mechanism and the worker mechanism.

This is visible currently, for instance, by it not being possible to
shut down MaxScale. The reason is that the workers should be shut down
first, then the poll mechanism and finally the threads. The shutdown
need to be arranged so that a shutdown message is sent to the workers
who then cause the polling loop to exit, which will cause the threads
to exit.

That can be arranged cleanly by making poll_waitevents() a "method"
of the worker, which implies that the poll set becomes a "member
variable" of the worker.

To be continued.
2017-04-20 13:51:16 +03:00
Johan Wikman
85faca74f7 Move DCB specific event handling to dcb.c 2017-04-20 13:51:16 +03:00
Johan Wikman
c3cfc86a7b Merge branch '2.1' into develop 2017-04-19 18:19:13 +03:00
Markus Mäkelä
a54d6fe816 Add connector plugindir to help output
The output now displays the connector directory.
2017-04-13 17:57:52 +03:00
Markus Mäkelä
7bd05d4581 Merge branch '2.1' into develop 2017-03-22 15:20:21 +02:00
Johan Wikman
4ca3c19ee3 Use [true|false] instead of [TRUE|FALSE] 2017-03-21 15:17:44 +02:00