96 Commits

Author SHA1 Message Date
Markus Makela
18a3aa5e33 Added missing newlines to all files
This caused build errors some systems, namely RHEL 5.
2016-03-08 14:48:17 +02:00
Markus Makela
bf24f18805 Merge branch 'develop' into MXS-544 2016-02-29 10:40:33 +02:00
Markus Makela
f03865f32a Cloned DCB authentication data was freed twice
This caused all Tee filter sessions to crash when the branch DCB was closed.
2016-02-27 13:05:44 +02:00
Markus Makela
f8d74dd7e2 Cleaned up error logging for session creation failures
The old message logged the function name and thread ID which are not useful
to the end user. The thread ID should only be printed for debugging purposes,
not general error messages.
2016-02-25 18:52:22 +02:00
counterpoint
5122777829 Try to fix problem if balancing free client DCB and free session so that auth data is always available and client DCB is not freed until session is ready to be freed. Also fix problem in auth logic. 2016-02-24 10:00:45 +00:00
counterpoint
395cbdc103 Simplify handling of "client data" by having a pointer to it only in DCB and not in session structure. Change name of session->client to session->client_dcb for greater clarity. Temporary free of client data in DCB, to be moved to authenticator when it becomes a module. Fix incorrect name of listener_alloc. 2016-02-23 11:13:21 +00:00
Markus Makela
c2310327fc Fixed idle session processing
The current implementation of idle connection timeouts is not safe. The sessions
are handled in a way which is not thread-safe and the checking is done from
a non-polling thread.

With this change, the checks for the session timeouts are done in one of the
polling threads in a thread-safe manner only if at least one service has enabled
the timing out of idle client connections.
2016-01-19 10:53:55 +02:00
Johan Wikman
15df33a93f Reindent server/core/session.c 2015-12-01 09:26:26 +02:00
Johan Wikman
916ee5ff2a Rename some log concepts
The mxs prefix is now uniformly used with all log components.
2015-11-26 17:34:53 +02:00
Johan Wikman
a8535f42af Remove all traces of logfile_t
The earlier log file based approach for enabling and disabling
messages has now been completely replaced with the syslog priority
based approach.

Similarly as with log files before it is now possible to enable
and disable a log priority for a particular session, even though
it apparently has not been used much.

The local test-programs of the logging has got minimal attention
only to make them compile. They should get an overhaul as they did
not work before either.
2015-11-23 19:10:53 +02:00
Johan Wikman
44df53d846 LOGIF and skygw_write_log removed from server/core/*.c
LOGIF and skygw_write_log removed from server/core/*.c and
replaced with calls to MXS_(ERROR|WARNING|NOTICE|INFO|DEBUG).
This is a mechanism change, no updating of the actual message
has been performed.

Currently this causes a very small performance hit, since the
check whether the priority is enabled or not is performed in
the function that is called and not before the function is called.
Once all LOGIFs and skygw_write_logs have been replaced, the
behaviour will be altered back to what it was.
2015-11-16 09:49:12 +02:00
counterpoint
dee20fe077 Merge remote-tracking branch 'origin/develop' into MXS-329-develop-20151111
# Conflicts:
#	server/core/CMakeLists.txt
#	server/core/buffer.c
#	server/core/service.c
#	server/modules/filter/tee.c
#	server/modules/monitor/mysql_mon.c
#	server/modules/routing/binlog/blr.c
#	server/modules/routing/binlog/blr_slave.c
#	server/modules/routing/debugcmd.c
#	server/modules/routing/readwritesplit/readwritesplit.c
#	utils/skygw_utils.cc

- resolved.
2015-11-11 11:08:02 +00:00
Johan Wikman
834a88aeda Log variables moved to log_manager.h
The log manager variables lm_enabled_log_files_bitmask, log_ses_count
and tls_log_info that earlier were declared separately in every
c-file are now declared in the log_manager.h header.
2015-11-04 14:26:53 +02:00
Markus Makela
040587c828 Fix to MXS-413: https://mariadb.atlassian.net/browse/MXS-413
Added missing terminating newlines so showSession and improved maxadmin logic.
2015-10-19 09:01:58 +03:00
Martin Brampton
91dd3bb9bd Fix mistake. 2015-09-17 08:18:47 +01:00
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