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
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
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.:
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.: