659 Commits

Author SHA1 Message Date
vraatikka
f50de7a084 build_gateway.inc
Removed MARIADB_SRC_PATH
	Added MYSQL_ROOT - root directory where MariaDB headers are installed
	Added MYSQL_HEADERS - -I notation for three header directories
	Added EMBEDDED_LIB - for embedded library directory
	Added ERRMSG - for errmsg.sys file

log_manager.cc
	Little fixes

log_manager/makefile
	Updated header include directive

makefile.inc
	Removed DEBUGGER and BACKGR as unnecessary
	Added LIB for embedded library file name

query_classifier/makefile
	Updated header include directives and embedded library directory

query_classifier/query_classifier.cc
	clean up

server/core/Makefile
	Updated header include directives and embedded library directory
	Added libaio and install of errmsg.sys

server/core/dcb.c
	clean up

server/core/gateway.c
	Added --language and --skip-innodb to mysql_library_init command-line arguments list
	clean up

server/core/load_utils.c
	clean up

server/modules/monitor/Makefile
server/modules/routing/readwritesplit/Makefile
	Updated header include directives and embedded library directory

utils/skygw_debug.h
	http://bugs.skysql.com/show_bug.cgi?id=369

utils/skygw_types.h
utils/skygw_utils.cc
	clean up
2013-12-06 00:12:41 +02:00
vraatikka
258bcb27da log_manager.cc
Added global variable lm_enabled_logfiles_bitmask which holds a bit for each enbaled logfile. It is updated when situation changes. 

gateway.c
	Changed gateway.c:main so that command-line argument -f specifies either the name of config file in $MAXSCALE_HOME/etc or exact location and name of it. Updated README correspondingly.
	Added eternal variable lm_enabled_logfiles_bitmask to be used for quick check before calling logging library functions.
2013-12-04 09:56:48 +02:00
Mark Riddoch
84fbf15bef Updates configuration for backward compatibility and improved error handling 2013-12-02 15:14:52 +00:00
Mark Riddoch
37426a8be6 Updated in line with changes made to the code by Vilho 2013-12-02 10:09:04 +00:00
vraatikka
cbbf3239a5 Doxygen compliance corrections 2013-12-01 21:47:38 +02:00
vraatikka
4a006dd707 Log manager is initialized before configu file name resolution so that if home directory is successfully set, further issues would be logged in log files located under home directory instead of /tmp/.. 2013-12-01 21:37:40 +02:00
vraatikka
6d0d85396e Added global default configuration file name "etc/MaxScale.cnf"
Added following static functions:
        bool  file_is_readable(char*)
        bool  file_is_writable(char)
        void  usage(void)
        char* get_expanded_pathname(char*, char*, char*)
        void  print_log_n_stderr(bool, bool, char*, char*, int)
        bool  resolve_maxscale_conf_fname(char**, char*, char*)
        bool  resolve_maxscale_homedir(char**)

Added new command-line argument '-f' which allows the user for specifying relative, or absolute pathname for configuration file. It is also possible to specify only a file name which will be concatenated to path held in MAXSCALE_HOME environment variable.

Old command-line parameter '-c' allow the user for specifying MaxScale home directory also as relative or absolute path. Relative path will be expanded before tested for readability and for writeability.
2013-11-29 23:49:37 +02:00
vraatikka
41298a09df Bugzilla entry # 363:
skygw_thread_t and simple_mutex_t make own copy of name argrument. Changed init calls to both accordingly.
2013-11-27 10:51:45 +02:00
vraatikka
8d1553b693 Bugzilla #362, http://bugs.skysql.com/show_bug.cgi?id=362
Modified datadir_cleanup so that it calls nftw to walk the directory tree and remove files and directories it meets.
2013-11-26 21:48:54 +02:00
vraatikka
f9a2a75987 Removed specific version number from MariaDB source path. Replaced it with 'mariadb/5.5' because 5.5 is supported and all existing versions still have serious issues. First possibly working version is 5.5.35 which isn't released yet. 2013-11-26 16:57:25 +02:00
vraatikka
4057ae0b0f log_manager.cc
renamed file_exists to file_exists_and_is_writable, added missing file open flags.

gateway.c	
	Removed command-line parameter '-m' because setting LD_LIBRARY_PATH after the program has started has no effect.
	Corrected some comments.
2013-11-26 16:52:48 +02:00
Massimiliano Pinto
8951f446ac - Removed the MARIADB_SRC_PATH twice set.
- Removed team member names from path examples
2013-11-26 12:49:29 +01:00
vraatikka
973a9a34d7 Added comment about '-m <modules directory>' 2013-11-26 13:07:14 +02:00
vraatikka
bc97b7f5ec log_manager.cc
external optind variable must be reset before using it because getopt may have been called earlier in the same process and without resetting argument parsing fails.

dcb.c
	check dcb state before attempting to write to dcb in dcb_write

gateway.c
	daemon_mode moved to global so that it can be taken into account when deciding where to print messages.
	added get_config_filename by using home directory name given as a parameter. Returns absolute paths to config file and to home directory regardless of home directory argument was relative of absolute.
	In main, arguments are parsed by using getopt.
	Changed argument '-c' to specify home directory because MaxScale.cnf is always in <home>/etc/ directory.
	Added argument '-m' to specify modules directory. Both arguments override any other settings.

skygw_types.h
	Added PATH_MAX
2013-11-26 12:53:46 +02:00
Mark Riddoch
f88969c214 Code tidyup 2013-11-25 16:53:17 +01:00
Mark Riddoch
1437d3f18a Update to arguemnt parsing 2013-11-25 15:50:56 +00:00
Mark Riddoch
050ca7ac7e Some fixes for doxygen generation 2013-11-25 10:12:08 +01:00
vraatikka
3b0d6c23ad log_manager.cc
Commented why spread-down logging is disabled. 
	In MaxScale start, log paths are printed in their complete form to make it easier to copy-paste the names.

gateway.c
	Replaced print_signal_set_error with more general-purpose print_log_n_stderr which prints non-formatted messages to error log and to stderr to the point MaxScale switches to run in daemon process. After that only error log is printed.

skyge_utils.cc
	polish
2013-11-25 10:49:45 +02:00
vraatikka
4f14c65040 Polished error mesesages, and made them consistent. 2013-11-22 21:17:38 +02:00
vraatikka
841c51fc5c Polished error messages in main, and made them consistent. 2013-11-22 12:01:41 +02:00
vraatikka
323fb8164e mysql_send_auth_error didn't check whether dcb is in DCB_STATE_POLLING state. If it is, function now returns. 2013-11-21 15:35:55 +02:00
vraatikka
4b2270727b Removed unnecessary debug assert. 2013-11-21 12:07:32 +02:00
vraatikka
4ed4419327 mysql_send_custom_error writes to client dcb but didn't check whether it was in the correct state. 2013-11-21 09:47:02 +02:00
vraatikka
a30e2ab29b Added back read and write mutex to dcb. Locks are acquired in poll.c before calling call-back functions. Additional locks efficiently hide memory corruption issue, which appears when readconn router is used without using those mutexes, with multiple parallel maxscale threads and intensive load. 2013-11-20 17:23:04 +02:00
vraatikka
35d34862b9 Replaced with MaxScale_template.cnf 2013-11-20 16:07:12 +02:00
vraatikka
4b1527b1c8 query_classifier.cc
Replaced fprintf's with log write commands, removed the second argument from call of mysql_reset_thd_for_next_command(thd) according to changes in mariadb/5.5/sql/sql_parse.c #rev 3958.

server/Makefile
	Instead of installing MaxScale.cnf (and overwriting previous config file), install MaxScale_template.cnf to DEST directory.

config.c
	Replace references to 'Gateway' with 'MaxScale', change configuration parameter 'auth' to 'passwd' as it is named in other instances where referenced to password.
2013-11-20 15:55:43 +02:00
Massimiliano Pinto
0f120e5593 Added
ss_dassert(len > 0);

before gw_mysql_do_authentication()
2013-11-18 11:16:35 +01:00
vraatikka
1c96824cb3 log_manager.cc
Declared program_invocation_name, and program_invocation_short_name. They are used as identifier strings in syslog logging in cases where log_manager is not initialized explicitly and/or the caller hasn't specified program name as one of the arguments in arguments array.

	Fixed memory corruption. Length of sequence number of file name was calculated to as one too short and one byte was written to unallocated memory.

	Freed also the linkpath in cases where at least one of the log files is written to shm and a symlink is added to log directory.

mysql_client.c
	Added debug check for protocol pointer because of memory issues in mysql_client.c
2013-11-13 22:08:10 +02:00
vraatikka
1a3fa578da Fixed snprint_timestamp function which left one byte garbage to log file. 2013-11-12 17:49:28 +02:00
vraatikka
836c7ad76d Removed erroneous Warning print. Monitor users and passwords are read in different place. 2013-11-12 15:20:04 +02:00
vraatikka
4487817f59 Renamed shutdown_maxscale to shutdown_server according to definition in gateway.c. 2013-11-12 11:51:31 +02:00
vraatikka
517b6a5ee3 Added argument '-m' to skygw_logmanager_init which takes the identity string for syslog as additional argument. If syslog is enabled in configuration, but identity is not specified, host process name is used. 'maxscale', for example. 2013-11-11 11:02:05 +02:00
vraatikka
b996631fc9 log_manager.cc
Added syslog support. There's a new argument '-l' which takes log file ids as additional arguments. Writes to those logs will be written to syslog as well. syslog write causes additional overhead. Thus, writing frequently may become a bottleneck.

gateway.c
	Set LOGFILE_ERROR, and LOGFILE_MESSAGE to be log files whose writes will be copied to syslog too.
2013-11-10 20:45:48 +02:00
vraatikka
9ba7a0d955 log_manager.cc
Added new argument '-s' which takes additional argument composed of list of logfile identifiers. Logfiles listed with '-s' will be written on main memory instead of disk. In practice, the log file in question will be written in /dev/shm but corresponding symlink is added to log directory. In the case of name conflicts with log files and links, a differentiating sequence number is included in hte name of the file. This, however, is done only when existing file is not writable or is of different type (symlink <> file). 
	Added new logfile LOGFILE_DEBUG whose contents will be largerly what was included up to date in trace log. 

	Disabled feature which spreads writes to log files to others because of bug (#338) in the way block buffers are managed.

	Changed log manager parameters to match with the current implementation. List of arguments:
                "-h - help\n"
                "-a <debug prefix>   ............(\"skygw_debug\")\n"
                "-b <debug suffix>   ............(\".log\")\n"
                "-c <trace prefix>   ............(\"skygw_trace\")\n"
                "-d <trace suffix>   ............(\".log\")\n"
                "-e <message prefix> ............(\"skygw_msg\")\n"
                "-f <message suffix> ............(\".log\")\n"
                "-g <error prefix>   ............(\"skygw_err\")\n"
                "-i <error suffix>   ............(\".log\")\n"
                "-j <log path>       ............(\"/tmp\")\n"
                "-s <shmem log file ids> ........(no default)\n";

dcb.c
	dcb_add_to_zombieslist, add dcb to the front of zombies list instead of inserting to the end of it.

gateway.c
	Renamed shutdown_gateway to shutdown_server (Bug #131)
	Call skygw_logmanager_init so that trace and debug logs are written to shared memory.

poll.c 
dcb.h
	Removed some dead code and references to unneeded mutexes.

debugcmd.c
	Added enable/disable log command for debug log.

skygw_utils.cc
	skygw_file_init now takes optional symlink name as a second argument. Symlink is created to point to the file being created.
2013-11-08 12:56:39 +02:00
vraatikka
594f1c294f Added include of stdlib.h because malloc needs it to work. Malloc time to time fails in server/core/buffer.c and produces the following error:
*** Error in `./maxscale': malloc(): memory corruption (fast): 0x00007f3988005510 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x7afc6)[0x7f39c67a9fc6]
/lib64/libc.so.6(+0x7d245)[0x7f39c67ac245]
/lib64/libc.so.6(__libc_malloc+0x63)[0x7f39c67ad633]
./maxscale(gwbuf_alloc+0x34)[0x406250]
/home/raatikka/bin/tmp/MaxScale/modules/libMySQLClient.so(MySQLSendHandshake+0x19b)[0x7f39afb09bc0]
/home/raatikka/bin/tmp/MaxScale/modules/libMySQLClient.so(+0x4d1b)[0x7f39afb0ad1b]
./maxscale(poll_waitevents+0x42a)[0x40d0c3]
/lib64/libpthread.so.0(+0x7e0f)[0x7f39c6ae5e0f]
/lib64/libc.so.6(clone+0x6d)[0x7f39c681844d]
======= Memory map: ========
00400000-0041a000 r-xp 00000000 08:03 6686345                            /home/raatikka/bin/tmp/bin/maxscale
00619000-0061a000 r--p 00019000 08:03 6686345                            /home/raatikka/bin/tmp/bin/maxscale
0061a000-0061b000 rw-p 0001a000 08:03 6686345                            /home/raatikka/bin/tmp/bin/maxscale
012fa000-0141e000 rw-p 00000000 00:00 0                                  [heap]
7f3984000000-7f3984021000 rw-p 00000000 00:00 0 

- and so forth.
2013-11-03 20:54:41 +02:00
vraatikka
38b44a3a3a gw_client_hangup_event, didn't take into account the possibility that session_alloc had failed in which case the session pointer of client dcb is NULL. 2013-10-31 22:57:04 +02:00
vraatikka
3769a02957 query_classifier.cc
resolve_query_type, added GSYSVAR_FUNC type for functions that read system variables and can be executed in Maxscale instead of backend server.

dcb.c
	dcb_read, if read returns value <= 0 and if error is EAGAIN/EWOULDBLOCK so there was nothing to read in sthe socket, that is not an error because some other thread may have read the data that was expected to be available.

mysql_backend.c
	gw_read_backend_event, used dcb->authlock to ensure that dcb's protocol state is read and modified serially. This removes issues with false authentication failures which may happen when two threads modify and read the state without any control.

mysql_client.c 
	removed dead code.

readconnroute.c, readwritesplit.c
	removed invalid assert which assumed that spinlock can not have larger value than one when itis locked.
2013-10-31 22:24:51 +02:00
vraatikka
e803acb036 dcb.c, gateway.c little tuning.
poll.c
	Removed mutex from epoll_wait.
	Removed read and write mutexes from poll_waitevents.

session.c
	If session_alloc fails, instead of calling directly free(session), call session_free, which decreases refcounter and only frees session when there are no references left. 
	Added session_unlink_dcb function which removes link from session and optionally sets the dcb->session pointer to NULL.

readconnection.h, readwritesplit.h
	Added check fields to ROUTER_CLIENT_SES strct as well as lock, version number (not used yet) and closed flag.

mysql_backend.c
	gw_read_backend_event: if backend_protocol->state was set to MYSQL_AUTH_RECV, function returned, which was unnecessary. If mysql state became MYSQL_AUTH_FAILED, router client session was closed. Removed unnecessary NULL checks because rsession is not allowed to be NULL. Similarly, removed other NULL checks and replaced them with asserts checking that router client session is not NULL at any phase.

mysql_client.c
	Removed unused code blocks. Polished log commands. Replaced router client sessions NULL checks with asserts.

mysql_common.c
	mysql_send_custom_error: if called with dcb == NULL, return.

readconnroute.c
	Replaced malloc with calloc. Added functions rses_begin_router_action and rses_exit_router_action. If router client session is not closed, they take a lock and release it, respectively. Those functions are used for protecting all operations which modify the contents of router client session struct.

readwritesplit.c
	Identical changes than in readconnroute.c

skygw_debug.h
	Added check number and - macro for ROUTER_CLIENT_SES, and added COM_QUIT to STRPACKETTYPE.
2013-10-30 22:07:51 +02:00
vraatikka
5e6b0a3b1a Included log_manager in query classifier's makefile, replaced fprintf's with log manager commands. 2013-10-28 10:44:05 +02:00
vraatikka
86c64ab3f4 Merge 2013-10-25 11:59:08 +03:00
vraatikka
f32cfe8546 query_classifier.cc
resolve_query_type, traverse through the list of items of thd->free_list, identify functions and reason query type according to the function type. This phase can only increase the restrictiviness level of the query.

query_classifier.h
        Added new query type QUERY_TYPE_LOCAL_READ, for functions that can be executed in Maxscale. This type is the least restrict
ive query type. It is not used currently.

testmain.c
	Added a few test cases and fixed expected return values for query type tests.

readwritesplit.c
	polish

skygw_debug.h
	Added string macro for Item types.
2013-10-25 11:55:45 +03:00
Massimiliano Pinto
2cbe46b506 gwbuf_consume is protected by spinlock 2013-10-24 17:53:38 +02:00
vraatikka
241a0a6175 Used sizeof operator for calculating the length of a string. 2013-10-24 10:51:54 +03:00
vraatikka
ddab34fe72 mysql_libraray_init failed due to invalid datadir setting. Fixed this by setting the working directory/data as data directory. 2013-10-23 14:16:50 +03:00
vraatikka
d7550f40c0 Merge 2013-10-23 09:24:42 +03:00
vraatikka
da60fe701c Cleanup, added also a macro for printing dcb state. 2013-10-23 09:11:20 +03:00
Massimiliano Pinto
8e9b7fb26a Added new entry point in router: errorReply
The routine if called from backend will ido:

1 reply error messages to client closing or not the session
2 open a new backend connection

An action flag is passed to the routine.
2013-10-22 10:30:16 +02:00
Massimiliano Pinto
4a189696bd In mysql_backend.c:gw_read_backend_event
the delay queue is now consumed when backend_protocol->state == MYSQL_AUTH_FAILED.

This will avoid sending more times the custom error in the threaded configuration.
2013-10-21 16:28:07 +02:00
vraatikka
1ef015196b Another case where gw_write fails in EAGAIN/EWOULDBLOCK. 2013-10-16 22:30:59 +03:00
vraatikka
81b52c6256 If gw_write returns -1 with errno EAGAIN or EWOULDBLOCK it is not treated like an error. 2013-10-16 21:59:22 +03:00