131 Commits

Author SHA1 Message Date
Martin Brampton
0cba9b797f Changes to deal with failed session creation by keeping the new session in existence until all related DCBs have closed; minor changes in response to reviews. 2015-09-17 08:15:32 +01:00
counterpoint
cfeaf7d6e9 Merge remote-tracking branch 'origin/develop' into MXS-329
Conflicts:
	server/core/session.c
2015-09-10 13:07:27 +01:00
Johan Wikman
160bbb70ee MXS-251: strerror
Replaces all calls to strerror with calls to strerror_r. The former
is non-thread safe while the latter is.
2015-09-05 15:52:13 +03:00
counterpoint
a711b25fec Improve user name setting in DCB for persistent connections and to fix bug; change name of session_alloc_dummy to session_set_dummy to be more informative. 2015-08-28 18:20:32 +01:00
counterpoint
9c5f622481 Additional spinlock in random_jkiss. Initial attempt at implementing dummy sessions to provide total consistency - used in mysql_client in relation to authentication - a single static dummy session is used and linked from the client dcb when authentication is not yet complete. 2015-08-28 15:30:06 +01:00
counterpoint
65c42e2d80 Move removal of closing DCB from poll list to the kill zombies processing, rather than immediately on close; modify persistent connections to obtain candidates for the pool from the kill zombies processing to be sure that they really are finished all previous processing. 2015-08-24 16:19:25 +01:00
counterpoint
37ac158791 Changes to try to eliminate setting dcb->session to NULL with risk of crashing system. 2015-08-24 12:12:43 +01:00
Martin Brampton
6b2d90fc50 Add check so DCB can't be added to poll list without a linked session; small safety improvement in session; tidying. 2015-08-23 09:34:26 +01:00
Markus Makela
98ab399e6e Changed sprintf calls to snprintf calls and fixed compiler warnings. 2015-08-18 10:50:48 +03:00
Markus Makela
a6ae1cbc22 Fixed session timeouts using func.hangup instead of dcb_close. 2015-08-03 08:34:25 +03:00
Markus Makela
1b3af7d61f Fixes to Coverity defects. 2015-04-16 19:41:49 +03:00
Markus Makela
de88ae790d Fix to MXS-80: https://mariadb.atlassian.net/browse/MXS-80
Fixed a possible null pointer dereference and schemarouter client sessions not being closed properly when connecting with an empty database.
2015-04-01 11:18:11 +03:00
Markus Makela
5fb9353b47 Added session idle time and user name the client is connecting with to the dprintSession and dprintAllSessions functions. Also changed last_read from time_t to unsigned long to match the hkheartbeat. 2015-03-13 08:49:34 +02:00
Markus Makela
1b0fd4576a Merge branch 'maxinfo' into develop
Conflicts:
	server/core/service.c
	server/core/session.c
	server/include/session.h
2015-03-04 11:33:00 +02:00
Markus Makela
c47d2f3791 Added session timeouts.
The parameter 'connection_timeout' for services takes a value as seconds.
All sessions that have been idle for longer than this will be disconnected.
2015-02-20 22:16:43 +02:00
Mark Riddoch
2f218cba3a Addition of maxinfo commands
show sessions
	show clients
	show listeners
	show services
	show servers
2015-02-19 12:55:39 +00:00
Markus Makela
ce58157901 Added more debugging output.
tee.c: Added details about the freeing of orphaned sessions.
session.: Added missing cases of session state into the session_state function in debug builds.
2015-01-01 13:03:03 +02:00
VilhoRaatikka
6b68136377 Fix to bugs #664 and #665
http://bugs.skysql.com/show_bug.cgi?id=664
http://bugs.skysql.com/show_bug.cgi?id=665

Cloned session was freeing the shared 'data' dcb->data/session->data. Now only session_free for the non-clone session is allowed to free the data.
2014-12-30 13:35:59 +02:00
VilhoRaatikka
77bd279a01 Fix to prevent double free of dcb->data/session->data. If authentication fails, call free(dcb->data) only when DCB in question is *not* cloned. 2014-12-30 12:28:36 +02:00
VilhoRaatikka
635fcf708f Fix to bugs #665, and #664. Potentially to #649.
http://bugs.skysql.com/show_bug.cgi?id=665
http://bugs.skysql.com/show_bug.cgi?id=664
http://bugs.skysql.com/show_bug.cgi?id=649

dcb.c:dcb_final_free: (665):set dcb->session->client pointer to NULL so that it won't be read anymore and other threads won't try to close it.
	dcb_final_free:(664):don't free dcb->data, it is either freed in session_alloc if session creation fails or in session_free only.
session.c:if session creation fails, free dcb->data and remove links between client DCB and session.
mysql_backend.c:(665):gw_backend_close:check that session->client isn't NULL and that client DCB's state is still polling before calling dcb_close for it.
mysql_client.c:gw_mysql_do_authentication:if anything fails, and session_alloc won't be called, free dcb->data.
mysql_common.c:gw_send_authentication_to_backend:if session is already closing then return with error.
2014-12-29 20:19:01 +02:00
VilhoRaatikka
f0d8ed0cf2 Fix to #657, http://bugs.mariadb.com/show_bug.cgi?id=657
session.c:session_free:if session is child of another service (tee in this case), it is the parent which releases child's allocated memory back to the system. This now also includes the child router session.
dcb.h: Added DCB_IS_CLONE macro
tee.c:freeSession:if parent session triggered closing of tee, then child session may not be closed yet. In that case free the child session first and only then free child router session and release child session's memory back to system.
tee.c:routeQuery: only route if child session is ready for routing. Log if session is not ready for routing and set tee session inactive
mysql_client.c:gw_client_close:if DCB is cloned one don't close the protocol because they it is shared with the original DCB.
2014-12-23 00:26:57 +02:00
VilhoRaatikka
6b6ac2f95f Partial fix to bug #657, http://bugs.mariadb.com/show_bug.cgi?id=657
dcb.c:dcb_clone: set same close function than in the original DCB so that routing session will become closed when client DCB is closed.
session.h:introduce a new state which indicates that SESSION structure can be freed next, SESSION_STATE_TO_BE_FREED. State is needed to separate the state before and after memory free. Memory is freed in different situation depending on whether the session is parent or child session. Child sessions are freed in their parent.
Also introduce a new member in SESSION struct, ses_is_child, to indicate whether SESSION has a parent session which is responsible for releasing the memory of it.

session.c:session_unlink_dcb:when last session reference is removed set SESSION->state=SESSION_STATE_TO_BE_FREED
session.c:session_free:only free the memory if session is not child session. If it is child, session is left to be freed by the parent (in tee filter's freeSession, for example).

tee.c:newSession:mark branch session to child.
tee.c:freeSession:if child session memory is ready to be freed, free it.

mysql_mon.c:monitorMain:when backend server's status changes so that it is not running anymore or doesn't have any of the states - master, slave, ndb, joined - call for each DCB the callback-function DCB_REASON_NOT_RESPONDING if specified. Earlier callbacks were called if there was any change in the state of the server being monitored.
2014-12-22 16:24:07 +02:00
Mark Riddoch
fdb9c5e6dc Switch to thread safe versions of localtime and asctime 2014-12-03 09:53:17 +00:00
Markus Makela
2556097a98 Added commands to debugcmd.c that enable and disable logs for a single session.
Added the session id to dprintAllSessions and dprintSession output.
2014-11-19 12:25:33 +02:00
VilhoRaatikka
fd11e6a7f5 Session-specific logging. Added functions
void session_enable_log(SESSION* ses, logfile_id_t id)
and
void session_disable_log(SESSION* ses, logfile_id_t id)

Which switch specific log type on/off if the log type in question is not generally enabled.

Each thread carries a thread-specific struct log_info_t which includes members for current session id and bitfield for enabled log types for the current session. That information is checked before actual log write functions are called.

Each file where session-specific logging is used, must include the following exports:

/** Defined in log_manager.cc */
extern int            lm_enabled_logfiles_bitmask;
extern size_t         log_ses_count[];
extern __thread log_info_t tls_log_info;
2014-11-19 00:08:59 +02:00
VilhoRaatikka
a30fc0c787 MAX-328, Add session identifier to trace log entries. Session id is given to session in session_alloc and stored to thread's local storage variable when thread picks a new event from epoll_wait. 2014-11-17 23:27:14 +02:00
VilhoRaatikka
4e405ebb8f Added logging to log rotation and to filter session setup. 2014-11-12 16:41:28 +02: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
0a306b2eeb Fix bug #611, http://bugs.mariadb.com/show_bug.cgi?id=611
Fixes to Coverity issues 72703, 72713, 72718, 72721
2014-11-05 18:37:11 +02: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
Mark Riddoch
3dcecc2d77 Fix for bug 539 2014-09-12 15:29:48 +01:00
Mark Riddoch
231b146645 Fix memory leak in filter support 2014-09-12 07:50:01 +01:00
Mark Riddoch
c133c6ef4a Fix for bug 479 - Undefined filter reference in MaxScale.cnf causes a crash 2014-08-22 14:33:14 +01: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
1d1da398d4 Merge branch 'develop' into MAX-99
Conflicts:
	server/modules/routing/readwritesplit/readwritesplit.c
2014-06-25 17:50:29 +03:00
VilhoRaatikka
65c42b93cf If backend fails and sets session state to SESSION_STATE_STOPPING before session is in state SESSION_STATE_ROUTER_READY, sessoin.c:session_alloc overwrites the session state by SESSION_STATE_ROUTER_READY. Protected session state modification and added check before changing the state.
cloesSession was called in session.c:session_free if all DCBs had been removed their references to session. closeSession, however, is function which handles closing router. Router is responsible for closing all backend DCBs (=connections). Thus, calling sessionClose after all backend connections had been removed already is unnecessary and causes assertion traps.

Simply removed the call.
2014-06-24 21:59:42 +03:00
Mark Riddoch
c759767a91 Use new session entry points to get remote and user rather than dereference
the DCB directly.
2014-06-19 16:07:21 +01: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
49163a4c43 Merge branch 'develop' into MAX-11 2014-06-16 19:53:19 +03:00
Mark Riddoch
189793f992 Clean up some compiler warnings 2014-06-16 08:40:04 +01:00
Mark Riddoch
850603171b Improvements to CLI commands and client 2014-06-16 07:57:12 +01:00
Mark Riddoch
8103ac6052 Merge branch 'develop' into MAX-65 2014-06-14 12:54:08 +01:00
Mark Riddoch
719503e471 Addition of new client utility, maxadmin.
Supporting protocol for the admin interface

New routing module, cli, which shares source with debugcli

Tidyup output of lsit commands
2014-06-13 23:40:07 +01:00
VilhoRaatikka
15ff1fd26a Fixed many error handling issues regading to timing and multiple threads.
Added flags to those backend references which have sent something to backend which causes the backend to send results or reply back. Didn't add removal of the flag since there's currently no way to tell whether response from backend contains anything else than session command reply - which aren't counted when BREF_WAITING_RESULT is set and cleared.
2014-06-12 23:22:51 +03:00
Mark Riddoch
d17315b2cd Updated QLA filter to allow for regex matches and client address matches
to control the statements that are logged.
2014-06-11 23:55:29 +01:00
Mark Riddoch
77e1426dbf Initial upstream fitlering implementation.
Test filter with up and down stream filtering. Keeps top N queries
and prints a report of these queries on session close.
2014-06-09 21:13:28 +01:00
Mark Riddoch
857ae25570 Addition of session filter tracking in order to allow the show session
command to call the diagnostic entries points of the filters in the
session.

Slight improvements to the two example filters and a fix to the
trim routine.
2014-06-02 10:56:50 +01:00
Mark Riddoch
8d55be4b23 First working filters implementaton.
Only downstream filters are supported currently, i.e. no result
set filtering can be done.

A crude QLA (Query Log All) filter is included as a test harness only
2014-05-30 16:45:39 +01:00