167 Commits

Author SHA1 Message Date
VilhoRaatikka
0ea4dd63a9 Merge branch 'develop' of https://github.com/mariadb-corporation/MaxScale into develop 2014-11-11 14:25:49 +02:00
VilhoRaatikka
128d5e3f48 Addition to previous fix 2014-11-11 14:25:34 +02:00
VilhoRaatikka
061fa62d29 Fixes to Coverity issues 77197 (mysql_common.c, dcb.c, mysql_client.c, skygw_debug.h), 72654 (poll.c), 72756 (mysql_backend.c), 72744 (mysql_backend.c), 77197 (mysql_common.c), 72746 (mysql_common.c), 72676 (mysql_common.c), 72705 (readwritesplit.c), 72697 (readwritesplit.c), 72652 (skygw_debug.h) 2014-11-11 14:10:06 +02:00
MassimilianoPinto
39b04682ea COM_CHANGE_USER honours charset change
COM_CHANGE_USER honours charset change
2014-11-10 17:06:14 +01:00
MassimilianoPinto
49d28bc1f3 MySQL connect: charset flag is stored
MySQL connect: charset flag is stored and passed to backend
2014-11-10 16:09:55 +01:00
VilhoRaatikka
3b07449daa Fix to bug #614, http://bugs.skysql.com/show_bug.cgi?id=614
Added protected state check to mysql_client.c, fixed locking in session.c
2014-11-10 14:07:51 +02:00
VilhoRaatikka
44771dbc51 readwritesplit.c:handleError is meant to handle backend errors. Removed one call from mysql_client.c and only send error message to client instead.
Added checks to debug build to ensure that handleError is called before backend DCB is closed.
2014-11-07 17:55:05 +02:00
VilhoRaatikka
4b98c472a8 Fixed a comment 2014-11-06 16:12:01 +02:00
VilhoRaatikka
9ccbab1899 poll.c:dcb_close Don't call poll_remove_dcb anymore if DCB has already been removed from poll set.
mysql_backend.c, mysql_client.c free error message GWBUF after calling handleError
readconnroute.c:handleError send error message to client before returning.
readwritesplit.c:handleError don't free error message buffer anymore since the caller of handleError frees it.
2014-11-01 20:00:59 +02:00
VilhoRaatikka
3f375e680a Fix to #590, http://bugs.mariadb.com/show_bug.cgi?id=590
gw_change_user returned error code in cases where authentication failed. That is not right behavior in that context. gw_change_user succeeds to route query and should return succees to router's routeQuery. Possible error is handled by creating error message and by feeding it to client DCB's event queue.
2014-10-31 20:09:43 +02:00
VilhoRaatikka
00fded016b Fixes to Coverity tasks : 73267, 72686, 72672
Cleaned up warnings, and added checks to malloc return values and error log writes in case of failures.
2014-10-31 15:25:59 +02:00
VilhoRaatikka
60536f622e Fix to bug #590, http://bugs.mariadb.com/show_bug.cgi?id=590
Added function poll.c:poll_add_epollin_event_to_dcb which adds given event and related GWBUF to given DCB. The DCB is then added to event queue list so that its even becomes executed as soon as any of the threads start to process events next time.
The problem solved is case where COM_CHANGE_USER failed due to authentication failure. An error should be sent to the client but it was sent once per failed backend authentication instead of just once.
Thread which failed in authentication bypassed router and thus replies weren't filtered out. Solution adds an event and a GWBUF including error message to DCB and the DCB is then added to event queue. Thus the error message appeares like it was an incoming event and becomes processed properly.

An addition was made to mysql_backend.c:gw_read_backend_event so that self-generated event can be processed. Even if socket read doesn't manage to read anything, function proceeds if there is enough data in DCB's readqueue.

Fix ti bug #602, http://bugs.mariadb.com/show_bug.cgi?id=602
Added function sescmd_response_complete which checks if the read data completes session command response packet(s). Function is called only if there's a sessoin command being executed.
2014-10-30 16:54:27 +02:00
MassimilianoPinto
970511a275 Update for message errors in DB authentication
Update for message errors in DB authentication
2014-10-24 12:20:50 +02:00
MassimilianoPinto
35996a40cb Reply messages for failed db authentication
Reply messages for failed db authentication
2014-10-23 19:36:25 +02:00
MassimilianoPinto
3cdb1dc2ae Added db names as hashtable
Added db names as hashtable
2014-10-20 19:26:13 +02:00
MassimilianoPinto
220e1d9505 local authentication with db name for change_user
local authentication with db name for change_user
2014-10-20 10:26:00 +02:00
MassimilianoPinto
b8f590e67f Added database errmsg to change_user
Added database errmsg to change_user
2014-10-17 19:02:19 +02:00
MassimilianoPinto
273a445045 Code cleanup
Code cleanup
2014-10-13 10:47:27 +02:00
MassimilianoPinto
ee54310a73 Implementation of db auth
Implementation of db auth
2014-10-13 09:50:55 +02:00
VilhoRaatikka
29e53e150a Fix to bug # 565, http://bugs.mariadb.com/show_bug.cgi?id=565
Client flags are now copied to each backend and used in their connections.

log_manager.cc: fixed string allocation where one byte was missing.
mysql_client.c: fixed string allocation where one byte was missing.
2014-10-08 22:27:28 +03:00
VilhoRaatikka
aca8596efa mysql_client.c:gw_client_close didn't close client session in cases where session->state == SESSION_STATE_STOPPING. That is a bug and lead to situation where session wasn't closed at all.
Also changed 'authorization failed' to 'access denied'
mysql_common.c: fixed memory leak in gw_receive_backend_auth, and replaced error code '2800' with '28000'.
readconnroute.c:handleError didn't set *succp pointer so uninitialized value was used in caller's context.
makefile.inc: added -lm to linker flags
mysql_backend.c: added a few comments
2014-10-06 11:46:12 +03:00
Markus Makela
c4ca1ddb13 Updated non-source files with new company name. 2014-10-01 15:21:47 +03:00
Markus Makela
b0683d9b4d Updated the licensing year from 2013 to 2013-2014 2014-10-01 14:37:12 +03:00
Markus Makela
f4e591e382 Changed 'SkySQL Gateway' to 'MariaDB Corporation MaxScale' 2014-09-30 13:15:03 +03:00
Markus Makela
c344231f80 Renamed all occurences of SkySQL to MariaDB Corporation 2014-09-30 13:02:10 +03:00
VilhoRaatikka
5a28a73fcb gwbuf_append's return value wasn't read in gw_read_client_event 2014-09-12 18:10:42 +03:00
MassimilianoPinto
8b5b4a17fe Merge from Z3
Merge from Z3
2014-09-11 12:51:16 +02:00
MassimilianoPinto
7245d1baa1 blr branch merge
blr branch merge
2014-09-11 12:20:42 +02:00
Mark Riddoch
f9aece5113 Remove queuing that is no longer required
Fixed bug in mysql_backend.c that lost up to 4 bytes of data in rare
circumstances.
2014-09-10 15:51:53 +01:00
VilhoRaatikka
677a44f497 Merge from release-1.0beta to Z2 2014-08-15 18:00:39 +03:00
VilhoRaatikka
2393ac57e9 mysql_common.c:protocol_add_srv_command didn't check that protocol status was MYSQL_PROTOCOL_ACTIVE and wrote to freed memory. 2014-08-14 17:23:46 +03:00
VilhoRaatikka
77e5525436 mysql_client.c:gw_error_client_event & gw_client_hangup_event: added session state check, if session is already closing, don't start redundant call to dcb_close.
mysql_common.c:mysql_protocol_done: added protocol state check. Used not to check it which caused double free of allocated memory.
2014-08-14 15:15:22 +03:00
VilhoRaatikka
d3a79ce7c4 Partial fix to #463, http://bugs.skysql.com/show_bug.cgi?id=463
log_manager.cc: fixed block buffer overflow. Queries are logged to trace log and long queries exceed the bufsize in length. Those were written beyond allocated memory areas.
mysql_client_server_protocol.h: added mysql_protocol_state_t to indicate whether MySQL protocol object is allocated, usable or freed. Freed means that memory allocations made by the protocol are freed. That is, command history etc.
mysql_backend.c: gw_backend_hangup and gw_error_backend_event used to call error handling function although session was already closing. Added check for session state.
mysql_client.c: route_by_statement lost some packets in case where query was sent in multiple packets.
mysql_common.c: gw_MySQL_get_next_packet failed in packet handling with route_by_statement. When multi-packet query was merged into one, packet type wasn't copied.
	protocol_archive_srv_command and mysql_protocol_done didn't have proper locking in place which lead to occasional crashes.
2014-08-14 13:05:05 +03:00
VilhoRaatikka
86a4c3ba90 Fix to #472, http://bugs.skysql.com/show_bug.cgi?id=472
Fix to #473, http://bugs.skysql.com/show_bug.cgi?id=473

Several memory issues. Read the code.
In general one-off hint is only added to gwbuf and freed in gwbuf_free. Stacked hint is copied to stack and to gwbuf. gwbuf is freed after routing but stacked hint is freed either in stop or when session is closed. All this applies to named hint as well except that in addition, it has one more copy in named hint struct which is emptied when session is closed.
2014-08-08 01:28:07 +03:00
VilhoRaatikka
cf38dad43a Merge branch 'Z2' of https://github.com/skysql/MaxScale into Z2
Conflicts:
	server/core/modutil.c
2014-08-05 18:26:55 +03:00
VilhoRaatikka
08b99c121e Bug #468, http://bugs.skysql.com/show_bug.cgi?id=468, Query classifier accessed freed thread context. If parsing fails thd doesn't need to be freed because it holds correct information about command type.
session.c:session_setup_filters : fixed memory leak
hintparser.c: added token_free for HINT_TOKENs and fixed a few memory leaks.
mysql_client_server_protocol.h: added mysql_protocol_done which frees memory blocks pointed to by protocol members. Those can't be freed in dcb.c because dcb.c doesn't know about protocol's members.
mysql_backend.c:gw_backend_close: fixed memory leak
mysql_client.c: gw_client_close: fixed memory leak
mysql_common.c: added implementation of mysql_protocol_done
        :protocol_archive_srv_command: tried to fix memory leak. Some memory is still leaking according to valgrind. Removed use of uninitialized local variable len.
readwritesplit.c: Fix to bug #469, http://bugs.skysql.com/show_bug.cgi?id=469,  rwsplit counts every connection twice in master - counnection counts leak
	execute_sescmd_in_backend: fixed a memory leak - visible only in DEBUG=Y build.
readwritesplit/test/makefile: added target for hints tests
2014-08-05 18:14:06 +03:00
VilhoRaatikka
7558abb6fa Bug #468, http://bugs.skysql.com/show_bug.cgi?id=468, Query classifier accessed freed thread context. If parsing fails thd doesn't need to be freed because it holds correct information about command type.
session.c:session_setup_filters : fixed memory leak
hintparser.c: added token_free for HINT_TOKENs and fixed a few memory leaks.
mysql_client_server_protocol.h: added mysql_protocol_done which frees memory blocks pointed to by protocol members. Those can't be freed in dcb.c because dcb.c doesn't know about protocol's members.
mysql_backend.c:gw_backend_close: fixed memory leak
mysql_client.c: gw_client_close: fixed memory leak
mysql_common.c: added implementation of mysql_protocol_done
    :protocol_archive_srv_command: tried to fix memory leak. Some memory is still leaking according to valgrind. Removed use of uninitialized local variable len.
readwritesplit.c:execute_sescmd_in_backend: fixed a memory leak - visible only in DEBUG=Y build.
2014-08-05 10:42:13 +03:00
VilhoRaatikka
6b3c7041e3 Bug #468, http://bugs.skysql.com/show_bug.cgi?id=468, Query classifier accessed freed thread context. If parsing fails thd doesn't need to be freed because it holds correct information about command type.
session.c:session_setup_filters : fixed memory leak
hintparser.c: added token_free for HINT_TOKENs and fixed a few memory leaks.
mysql_client_server_protocol.h: added mysql_protocol_done which frees memory blocks pointed to by protocol members. Those can't be freed in dcb.c because dcb.c doesn't know about protocol's members.
mysql_backend.c:gw_backend_close: fixed memory leak
mysql_client.c: gw_client_close: fixed memory leak
mysql_common.c: added implementation of mysql_protocol_done
	:protocol_archive_srv_command: tried to fix memory leak. Some memory is still leaking according to valgrind. Removed use of uninitialized local variable len.
readwritesplit.c:execute_sescmd_in_backend: fixed a memory leak - visible only in DEBUG=Y build.
2014-08-05 09:31:10 +03:00
VilhoRaatikka
d83a4673d7 Bug 462, http://bugs.skysql.com/show_bug.cgi?id=462, testall target fails in server/test to invalid MAXSCALE_HOME path specification.
Fixed path specification in server/test/makefile.

Added comments to mysql_backend.c
2014-07-29 12:11:00 +03:00
VilhoRaatikka
5357f6e2f2 Fixes symtoms described in http://bugs.skysql.com/show_bug.cgi?id=454
Added DCB state check to backend error evend handler. If state isn't DCB_STATE_POLLING anymore, socket is closed with purpose or error occurred but it has already been handled.
Client doesn't hang anymore at least with the documented method.
2014-07-04 14:26:55 +03:00
Mark Riddoch
4af2e58c86 Update plugin status to BETA 2014-07-04 09:23:40 +01:00
VilhoRaatikka
39679447c9 Bugzilla #455, MaxScale crashed due missing buffer type information in multi-buffer responses. 2014-07-03 19:20:45 +03:00
VilhoRaatikka
e944ae2e70 http://bugs.skysql.com/show_bug.cgi?id=453
Fixed bug in session command resul handling. In case where backend sent error message the session command cursor wasn't updated properly.

Added check to bref_clear_state, if bref's waiter counter would go negative, decrement to global operation counter is skipped.
2014-07-03 00:43:30 +03:00
VilhoRaatikka
3e3c1af211 Clean up 2014-06-30 13:43:25 +03:00
VilhoRaatikka
fcf67716fd Added mechanism for choosing slave for a query based on the current load in all connected slaves. Counting operations is not correctly done here. Reading values and choosing accordingly is done.
Fixed several things in session command reply processing.
2014-06-29 22:21:30 +03:00
VilhoRaatikka
1d1da398d4 Merge branch 'develop' into MAX-99
Conflicts:
	server/modules/routing/readwritesplit/readwritesplit.c
2014-06-25 17:50:29 +03:00
VilhoRaatikka
7ff14e23a5 Support for prepared statement, namely support for following comands : COM_STMT_PREPARE, COM_STMT_EXECUTE, COM_STMT_SEND_LONG_DATA, COM_STMT_RESET, COM_STMT_CLOSE, SQLCOM_PREPARE, SQLCOM_EXECUTE, SQLCOM_DEALLOCATE_PREPARE (DEALLOCATE/DROP PREPARE stmt).
All prepare commands are executed in every backend server currently connected.

All executes are routed to master. If stmt type was recorded in prepare phase in rwsplit router, read-only stmts could be routed to slaves.

COM_STMT_PREPARE gets arbitrary number of response packets from backend database. Since statements are prepared in every backend server and only one multi-packet response can be replied to client, redundant multi-packet responses are discarded. This is done in router. Mechanisms from session command handling are utilized with little changes: router must identify when response consists of multiple packets so that it knows to calculate the number of packets in response and that it is able to discard correct number of packets.

Information to the reply-handling router is provided by backend protocol, which includes a ordered list of commands of commands sent to protocol-owning backend server. A command is stored to protocol struct in mysql_backend.c:gw_MySQLWrite_backend if the statement buffer's type has GWBUF_TYPE_SINGLE_STMT set in mysql_client.c:route_by_statement. GWBUF_TYPE_SINGLE_STATEMENT indicates that there is single statement in the buffer, as opposite to Read Connection router, which accepts streaming input from client.
2014-06-25 17:15:46 +03:00
Mark Riddoch
4d257897d3 Merge branch 'develop' of github.com:skysql/MaxScale into develop
Conflicts:
	server/core/session.c
	server/modules/protocol/mysql_backend.c
	server/modules/routing/readwritesplit/readwritesplit.c

Resolved.

Addition of user in topfilter report and general tidyup
2014-06-18 17:45:57 +01:00
VilhoRaatikka
e7fa80a591 Code clean up 2014-06-17 16:15:19 +03:00
VilhoRaatikka
5bcae64538 When protocol closes DCB it calls dcb_close instead of dcb->func.close. dcb_close then calls dcb->func.close. This is now changed to all protocols and routers.
Rwsplit handles ERRACT_NEW_CONNECTION by clearing backend reference, removing callbacks and associating backend reference with new backend server. If it succeeds and the router session can continue, handleError returns true. Otherwise false. When ever false is returned it means that session must be closed.

Rwsplit now tolerates backend failures in a way that it searches new backends when monitor, backend, or client operation fails due to backend failure.
2014-06-15 23:44:07 +03:00