212 Commits

Author SHA1 Message Date
Markus Mäkelä
8b653133a7
Add shutdown detection
The maxscale_is_shutting_down function is used to detect when MaxScale
should stop. This fixes a race condition in the code where the workers has
not yet been initialized but a termination signal has been received. It
also replaces the misuse of the service_should_stop variable with a proper
function.
2018-08-29 11:06:11 +03:00
Markus Mäkelä
c92aa02961
Don't use log before initialization
The print_log_n_stderr function used to implicitly initialize the log
manager. As this is no longer done, no logging must be done before the log
manager is initialized.
2018-08-27 14:03:39 +03:00
Markus Mäkelä
fe7d7475a4
Improve PID file check
The executable name of the PID is now checked to be maxscale. This fixes
the problem where MaxScale would refuse to start if a stale PID file had a
PID of a process that's not a MaxScale process.
2018-08-23 15:46:46 +03:00
Markus Mäkelä
ad36a50e97
Remove log initialization form print_log_n_stderr
The log manager must not be initialized twice. If an error is to be logged
to a file, the log manager has already been initialized.
2018-08-23 15:46:46 +03:00
Marko
8e7b012852 Don't call some of atexit functions twice
Registering of atexit functions was fixed so these functions don't need
to be called here anymore.
2018-08-22 22:51:32 +03:00
Johan Wikman
3f53eddbde MXS-2020 Replace ss[_info]_dassert with mxb_assert[_message] 2018-08-22 11:34:59 +03:00
Johan Wikman
3576780f78 MXS-2008 Update gateway and tests to initialize maxbase
Update gateway and tests to initialize maxbase using

  maxbase::init();

instead of initializing individual components.
2018-08-21 10:02:39 +03:00
Johan Wikman
88f1795412 MXS-2008 Move Worker and MessageQueue to maxbase 2018-08-21 10:02:39 +03:00
Markus Mäkelä
fe7a73e5c3
Register atexit functions in the correct place
The atexit functions should be registered after there is a need for
them. This fixes the problem where cleanup functions were called before
the initialization for them was done. Also removed the header and footer
printint to stdout.
2018-08-20 13:56:59 +03:00
Markus Mäkelä
c38dcff53c
MXS-2019: Remove header and footer output
Now that the exit handlers work correctly, the output of `maxscale
--version` no longer consists of a single line but multiple lines in both
stdout and stderr. Removing the printing to stderr guarantees that the
correct output is produced.
2018-08-20 10:04:12 +03:00
Markus Mäkelä
667e9df97c
Merge branch '2.2' into develop 2018-08-17 18:10:44 +03:00
Markus Mäkelä
0fbd789572
MXS-2019: Fix atexit handlers
The code now registers all functions once instead of one function multiple
times.
2018-08-17 17:35:41 +03:00
Johan Wikman
cf0aeed516 MXS-2014 Rename log_manager.h to log.h
There's nothing resembling a manager anymore.
2018-08-17 10:59:37 +03:00
Marko
9370cda24b MXS-1663 Detect conflicting configurations and refuse to start
Use locks with the datadir and cachedir to detect if another MaxScale
instance attempts to use the same directories as the already running
MaxScale.
2018-08-15 22:23:32 +03:00
Markus Mäkelä
5a306aa20a
MXS-2005: Use log manager only after initialization
The log manager functions must not be used before it is initialized.
2018-08-14 14:57:34 +03:00
Markus Mäkelä
39ce6c624f
MXS-2005: Remove unused code
Removed skygw_utils and relate files along with the old log manager
code. Also removed file flushing due to it being redundant; messages are
written to the file immediately. Adjusted tests to accommodate this
change.
2018-08-14 14:57:33 +03:00
Markus Mäkelä
32b1711684
MXS-2005: Remove logging to shared memory
The feature was rarely used and was only useful in extremely rare
cases. The functionality can still be emulated, if for some reason needed,
by pointing `logdir` to `/dev/shm` or another tmpfs mount.
2018-08-14 14:57:33 +03:00
Markus Mäkelä
2852530893
Use standard RNG
The custom random number generator can now be replaced with a C++11
RNG. This greatly improves the reliability and trustworthiness of it.

In addition to this, the conversion of the RNG to a thread-local object
removes the race condition that was present in the previous
implementation. It also theoretically improves performance by a tiny bit.
2018-08-13 10:37:48 +03:00
Markus Mäkelä
70fa300fe1
Remove unnecessary mxs_log_flush_sync calls
The calls were unnecessary in the context where they were made.
2018-08-13 10:28:02 +03:00
Johan Wikman
2539183be2 MXS-2000 Add query_classifier_cache_size to maxscale resource 2018-08-09 08:37:44 +03:00
Markus Mäkelä
ec420332ea
MXS-1929: Take ResultSet into use
Replaced the previous RESULTSET with the new implementation. As the new
ResultSet doesn't have a JSON streaming capability, the MaxInfo JSON
interface has been removed. This should not be a big problem as the REST
API offers the same information in a more secure and structured way.
2018-07-31 22:50:08 +03:00
Markus Mäkelä
ad5762a2fb
Fix debug assertion on shutdown
The debug assertion that asserts that services are destroyed only on the
main worker would be triggered on shutdown as there is no current worker
at that point in time. In addition to this, it is wrong to call
service_destroy at shutdown as that will remove persisted
configurations. The service_free function can be called directly as we
know no other thread are running when the services are being torn down.

Also added the missing check that the destroyInstance function is
implemented before calling it.
2018-07-31 22:32:31 +03:00
Markus Mäkelä
3be975ba5d
Fix fixing of std::string object names
Comparing two fixed std::strings would have equal C strings but comparing
with operator== they would be different. This was a result of the string
modification done by fix_object_name.

Converted the internal header into a C++ header, added std::string
overload and fixed use of the function.
2018-07-31 09:41:15 +03:00
Markus Mäkelä
a833f39196
MXS-1929: Load global configuration as soon as possible
There exists a dependency on the configuration for the workers: the total
number of worker thread is defined by the `threads` parameter. This means
that the global configuration section must be read before workers are
started.

Commit 411b70e25656317909e54f748f8012593120041f broke MaxScale and turned
it into a single threaded application as the default configuration value
of one worker was used.
2018-07-31 09:41:14 +03:00
Markus Mäkelä
cca7757090
MXS-1929: Take internal Service struct into use
The internals now mostly refer to the Service struct instead of the public
SERVICE struct.
2018-07-31 09:41:13 +03:00
Markus Mäkelä
a50fce0c65
MXS-1929: Allow startup with no services
MaxScale can now be started with an empty configuration file and services
can be created at runtime. Filters cannot yet be created at runtime so
complete runtime creation of configurations is not yet possible.
2018-07-31 09:41:09 +03:00
Markus Mäkelä
823efffb00
Read config as late as possible
By reading the configuration as late as possible, we allow the objects to
be created in an environment which is nearly identical to the environment
that is present at runtime.

This change makes it possible to execute worker tasks in the instance
creation functions of various modules. The avrorouter in particular
depended on being able to queue worker tasks on startup.
2018-07-31 09:41:08 +03:00
Markus Mäkelä
a553ddba6e
MXS-1929: Split housekeeper initialization
The initialization and starting of the housekeeper is now done
separately. This allows housekeeper tasks to be created when the services
are being created while still preventing the execution of the task before
the startup is complete.
2018-07-31 09:41:08 +03:00
Markus Mäkelä
e2fb0093b1
Merge branch '2.2' into develop 2018-07-12 19:38:40 +03:00
Markus Mäkelä
b320217212
Remove configuration reloading
Removed the deprecated configuration reloading code. Added a entry into
the release notes that states this and the fact that it was deprecated in
2.2.
2018-07-11 14:08:54 +03:00
Markus Mäkelä
2df5763b6c
Add configuration exporting
The runtime configuration of a MaxScale can now be exported to a single
file. This allows modifications made via runtime configuration commands to
be "committed" for later use.
2018-07-07 09:28:50 +03:00
Johan Wikman
f2b8487577 MXS-1624 Add configuration parameter
With the global configuration parameter 'query_classifier_cache'
the query classification cache can be turned on. At the moment it
does not matter what value it has; its presence simply enables the
caching.

Eventually you will be able to specify how much memory the cache
is allowed to consume.
2018-07-06 12:12:31 +03:00
Johan Wikman
e7913cc022 MXS-1624 Update qc_setup() prototype
Now takes a structure that, if present, enables the query
classification caching and specifies the properties of the
cache.

For the time being no actual properties are yet available.
2018-07-06 12:12:31 +03:00
Markus Mäkelä
702f8aaed4
Merge branch '2.2' into develop 2018-07-05 13:53:14 +03:00
Markus Mäkelä
7954de0da6
Always log commit ID
There's no good reason to not include the commit ID in release build
startup messages.
2018-07-05 12:01:38 +03:00
Marko
d3c1ec4742 MXS-1664 Add --runtimedir config parameter 2018-07-04 22:38:28 +03:00
Johan Wikman
1eddb29d91 MXS-1915 Move Monitors on top of mxs::Worker
Monitors are now workers, so the path for making all interaction
between MaxScale proper and the monitors message based is now
open.
2018-06-26 09:19:46 +03:00
Johan Wikman
cc0299aee6 Update change date of 2.3 2018-06-25 10:07:52 +03:00
Markus Mäkelä
3d8f946e19
Take dump_stacktrace into use
MaxScale and tests now both use the same code to dump stacktraces.
2018-06-22 13:59:57 +03:00
Markus Mäkelä
13893cca3d
MXS-1914: Move maxscale_shutdown() into the core
The core library now contains the maxscale_shutdown() command. This makes
it possible to resolve all symbols at link time even for administrative
modules.
2018-06-18 12:58:50 +03:00
Markus Mäkelä
70fdd0fc17
Merge branch '2.2' into develop 2018-06-06 08:56:31 +03:00
Marko
1857252033 MXS-1749 Delete old process datadir on startup if it still exists
When starting MaxScale it deletes all of the old process datadirs that
might have not been cleaned up due to unexpected exit of the program.
2018-06-05 15:10:41 +03:00
Markus Mäkelä
95815df1db
Merge branch '2.2' into develop 2018-05-16 11:46:45 +03:00
Markus Mäkelä
bcc3312d8e
Merge branch '2.1' into 2.2 2018-05-16 11:45:48 +03:00
Markus Mäkelä
46d1187172
Backport GCC 8 fixes to 2.1
Backported the minimal set of changes required to build 2.1 with GCC
8. The format-truncation and format-overflow warnings are disabled instead
of fixed in 2.1 to remove duplication of effort that was already done in
2.2 (the commit doesn't cherry-pick cleanly).
2018-05-16 11:09:47 +03:00
Johan Wikman
42c10cfa1c MXS-1848 Move Worker from internal to public include dir
maxscale::Worker needs to be public if monitors should be
implementable using it.
2018-05-14 10:10:18 +03:00
Johan Wikman
bf2a97812d MXS-1848 Destroy all monitors at system shutdown 2018-05-07 14:08:36 +03:00
Johan Wikman
510eb7ec7c MXS-1848 Change monitorCamelCase to monitor_snake_case 2018-05-07 14:08:36 +03:00
Niclas Antti
62a3dd664d MXS-1755 Warn about unknown global configuration entries.
MXS_WARNING for unknown entries. Later to become an error (in 2.4).
2018-04-27 18:41:01 +03:00
Markus Mäkelä
59165b8dd5
Simplify housekeeper shutdown
The two-part shutdown procedure for the housekeeper was not needed and
caused problems if SIGINT wasn't raised. Since the main thread returns to
the main function, a single shutdown function is all that the housekeeper
needs to function.

Moved all the shutdown related code into Housekeeper::stop to remove the
waiting for the thread in the destructor.
2018-04-27 12:00:38 +03:00