4320 Commits

Author SHA1 Message Date
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
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
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
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
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
vraatikka
849a366e95 log_manager.cc :
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.
2013-10-04 12:06:44 +03:00
vraatikka
440a4c7278 Missing argument in log command caused maxscale to fail. 2013-09-30 12:36:08 +03:00
vraatikka
f74e7b6f79 Cannot compile. 2013-09-30 11:19:03 +03:00
vraatikka
701830f0ab Logging related (mostly) sanity checks and fixes.
- 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.
2013-09-30 11:14:36 +03:00
Massimiliano Pinto
c48dd6028f Modified dcb_read return: n = 0 means 0 bytes read without errors
if (rc < 0) is now used testing dcb_read() return, instead of if (rc <= 0)
2013-09-27 19:24:23 +02:00
vraatikka
1120ae9b2c Zombie processing had an risk of getting into an infinite loop. 2013-09-27 11:20:28 +03:00
Mark Riddoch
ee7b799bf1 Bug 160 - fixed memory leaks with telnetd and debug CLI 2013-09-26 17:38:35 +02:00
Mark Riddoch
1e83308cd1 Bug 133 - cleanup data<pid> directory on SIGINT 2013-09-26 16:33:16 +02:00
Mark Riddoch
ab731274fd Bug 218 - add error message if MAXSCALE_HOME does not exist 2013-09-26 13:46:04 +02:00
Mark Riddoch
c26bd04ea7 Addition of messages to standard error if MaxScale refuses to start for some reason 2013-09-26 12:21:45 +02:00
Mark Riddoch
c1c7a3fb02 Additional check for service starts 2013-09-26 10:38:31 +02:00
Mark Riddoch
fe7d0477ba Improved configuration object checking 2013-09-26 10:37:55 +02:00
Mark Riddoch
947fc3509b Make configuration file reading more robust 2013-09-25 17:50:12 +02:00
Mark Riddoch
5d22884a9b Fixed NULL pointer issue 2013-09-25 16:36:54 +01:00
Mark Riddoch
ed7c32fb88 Bug 124 - config file validation 2013-09-25 16:25:12 +01:00
Massimiliano Pinto
44d424adb4 setipaddress uses getaddrinfo
for listening socket different flags are used, detection is based on 0.0.0.0

This will change when supporting multiple binding addresses.
2013-09-25 11:08:39 +02:00
vraatikka
3b647e47ab When there is no load but there are zombies to be cleaned up, it used to take at least nthreads*timeout time to get socket closed. Now in this case, once the timeout exceeds for the first time, all threads are allowed to call dcb_process_zombies without having to wait the timeout period until there are no zombies anymore. 2013-09-25 09:12:18 +03:00
vraatikka
09cc20b7be Improved behavior of debug cli API command 'fail accept'. It takes now _two_ arguments, Syntax:
fail accept <errno> <repeat count>

Changed fail_next_accept from boolean to decreasing counter.
2013-09-24 15:48:59 +03:00
vraatikka
e637ea3844 Merge 2013-09-24 15:16:14 +03:00
vraatikka
3e1322034d Added logging and som checks. 2013-09-24 15:13:25 +03:00
vraatikka
a7c3cd5f30 Related to bug #217, added command 'fail accept <errno>' to debug client's commands.
Reproduce #217 by connecting with telnet to debug client interface and execute command:

fail accept 23

and try to execute read query, for example, with

mysql -h 127.0.0.1 -P 4008 -u maxuser -pmaxpwd -e 'select current_user(), @@server_id'
2013-09-24 15:04:12 +03:00
Massimiliano Pinto
d248ecb180 Added missing parameter in log write, poll_remove_dcb 2013-09-20 18:36:31 +02:00
Massimiliano Pinto
eec0b74191 dcb_printf(pdcb, "\tQueued write data: %d\n", gwbuf_length(dcb->writeq)); is now protected by if (dcb->writeq)
No more segfaults in dprintAllDCBs
2013-09-20 17:53:15 +02:00
vraatikka
74aa3638f9 dcb.c
dcb_final_free: Router session is not closed anymore when dcb is closed. Router session is shared among all dcbs and is closed and freed with session.
	dcb_connect: dcb's state must be switched fro DCB_STATE_ALLOC to DCB_STATE_DISCONNECTED before dcb_final_free can be called for it.
	dcb_close: poll_remove_dcb encapsulates dcb's state transition in the same way as poll_add_dcb. Removed state modification from dcb_close. Read return value of poll_remove_dcb and log accordingly.
	dcb_set state: remove dassert if dcb_set_state_nomutex returned false. False can be returned indicating that intented change didn't occur but the end state, for example, may be acceptable. Failures in state transitions are asserted in dcb_Set_state_nomutex.

poll.c
	poll_add_dcb: dcb state is now set here to either DCB_STATE_LISTENING or to DCB_STATE_POLLING according to dcb's role. Failures in state setting and in epoll_ctl are detected, logged and handled.
	poll_remove_dcb: Failures in state setting and epoll_ctl are detected, logged, and handled.

mysql_client_server_protocol.h 
	Removed macros MYSQL_FAILED_AUTHENTICATION & MYSQL_SUCCESFUL_AUTHENTICATION as they were not necessary and used with constant values 0 and 1 depending on the case.
	Renamed variable 'conn' to 'protocol' in cases where it meant protocol.

mysql_backend.c
	gw_read_backend_event: In case when there was nothing to read or read failed, backend dcb is closed because situation is assumed to be such that backend server closed its side of the socket. Removed macros MYSQL_FAILED/SUCCESFUL_AUTHENTICATION
	gw_create_backend_connection: Assigned protocol with fd which is connected to backend.
	backend_write_delayqueue: In case where dcb_write fails to write anything, close backend dcb to avoid it getting hanging.

mysql_client.c
	gw_read_client_event: Read return value of routeQuery and if it isn't == 1, call mysql_send_custom_error with client dcb and set client's protocol state to MYSQL_IDLE instead of MYSQL_ROUTING.
	gw_MySQLAccept: Static reply counter was erroneously used as a criteria for jumping to return point where return value was constantly 'success' (=0). Replaced static reply counter with private. Fixed return value in different cases.

mysql_common.c
	gw_receive_backend_auth: Changed to return boolean values indicating of success or failue. Used integers which were assigned to macroed values on the caller side. Added length check before accessing buffer. 

readconnroute.c
	Cut too long lines and removed statements with side effects.

skygw_debug.h
	Added macro STRPROTOCOLSTATE(s) to produce string representation of a given protocol state.
2013-09-20 14:32:28 +03:00
Mark Riddoch
c7b052aab3 Addition of CheckSessions debug entry point 2013-09-18 19:06:32 +02:00
vraatikka
4321861ed8 dcb_read : removed redundant or dead code.
dcb_write: if fail backendfd | clientfd is used, now listener operations don't cause failure.
2013-09-17 21:54:38 +03:00
vraatikka
4cf5b3293f Added check routine for gw_buffer. Only effective in debug build. 2013-09-17 15:10:16 +03:00
vraatikka
5fba84a4ee poll.c : forgot from previous commit
debugcmd.c : cannot compile.
2013-09-17 00:16:06 +03:00
vraatikka
8bf73ea154 Replaced write system function with wrapper gw_write. It allows for generating failures by using telnet commands, fail backendfd, fail clientfd, which are available in debug build only. 2013-09-17 00:07:56 +03:00
vraatikka
4815856017 session.c : session_alloc
If backend connection can't be created, backend_dcb is not create, router client session is not created and what already is created in session_alloc, is freed.
mysql_client.c : gw_read_client_event
If session creation failed, then - instead of sending ok to client, "failed to create new session" is sent and client dcb is closed.
 : gw_MySQLAccept
removed loop where accept was called again and again. With single thread looping forever is not possible because there's no one to free previously allocated resources.
If accept fails ten times in a row, then return without new client dcb.
2013-09-13 23:55:26 +03:00
vraatikka
710fc5cfa6 dcb.c
: dcb_alloc switched malloc to calloc, dcb->fd is initialized to -1. 
: dcb_process_zombies return value of close(fd) is checked. Closed fds are stored to conn_open array. 
: dcb_connect assigns new fd only if backend connection succeeds. Dcb is added to poll set in the same way, only if connect succeed.
gateway.c : conn_open array is initialized in main. For each created socket, a true is set to corresponding slot. Max. number of slots is 1024.
mysql_client_server_protocol.h : gw_do_connect_to declaration 
mysql_backend.c : gw_create_backend_connection returns rv >= 0 and a protocol which is assigned to backend_dcb. In error, -1 is returned and fd is not set.
mysql_client.c : conn_open array is kept up-to-date and protocol pointer is assigned also to dcb outside mysql_protocol_init.
mysql_common.c : gw_do_connect_to_backend 3rd argument is pointer to fd, not protocol. dcb is added to poll set later in dcb_connect.
skygw_debug.h : define conn_open[1024] array where open connections can be marked in debug build.
2013-09-13 22:10:40 +03:00
vraatikka
ae12ef8f34 Added call to close(fp_tmp) 2013-09-12 23:13:22 +03:00
vraatikka
d7e793a411 poll.c:Returned checks for zombie
mysql_backend.c:don't write to session->client if session->client is NULL
mysql_common.c:assert if called with dcb==NULL
2013-09-12 22:34:49 +03:00
vraatikka
bbc9dcc9a3 poll.c: added maxscale thread id to log
session.c: Replaced free(session->router_sesision) with call to freeSession callback
users.c: Removed reference to uninitialized variable.
router.h: Added freeSession callback to function block.
mysql_backend.c: try to ensure that client dcb is still listening in epoll_wait when writing reply to it.
mysql_common.c: assert debug build is mysql_protocol_init is called with dcb == NULL
readconnroute.c, readwritesplit.c, debugcli.c and testroute.c : Added freeSession to function block and an inmplementation of it.
2013-09-12 22:17:11 +03:00
vraatikka
c4d01cdaed Backend sets session's client pointer to NULL before session_free is called for session. 2013-09-12 22:10:43 +03:00
vraatikka
3841f95531 In error cases, called close(fp). 2013-09-12 22:00:08 +03:00
vraatikka
33fc1737d5 One uninitialized read in dcb_set_state_nomutex. One read of freed memory in dcb_process_zombies.
The former may have affected on the program behavior.
The latter left in many cases fds open and dcbs not freed for real.
2013-09-12 10:00:55 +03:00
Massimiliano Pinto
092795d95b in dcb_final_free the dcb->session NULL check protects the access to dcb->session->router_session and all the code below 2013-09-10 15:50:47 +02:00
Mark Riddoch
22e9fb9a4d Bug 194: Crash starting listener if protocol module load fails 2013-09-09 16:33:04 +02:00
vraatikka
46464d7723 Check if router_session pointer has value in session structure before calling free for it. 2013-09-09 14:36:45 +03:00