1465 Commits

Author SHA1 Message Date
counterpoint
a58b25d6c3 Fix mistakes 2015-11-19 15:51:18 +00:00
counterpoint
e7a30a7944 Overhaul monitor_common functions and move into monitor.c 2015-11-19 15:40:43 +00:00
Johan Wikman
6164b7f301 Fixed unsafe use of localtime
Since localtime is not thread-safe it should not be used in multithreaded
contexts. For this reason all calls to localtime were changed to localtime_r
in code where concurrency issues were possible.

Internal tests were left unchanged because they aren't multithreaded.
2015-11-19 17:17:16 +02:00
Johan Wikman
6613723a1f Update error message when startup fails
Claiming that the loading of maxscale.cnf failed in case of any
error was misleading. Maxscale may not succeed in opening it,
reading it or processing it.
2015-11-19 09:28:14 +02:00
Johan Wikman
3e3770fa82 ss_dassert() no longer uses skygw_log_write.
Use of skygw_log_write() in ss_dassert and ss_info_dassert replaced
with the use of MXS_ERROR(). In addition, ss_dassert and ss_info_dassert
are now expressions that require a trailing ;.
2015-11-18 14:56:08 +02:00
Markus Makela
eb0cf745ca Filters not being found is now an error instead of a warning.
The log message was labeled as a warning instead of an error and finding out
the real reason why MaxScale didn't start when a filter wasn't found was difficult.
2015-11-18 11:50:35 +02:00
Markus Makela
41d26b5b73 Failure to load filters is now a configuration error
When a filter module is not found or the instance creation fails, this is considered
a fatal error and MaxScale will not start. If a failure occurs when the configuration
is being reloaded, the service will not use filters and an error will be logged.
2015-11-17 12:04:47 +02:00
Markus Makela
074f37e997 Fixed crash when filters fail to load
The number of filters wasn't decreased if a filter failed to load resulting
in a crash when the filters were applied.
2015-11-17 03:04:23 +02:00
Markus Makela
b22d40b06b Fixed PCRE2 beng built when CMake is configured
The bundled PCRE2 library will be built as a separate target and configuring
CMake no longer builds it. Instead, it will only be built when it is out of date.
This requires all targets to declare that they depend on the pcre2 target in
order for it to be built.
2015-11-16 13:59:47 +02:00
Markus Makela
40dc49c887 Filters are now loaded and created at startup
Previously filter instances were created when the first session was made. This
caused filter configuration errors to be noticed only after MaxScale was successfully
started. Now filters are loaded and the instance is created when a service applies its filters.
2015-11-16 13:31:33 +02:00
Markus Makela
ab6dae897d Removed unnecessary locking when modifying server status
Server lock was used when the server status was modified even though only
one thread should ever be modifying the server status.
2015-11-16 13:02:17 +02:00
Johan Wikman
a355e1beef Printf format checking added to logging function.
Printf format checking added to logging function and all
issues that were revealed by that fixed.
2015-11-16 12:40:49 +02:00
Johan Wikman
44df53d846 LOGIF and skygw_write_log removed from server/core/*.c
LOGIF and skygw_write_log removed from server/core/*.c and
replaced with calls to MXS_(ERROR|WARNING|NOTICE|INFO|DEBUG).
This is a mechanism change, no updating of the actual message
has been performed.

Currently this causes a very small performance hit, since the
check whether the priority is enabled or not is performed in
the function that is called and not before the function is called.
Once all LOGIFs and skygw_write_logs have been replaced, the
behaviour will be altered back to what it was.
2015-11-16 09:49:12 +02:00
Johan Wikman
bcb918e60b Log: Another step in the move from logfiles to priorities.
skygw_[enable|disable]_log has now been removed from the external
interface and priorities must instead be set using
mxs_log_set_priority_enabled(int priority, bool enabled). A bitmask
is already being updated, but internally and as used by the LOG_IF
macros, the actual enabling is still made using logfile ids.

The configuration entries have been replaced as follows:

	log_messages -> log_notice
	log_trace    -> log_info

The old ones can be used, but cause a warning to be logged.

Similarily the maxadmin commands have been updated.
"[enable|disable] log ..." works as expected, but there will be
a message about it being deprecated. Instead there is now a
[enable|disable] log-priority err|warning|notice|info|debug
command that should be used instead.
2015-11-14 22:28:17 +02:00
Johan Wikman
2dcdab29b6 LOGIF_MAYBE macros cleaned away.
Used in few places and only obscured what was going on.
2015-11-14 22:28:17 +02:00
Johan Wikman
86dcd1cc0f LOGIF_MAYBE macros cleaned away.
Used in few places and only obscured what was going on.
2015-11-14 21:51:27 +02:00
Markus Makela
8d0bd8150a Merge branch 'MXS-329-develop-20151111' into develop 2015-11-13 17:26:34 +02:00
Markus Makela
b0c48c3f66 Updated config.c to use PCRE2
config.c now uses PCRE2 to clean up parameter values.
2015-11-13 16:44:23 +02:00
Markus Makela
0b2e00118a Added missing initialization
The service->protocol->listener was never initialized in serviceAddProtocol
and caused a crash if the listener was not started.
2015-11-13 16:38:22 +02:00
Markus Makela
76856e6c90 Fixed compiler warnings. 2015-11-13 11:53:12 +02:00
Markus Makela
6b88b6b17f Merge branch 'develop' into MXS-329-develop-20151111 2015-11-13 07:48:59 +02:00
Markus Makela
1433d28f5f Added missing initialization for monitor parameters
Monitor parameters were uninitialized and the pointer was used when
the monitors were started.
2015-11-13 06:54:13 +02:00
Johan Wikman
2c1b53c120 Log: Cleanup of API
skygw_ functions removed and replaced with mxs_ equivalents.
logfile_id_t removed.
2015-11-12 18:31:53 +02:00
Johan Wikman
05fbdb1b76 Log: skygw_log_flush replaced with mxs_log_flush.
skygw_log_flush replaced with mxs_log_flush and skygw_log_sync_all
with mxs_log_flush_sync.
2015-11-12 18:28:34 +02:00
Johan Wikman
c7a329e43e Log: skygw_logmanager_init renamed to mxs_log_init.
skygw_logmanager_init renamed to mxs_log_init and skygw_logmanager_done
renamed to mxs_log_finish. skygw_logmanager_exit removed alltogether as
all it did was to call skygw_logmanager_done. That appears to have been
a source for confusion as in many places a call to skygw_logmanager_done
was followed by a call to skygw_logmanager_exit. In addition, the function
skygw_log_done was removed from the header, since it lacked an
implementation.
2015-11-12 16:06:44 +02:00
Johan Wikman
680345d374 Whitespace cleanup of config.c
- Tabs replaced with spaces.
- Allman indentation style
2015-11-12 16:06:02 +02:00
Markus Makela
5efd564573 Fix to MXS-288: https://mariadb.atlassian.net/browse/MXS-288 Added MySQL 5.7 authentication
The change to the mysql.user table in MySQL 5.7 caused MaxScale to stop
working with it. This commit adds functionality that checks which version of
the user data query should be made. It also moves common code related to
server version strings to server.c
2015-11-12 15:24:27 +02:00
Johan Wikman
bdfd72404b Log: skygw_log_rotate replaced with mxs_log_rotate.
With only one log-file no arguments are needed. The maxadmin command
'flush log'  still accepts all the previous arguments, but warns about
them being deprecated.
2015-11-12 14:48:37 +02:00
Markus Makela
e37ba0a63d Fixed build failures due to conflicts
Due to an odd rebase, a conflict was left in externcmd.c
2015-11-11 21:38:37 +02:00
Markus Makela
ba9da9ae3d Fixed invalid EXTERNCMD allocation
externcmd_allocate now returns either a valid EXTERNCMD or NULL.
2015-11-11 21:26:10 +02:00
Markus Makela
2d600868f5 Added argument substitution to monitor scripts 2015-11-11 21:19:07 +02:00
Markus Makela
466224b316 Moved common monitor code to externcmd.c
File existence and permission checks are now done in externcmd_can_execute
2015-11-11 21:19:07 +02:00
Markus Makela
d56843835c Cleaned up externcmd_allocate and externcmd_free 2015-11-11 21:19:07 +02:00
Markus Makela
9ab5326960 Fix to MXS-438: https://mariadb.atlassian.net/browse/MXS-438
Maxinfo now supports the shutdown command which shuts down a service, monitor
or MaxScale itself and the restart command which restarts a stopped monitor
or service.
2015-11-11 18:59:39 +02:00
Markus Makela
3ea55e3b50 Fix to MXS-437: https://mariadb.atlassian.net/browse/MXS-437
Maxinfo now allows users to flush logs and change the server status
through the MySQL interface.
2015-11-11 18:57:19 +02:00
Markus Makela
30d1fc66b7 getCapabilities no longer takes arguments and returns an int. 2015-11-11 18:14:03 +02:00
Markus Makela
264944ff23 Service users are set to NULL after they are freed. 2015-11-11 18:02:01 +02:00
Markus Makela
c5c416e7fe Fixed modification of parameters
Monitor parameters were being modified in externcmd_allocate which caused truncation
of the arguments to the commands.
2015-11-11 18:01:09 +02:00
Markus Makela
8363673be6 Added number of inserted elements to hashtable
Added tracking of the number of inserted elements to the hashtable.
Also added utility function to get the size of the hashtable.
2015-11-11 17:57:35 +02:00
Markus Makela
cd6f7ce046 Fix to MXS-447: https://mariadb.atlassian.net/browse/MXS-447
Monitors are now started after they have been fully configured.
2015-11-11 17:54:41 +02:00
Johan Wikman
acb0a523a7 Log: No more argv parsing for log manager.
Earlier, the global setting for the syslog decided whether syslog
was enabled when skygw_logmanager_init was called, but not whether
logging to syslog actually was made.

Now syslog logging is enabled by default and the global setting
decides whether or not syslog logging actually is made. That is,
this opens up the possiblity for making it possible to turn on
and off sysloging at runtime.

Further, although the API led you to believe otherwise, it was
hardwired that LOGFILE_ERROR and LOGFILE_MESSAGE messages were
written to syslog.

The changed removed the need for passing an argv array explicitly.
2015-11-11 13:53:14 +02:00
Johan Wikman
24bed47794 Syslog ident must be provided explicitly.
The syslog ident must be provided explicitly when calling
skygw_logmanager_init (and not provided via the argv array).
It can be NULL, in which case it automatically will be the program
name.

The openlog() call is now always made, irrespective of what the
value of the global syslog flag is. That way it will be possible
to turn syslog logging on or off after the fact.
2015-11-11 13:48:57 +02:00
Johan Wikman
55dbaa49c0 Logging target must be explicitly defined.
Whether the log-file should be written to the filesystem or to
shared memory must now be explicitly defined when calling
skygw_logmanager_init() (instead of passing that via the argc/argv
construct).

Also, the meaning of '-l' when invoking maxscale has been changed.

Earlier -l [file|shm] specified whether the trace and debug logs
should be written to shared memory (while the error and message
logs always were written to the filesystem) and the _default_
was to write them to shared memory.

Now, with only one file, '-l' has still the same meaning, but it
decides whether the one and only logfile should be written to shared
memory, or the filesystem and the _default_ is to write it to the
filesystem.
2015-11-11 13:47:34 +02:00
Johan Wikman
90a8646ac2 Whitespace and indentation changes.
Also changed line-endings from DOS CRLF to only LF.
In addition, made functions const correct.
2015-11-11 13:43:15 +02:00
counterpoint
2183d5d3c5 Fix mistakes in merging. 2015-11-11 11:31:07 +00:00
counterpoint
dee20fe077 Merge remote-tracking branch 'origin/develop' into MXS-329-develop-20151111
# Conflicts:
#	server/core/CMakeLists.txt
#	server/core/buffer.c
#	server/core/service.c
#	server/modules/filter/tee.c
#	server/modules/monitor/mysql_mon.c
#	server/modules/routing/binlog/blr.c
#	server/modules/routing/binlog/blr_slave.c
#	server/modules/routing/debugcmd.c
#	server/modules/routing/readwritesplit/readwritesplit.c
#	utils/skygw_utils.cc

- resolved.
2015-11-11 11:08:02 +00:00
counterpoint
1fc6b00211 Add conditionally compiled mechanism to "show buffers" to give a list of the currently allocated buffers, with a trace for each one of the calls that led to its creation. 2015-11-11 09:03:48 +00:00
Johan Wikman
49866b5959 ss_info_dassert now enabled also in release mode. 2015-11-10 21:19:50 +02:00
Johan Wikman
450078fa92 Interface of skygw_logmanager_init(int argc, char* argv[]) changed.
The previous interface of skygw_logmanager_init was conceptually
broken. With -o you could specify that logging should be done to
stdout. However, even if you did that, the log manager still checked
that the logging directory could be accessed. Unless it had been
specified using -j <path> the default was /var/log/maxscale.

That is, unless the program calling skygw_logmanager_init was invoked
by a user that had write access to /var/log/maxscale, there would be
a complaint even if nothing was ever written to that directory.
In practice this meant that even if -o was used you had to provide
a -j with a path that surely is writeable (e.g. "/tmp").

This has now been changed so that you explicitly must provide the
log directory and the flags -j and -o are removed.

  bool skygw_logmanager_init(const char* logdir, int argc, char* argv[]);

If /logdir/ is provided then logged messages are written to a log file
in that directory. If /logdir/ is NULL then messages are logged to stdout
and no checks for access to any directory is not made.
2015-11-06 14:20:05 +02:00
Markus Makela
548d03005b Added test for maxscale_pcre2.c 2015-11-05 10:19:24 +02:00