643 Commits

Author SHA1 Message Date
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
vraatikka
44c7914f2b Increased size of following arrays to prevent memory overwrites: dcb_fake_write_errno, dcb_fake_write_ev, conn_open. Note that these are use in DEBUG build only. 2013-10-16 17:32:30 +03:00
vraatikka
a696e041e0 gateway.c
file_write_footer, added checks for the case of failed memory allocation. 

service.c
	serviceRestart, added check for return value of poll_add_dcb. In failure, service is not moved to SESSION_STATE_LISTENER state and listener counter is not increased.
2013-10-16 17:13:50 +03:00
Massimiliano Pinto
76af245eac Added the \0 byte to user and db in musql_session 2013-10-16 11:01:16 +02:00
vraatikka
94c37799b1 dcb.c
dcb_write earlier returned an error (== 0) if errno was not set and other conditions were satisfied. In practice, if write was done in write queue, queue pointer was not updated and dcb_write returned and error. Changed the error detection condition so that it requires errno being set, at least.

readwritesplit.c
	Clean up.
2013-10-16 08:29:22 +03:00
vraatikka
4db366290d Removed 'datadir' value from libmysqld's start-up parameters to make it start. 2013-10-15 22:18:59 +03:00
vraatikka
52644db8ce testmain.c
Removed embedded server startup parameter '--skip-innodb' and replaced TRUE, and FALSE with true and false, respectively.
gateway.c
	Removed embedded server startup parameter '--skip-innodb' because libmysqld inside MariaDB 5.5.33 + doesn't start with that paramter.
2013-10-15 18:18:09 +03:00
Massimiliano Pinto
b5da527555 myql_common.c:gw_send_change_user_to_backend checks func.write for 0 and 1
mysql_client.c:gw_MySQLWrite_client is simply return dcb_write(dcb, queue);
The return codes are not the same of the code replaced, but they are not checked in the caller routines.
2013-10-14 18:41:49 +02:00
Massimiliano Pinto
121cff7ffa Galera cluster status is Synced, all affected files are updated 2013-10-14 15:29:26 +02:00
vraatikka
66dbb8ec23 dcb.c
dcb_write, if write failed, gwbuf wasn't freed.
mysql_backend.c 
	gw_MySQLWrite_backend, if dcb wasn'r in POLLING state then write was skpiped but gwbuf wasn't freed.
mysql_client.c
	gw_MySQLWrite_client, disabled the use of dcb_write because it returns different values than the code it replaced. Also removed erroneous call of gwbuf_consume.
mysql_common.c
	mysql_send_custom_error, removed erroneous call of gwbuf_free.
2013-10-14 15:12:30 +03:00
vraatikka
0f2eeff243 gw_buffer was not freed. 2013-10-14 13:16:33 +03:00
vraatikka
42417797a9 freeSession, trace log write referenced to backend_dcb which may be freed. 2013-10-12 12:40:49 +03:00
Massimiliano Pinto
1f0e8d5c56 Fixed: use row[1] instead of row[0] in monitorDatabase() 2013-10-11 09:02:49 +02:00
vraatikka
cd507f1461 log_manager.cc
blockbuf_get_writepos, when all existing buffers in blockbuf list are full, a new block buffer is created and added to the list. Adding to the list is done with mutex on hold. Mutex shouldn't be freed before the next iteration in while loop, which expects that bblist mutex is on hold. At the end of the function, removed an unnecessary debug assertion.

testlog.c
	Enabled more intensive write test. Replaced TRUE and FALSE with true, false, respectively.

skygw_utils.cc
	simple_mutex_unlock, added debug assertion to ensure that pthread mutex's user counter is always at least 0 (it goes negative in double free).
2013-10-10 16:46:51 +03:00
Massimiliano Pinto
e1c7887726 gw_MySQLWrite_client is now simply a call to dcb_write 2013-10-07 16:34:15 +02:00
vraatikka
655a6537b2 mysql_client_server_protocol.h :
changed gw_receive_backend_auth declaration to return int instead of boolean.
mysql_backend.c:
	gw_read_backend_event calls gw_receive_backend_auth which either fails (== -1), succeeds with nothing to read (== 0) or succeeds (== 1). For each case there is handling. If dcb_read succeeds without read bytes, return asap.
mysql_client.c:
	gw_error_client_event, gw_client_close, gw_client_hangup_event : all close client dcb but now they also close backend dcb.
mysql_common.c:
	gw_receive_backend_auth, return -1, 0, or 1 if read from backend failed, was empty, or succeed, respectively.:
2013-10-07 14:00:44 +03:00
vraatikka
80b67d1083 log_manager.cc:
State update for filewriter was missing and that caused Maxscale to fail if opening of any log file failed.
dcb.c:
	Added EAGAIN and EWOULDBLOCK handling to dcb_read. If dcb_close is called for freshly created dcb, dcb is only freed.
gateway.c:
	Added file_write_footer and write_footer of which the latter is called at exit time. It simply draws a line to screen.
gw_utils.c:
	Some macros for helping comparison between gw_read_gwbuff and dcb_read, which overlap.
poll.c:
	Some macros to help enable/disable mutexing in poll_waitevents
service.c:
	Check return value of listen and session_alloc and behave accordingly.

mysql_client.c:
	If ioctl returned successfully with b==0 it earlier caused closing the client and backend dcbs. Since that doesn't reliably indicate that client has closed socket on its side, Maxscale doesn't close its sockets either.
mysql_common.c:
	In gw_receive_backend_auth, if dcb_read returns n==0, it is not considered as an error anymore. The implemented behavior is not yet complete and correct. Result should be successful but the protocol state shouldn't change to MYSQL_IDLE before backend return is received.
	In gw_send_authentication_to_backend protocol state was always set to MYSQL_AUTH_RECV even if gw_rwite had failed. Now, return value is read and state is set in caller's context basen on the return value.
skygw_utils.cc:
	Removed ss_dassert from skyge_file_init because it prevented from returning meaningful error meassage to the client.:
2013-10-06 22:31:32 +03:00