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.:
tuned error printing and log writing output format
dcb.c :
dcb_connect, check return value of poll_add_dcb and behave accordingly.
dcb_write, in case of SIFPIPE, only write to trace log.
dcb_close, dassert with incorrect dcb states.
gateway.c :
added file_write_header to print header similar than in logs to stderr.
main, add signal handler for SIGPIPE
poll.c :
poll_remove_dcb, don't fail if dcb is in NOPOLLING or in ZOMBIE states.
poll_waitevents, write EPOLLHUPs to trace log, don't even attempt to write to closed socket.
readconnection.h :
shortened comment.
readwritesplit.h :
replaced generic names with more specific ones.
httpd.c :
Check listen return value and behave accordingly.
mysql_backend.c :
Tiny clean up.
mysql_client.c :
gw_MySQLListener, Check listen return value and behave accordingly.
mysql_common.c :
Shortened a header.
telnetd.c :
telnetd_listen, check listen return value and behave accordingly.
readconnroute.c :
Tuned log writing format.
readwritesplit.c :
Added function search_backend_servers, which chooses suitable backend and master server among those known by Maxscale. Fixed clean-up routines. Not ready yet but works somehow.
testroute.c :
Cleanup.
skygw_utils.cc :
Log writing clean up.
- Checked argument types and counts
- Removed trailing line feeds
- Removed thread ids from error logs (they are used in trace / debug log
- Added some state information to dcbs
- Added prefix 'Error' or 'Fatal' to error logs.
- Switches all error logs to use flushing log write.