31 Commits

Author SHA1 Message Date
Johan Wikman
61a2c960ec MXS-1378 Provide access to current session
Provide access to current session and session id. This will
be used by the logging mechanism for logging the session id
together with messages.
2017-09-01 13:20:20 +03:00
Markus Mäkelä
5b1f8afcd9 MXS-1366: Validate closed connections before pooling them
When a session is being closed in a controlled manner, i.e. a COM_QUIT is
received from the client, it is possible to deduce from this fact that the
backend connections are very likely to be idle. This can be used as an
additional qualification that must be met by all connections before they
can be candidates for connection pooling.

This assumption will not hold with batched and asynchronous queries. In
this case it is possible that the COM_QUIT is received from the client
before even the first result from the backend is read. For this to work,
the protocol module would need to track the number and state of expected
responses.
2017-08-21 10:31:07 +03:00
Johan Wikman
65457f1724 Remove support for session specific log priorities
No need to maintain information in thread local storage,
which just added complexity and also incurred a slight
performance penalty.
2017-02-27 14:41:01 +02:00
Johan Wikman
49cc2b52e3 Merge branch '2.1.0' into 2.1 2017-02-15 08:44:55 +02:00
Johan Wikman
5648f708af Update license to BSL 1.1 2017-02-14 21:42:28 +02:00
Markus Mäkelä
ce5cd69eb3 Remove unused locks and variables
Removed unused spinlocks from DCBs, sessions and the MySQL protocol
structs. They were used in a context where only one thread has access to
the structure.

Removed unused member variables from DCBs.
2017-02-08 15:31:17 +02:00
Markus Mäkelä
99f6d4678d Make COMMIT/ROLLBACK a part of the transaction
The transaction tracking now flags the transaction as open even when a
COMMIT/ROLLBACK is received. The next statement after the transaction is
closed resets the transaction state to inactive. This means that the end
of the transaction belongs in the transaction.

This allows all statements that belong to a transaction to be detected
with the transaction tracking functions provided by the core. With this,
the routing modules should have an easier time handling transactions.
2017-01-24 20:36:39 +02:00
Markus Mäkelä
c77bb502e9 Store transaction type bit on transaction end
When the transaction ends, it's good to know what type of a transaction
just ended. Currently, this will be used by readwritesplit to detect when
a read-only transaction ends.
2017-01-24 20:36:39 +02:00
Markus Mäkelä
81be935fa9 Track transaction end as well as start
The COMMIT and ROLLBACK are now detected. This can be used to route the
trailing end of a transaction to a specific server.
2017-01-24 20:36:39 +02:00
Esa Korhonen
02a8f7492e Divide session.h to internal and interface headers
Definitions and function used by core are in
server/core/maxscale/session.h
Definitions and function used by plugins are in
include/maxscale/session.h
2017-01-19 15:19:40 +02:00
Esa Korhonen
00f77bbe69 Fix some leftovers from the SESSION->MXS_SESSION and related renames
Renames only.
2017-01-18 11:50:52 +02:00
Esa Korhonen
fb771c8a2e Rename public types and constants in session.h
Preparing to split session.h into module and core sections.
2017-01-17 16:30:14 +02:00
Markus Mäkelä
0b6b9c3d81 Format core source code and headers
Formatted core source code and headers with Astyle.
2017-01-17 14:47:50 +02:00
Johan Wikman
265e5c0593 Rename FILTER_DEF to MXS_FILTER_DEF
Provide functions that allows the actual definition of MXS_FILTER_DEF
to be made private.
2017-01-13 14:30:11 +02:00
Johan Wikman
424849a9a2 Rename UPSTREAM to MXS_UPSTREAM
And DOWNSTREAM to MXS_DOWNSTREAM
2017-01-13 13:40:03 +02:00
Johan Wikman
78928dc575 Make session_[getUser|get_remote] const correct
- Rename session_getUser to session_get_user
- Change session_get_user and session_get_remote to take a const
  SESSION* as argument and to return a const char*.
- Change server_get_persistent, so that user is passed as const.
- Update all users of these functions as appropriate.
2017-01-02 16:16:37 +02:00
Markus Makela
d42ef8ed13 Combine and rename session statement functions
There was no real need to have two separate functions for getting the
stored buffer and the target server. Combining them into one allows it to
be handled in a nicer way.
2016-12-08 10:07:48 +02:00
Markus Makela
03e06727e8 Fix order of function declarations in session.h
A function was used before it was declared.
2016-12-07 10:58:01 +02:00
Markus Makela
8d539d9afb Improve transaction tracking fix
The previous fix can be implemented with less changes to actual code.
2016-12-07 10:39:16 +02:00
Markus Makela
6f7f8cae39 Add storing of statements to session
Statements can now be stored in the session object. This enables the
retrieval of these statements at a later time. These will be used by
readwritesplit to reroute failed reads to backup slaves.
2016-12-06 20:27:51 +02:00
Markus Makela
a4bc575353 Remove direct freeing of sessions
Sessions are now always freed by releasing the last reference to it.
2016-12-02 15:19:44 +02:00
Markus Makela
adbd666991 Change module command parameter types
This commit introduces safe session references that can be handled without
holding locks. This allows the safe searching of sessions with the unique
ID of the session.

Remove the use of raw pointers passed as strings. Change the comments of
the argument types and add more details to the parsing function
documentation.
2016-12-02 14:26:56 +02:00
Markus Makela
2efa862944 Remove listmanager code
The code prevented scaling by imposing global spinlocks for the DCBs and
SESSIONs. Removing this list means that a thread-local list must be taken
into use to replace it.
2016-11-30 10:28:23 +02:00
Markus Makela
5067f3594a Adapt session timeout checks to a per thread model
Each thread will now check their own list of DCBs for timed out sessions.
2016-11-30 10:28:23 +02:00
Johan Wikman
d7ce3ad75b Replace include guards with #pragma once 2016-10-26 08:23:15 +03:00
Johan Wikman
f961f87e5e Update autocommit mode and transaction state
The transaction state only reflects explicitly started transactions.
Thus, by looking at the autocommit mode and the transaction state a
component can figure out whether the current statement will be committed
or not.
2016-10-25 16:21:31 +03:00
Johan Wikman
693d8dcbb4 Track session autocommit state
This tracks only what is explicitly set. That is, if autocommit
has been set true then, even if a transaction is started, autocommit
will not be set false.

That is, a user of the session autocommit and transaction states
need to be aware of their semantics. If a transaction is active,
then the state of autocommit is irrelevant.
2016-10-21 13:58:51 +03:00
Johan Wikman
311eae8cfe MXS-983: Add transaction state to session object 2016-10-20 23:00:33 +03:00
Johan Wikman
03dbc6df80 Remove dependency on skygw_utils.h
- STRERROR_BUFLEN moved to cdefs.h and renamed to MXS_STRERROR_BUFLEN.
  Better would be to provide a 'const char* mxs_strerror(int errno)'
  that would have a thread specific buffer for the error message.
- MIN and MAX also moved to defs.h as MXS_MIN and MXS_MAX.
- Now only mlist.h of the headers depend upon skygw_utils.h.
2016-10-14 15:42:02 +03:00
Johan Wikman
1a978be6b6 Cleanup header files
- All now include maxscale/cdefs.h as the very first file.
- MXS_[BEGIN|END]_DECLS added to all C-headers.
  Strictly speaking not necessary for private headers, but
  does not hurt either.
- Include guards moved to the very top of the file.
- #pragma once added.
2016-10-14 11:54:37 +03:00
Johan Wikman
e41589be10 Move headers from server/include to include/maxscale
- Headers now to be included as <maxscale/xyz.h>
- First step, no cleanup of headers has been made. Only moving
  from one place to another + necessary modifications.
2016-10-13 16:19:20 +03:00