116 Commits

Author SHA1 Message Date
Esa Korhonen
d96a7dedc5 MXS-2205 Convert maxscale/poll.h to .hh 2018-12-04 14:51:02 +02:00
Markus Mäkelä
43c33e9f4a
MXS-2196: Allocate a session before allocating DCBs
Allocating the session before a DCB guarantees that at no point will a DCB
have a null session. This further clarifies the concept of the session and
also allows the listener reference to be moved there.

Ideally, the session itself would allocate and assign the client DCB but
since the Listener is the only one who does it, it's acceptable for now.
2018-12-04 11:50:43 +02:00
Markus Mäkelä
692127a2cb
MXS-2196: Remove the dummy session
As each connection now immediately gets a session the dummy session is no
longer required. The next step would be to combine parts of the session
and the client DCB into one entity. This would prevent the possibility of
a client DCB with no associated session. Backend DCBs are different as
they can move from one session to another when the persistent connection
pool is in use.
2018-12-04 11:50:43 +02:00
Markus Mäkelä
a2f5cc9d09
MXS-2196: Rename struct session to struct MXS_SESSION 2018-12-04 11:50:43 +02:00
Markus Mäkelä
da9816b7e7
MXS-2196: Always allocate a session
Whenever a client DCB is accepted, a session for it is allocated. This
simplifies the handling of shared data between DCBs by allowing it to be
placed inside the session object. Currently, the data is stashed away in
the client DCB.
2018-12-04 11:50:43 +02:00
Markus Mäkelä
180e150ba1
MXS-2196: Split session startup into two parts
The session allocation now has two distinct parts: the initialization of
the session itself and the creation of the router and filter
sessions. This allows sessions to be allocated the moment a client DCB is
created instead of only after the authentication is complete. With this
change, the need for the dummy session is removed.
2018-12-04 11:50:43 +02:00
Markus Mäkelä
694d4a4003
MXS-2196: Make DCB a C++ struct
Allocating DCB with new allows the use of C++ objects in the DCB
struct. Also the explicit poll field can be replaced by inheriting from
MXB_POLL_DATA.
2018-12-04 11:50:43 +02:00
Markus Mäkelä
ad12ff6d06
MXS-2196: Rename dcb.h to dcb.hh 2018-12-04 11:50:43 +02:00
Markus Mäkelä
3b5e45ceee
MXS-2196: Combine session.h and session.hh
Combined the public session headers into one.
2018-12-04 11:43:38 +02:00
Esa Korhonen
756593a718 MXS-2205 Combine maxscale/router.h with maxscale/router.hh 2018-12-03 15:28:06 +02:00
Esa Korhonen
97bb7e7e1a MXS-2205 Combine maxscale/modutil.h with maxscale/modutil.hh 2018-12-03 15:28:06 +02:00
Esa Korhonen
1701f87f00 MXS-2205 Convert internal/maxscale.h and internal/dcb.h to .hh 2018-12-03 13:49:08 +02:00
Markus Mäkelä
77585bdb8c
MXS-2197: Make config.h and service.h C++ headers
This is the first step into converting the other headers into C++.
2018-11-30 12:15:57 +02:00
Johan Wikman
32f2e769f4 MXS-1780 Make retain_last_statements service specific 2018-11-08 12:08:42 +02:00
Johan Wikman
2bd2b4a32e MXS-1780 Report times using localtime instead of gmtime 2018-11-08 12:08:42 +02:00
Johan Wikman
dd712a06fa MXS-1780 Make statement retaining session specific
Whether or not a session should retain its statements is now
a property of the session. This in preparation for making the
whole functionality a property that can be enabled and disabled
at runtime, of the service.
2018-11-08 12:08:42 +02:00
Johan Wikman
c899f00541 MXS-1780 Collect server response information
As the router is the only one that knows what backends a particular
statement has been sent to, it is the responsibility of the router
to keep the session bookkeeping up to date. If it doesn't we will
know what statements a session has received (provided at least some
component in the routing chain has RCAP_TYPE_STMT_INPUT capability),
but not how long their processing took. Currently only readwritesplit
does that.

All queries are stored and not just COM_QUERY as that makes the
overall bookkeeping simpler; at clientReply() time we do not need to
know whether or not to bookkeep information, we can just do it.

When session information is queried for, we report as much information
we have available.
2018-11-08 12:04:55 +02:00
Johan Wikman
c78c5a615d MXS-1780 Store time when statement was received 2018-11-08 12:03:50 +02:00
Johan Wikman
c6378e1006 MXS-1780 Make retained statements available via REST-API 2018-11-08 12:03:50 +02:00
Johan Wikman
fa13b8036a MXS-1780 Store last statement as cloned GWBUF
The last statements of a session are now stored as a cloned
GWBUF instead of as a copy of the SQL.
2018-11-08 12:03:50 +02:00
Markus Mäkelä
75ea1b6ea1
Fix formatting of new(std::nothrow)
The code previously formatted everything as `new( std::nothrow)`.
2018-10-04 21:50:44 +03:00
Markus Mäkelä
9278da1f54
MXS-2067: Remove spinlock.h
Removed the spinlock.h header and replaced with plain pthread types and
functions.
2018-09-28 12:18:24 +03:00
Markus Mäkelä
f9e876db06
Fix Session destruction
The Session class was deleted via the opaque pointer instead of the actual
class pointer.
2018-09-24 12:07:49 +03:00
Markus Mäkelä
71ffef5708
Partially revert 4ba011266843857bbd3201e5b925a47e88e1808f
Add back leading operator enforcement.
2018-09-20 15:57:30 +03:00
Markus Mäkelä
2e069fa892
MXS-1632: Take mxb::atomic::add into use
The function now mostly replaces the use of atomic_add_ functions declared
in atomic.h.
2018-09-18 15:21:54 +03:00
Markus Mäkelä
d11c78ad80
Format all sources with Uncrustify
Formatted all sources and manually tuned some files to make the code look
neater.
2018-09-10 13:22:49 +03:00
Niclas Antti
c447e5cf15 Uncrustify maxscale
See script directory for method. The script to run in the top level
MaxScale directory is called maxscale-uncrustify.sh, which uses
another script, list-src, from the same directory (so you need to set
your PATH). The uncrustify version was 0.66.
2018-09-09 22:26:19 +03:00
Markus Mäkelä
26dfb19ea4
Make routingworker.hh public
Given that worker.hh was public, it made sense to make routingworker.hh
public as well. This removes the need to include private headers in
modules and allows C++ constructs to be used in C++ code when previously
only the C API was available.
2018-09-04 13:04:08 +03:00
Markus Mäkelä
a13e95951b
Merge branch '2.2' into develop 2018-08-30 11:37:49 +03:00
Markus Mäkelä
5f4aa46552
MXS-2027: Store LOAD DATA state inside MXS_SESSION
By storing the data gathere by readwritesplit inside the session, the
protocol will be aware of the state of the LOAD DATA LOCAL INFILE
execution. This prevents misinterpretation of the data which previously
led to closed connections, effectively rendering LOAD DATA LOCAL INFILE
unusable.

This change is a temporary solution to a problem that needs to be solved
at the protocol level. The changes required to implement this are too big
to add into a bug fix release.
2018-08-29 18:10:51 +03:00
Johan Wikman
3f53eddbde MXS-2020 Replace ss[_info]_dassert with mxb_assert[_message] 2018-08-22 11:34:59 +03:00
Johan Wikman
88f1795412 MXS-2008 Move Worker and MessageQueue to maxbase 2018-08-21 10:02:39 +03:00
Johan Wikman
cf0aeed516 MXS-2014 Rename log_manager.h to log.h
There's nothing resembling a manager anymore.
2018-08-17 10:59:37 +03:00
Johan Wikman
ae43e4f0f2 MXS-2013 Remove all CHK_-macros 2018-08-15 09:28:04 +03:00
Johan Wikman
8fd1648217 MXS-2013 Remove skygw_chk_t 2018-08-15 09:28:04 +03:00
Johan Wikman
f3f802cabe MXS-2008 Move maxscale/atomic.h to maxbase/atomic.h 2018-08-15 08:44:39 +03:00
Markus Mäkelä
f90b8cdafb
Fix race condition in session.cc
The dummy session was unnecessarily modified by multiple threads at the
same time. The state of the dummy session must not change once it's been
set at startup.
2018-08-13 10:37:48 +03:00
Johan Wikman
e9758ebaf1 MXS-2002 Rename Worker::post() to Worker::execute()
The main point is that tasks/functions are executed, not that
they are posted.
2018-08-13 08:30:05 +03:00
Johan Wikman
6335d3776c MXS-2002 Replace auto_ptr with unique_ptr
Given 'Derived : public Base', a unique_ptr<Derived> converts
implictly to a unique_ptr<Base>.
2018-08-13 08:30:05 +03:00
Johan Wikman
9cfd451a1d MXS-2002 Make Worker excecution mode explicit
This is the first step in some cleanup of the Worker interface.
The execution mode must now be explicitly specified, but that is
just a temporary step. Further down the road, _posting_ will
*always* mean via the message loop while _executing_ will optionally
and by default mean direct execution if the calling thread is that
of the worker.
2018-08-13 08:30:05 +03:00
Markus Mäkelä
2e60d5fd71
MXS-1929: Store filters inside Session
The Session now holds a reference to the filters it uses. This makes the
use of filters safe even if they are destroyed mid-session.
2018-08-06 21:20:29 +03:00
Markus Mäkelä
7e64d6b3df
MXS-1929: Move use of C++ inside the Session
The Session class now handles the work involved in dealing with the
private member variables.
2018-08-06 21:20:29 +03:00
Markus Mäkelä
945510e735
MXS-1929: Add Session class
The Session class now contains all of the C++ objects that were previously
in the MXS_SESSION struct. It is also allocated with new but all
initialization is still done outside of the Session in session_alloc_body.

This commit will not compile as it is a part of a set of commits that make
parts of the session private.
2018-08-06 21:20:29 +03:00
Markus Mäkelä
47176d9bf1
MXS-1929: Take local filter lists into use
The session creation function now uses the local filter list of the
worker. This also removes the need for the has_filters function.
2018-08-06 21:20:29 +03:00
Markus Mäkelä
7d6338d65b
MXS-1929: Make filters configurable at runtime
The filters can now be altered at runtime. Currently, the filter usage
uses a service level lock. The next is to allocate a per-service key to
the worker local data and use that to orchestrate the storage of the
filter lists.
2018-08-06 21:20:29 +03:00
Markus Mäkelä
4d3dbb2040
MXS-1929: Take SFilterDef into use
The service now uses a std::vector<SFilterDef> to store the filters it
uses. Most internal parts deal with the SFilterDef but debugcmd.cc still
moves raw pointers around (needs to be changed).
2018-08-06 21:20:29 +03:00
Markus Mäkelä
ec420332ea
MXS-1929: Take ResultSet into use
Replaced the previous RESULTSET with the new implementation. As the new
ResultSet doesn't have a JSON streaming capability, the MaxInfo JSON
interface has been removed. This should not be a big problem as the REST
API offers the same information in a more secure and structured way.
2018-07-31 22:50:08 +03:00
Markus Mäkelä
cca7757090
MXS-1929: Take internal Service struct into use
The internals now mostly refer to the Service struct instead of the public
SERVICE struct.
2018-07-31 09:41:13 +03:00
Markus Mäkelä
829fdcff83
MXS-1929: Make filters fully opaque
The filter implementation is now fully hidden. Also converted it to a C++
struct allocated with new and stored the filters in a global list instead
of embedding the list in the object itself.
2018-07-31 09:41:13 +03:00
Markus Mäkelä
efd953c434
MXS-1929: Store service active state atomically
When a session is closed, it releases a reference on the service and
checks if it was the last session for a destroyed service. The state of
the service was loaded after the reference count was decremented.  This
behavior introduced a race condition where it was possible for a service
to be freed twice, first by the thread that marked the service as
destroyed and again by the last session for that service. By always
loading the service state before decrementing the reference count, we
avoid this race condition.

Currently, the memory ordering used for the reference counting is too
strict and could be relaxed. By default, all atomic operations use
sequentially consistent memory ordering. This guarantees correct behavior
but imposes a performance penalty. Incrementing the reference counts could
be done with a relaxed memory order as long as as we know the reference
we're incrementing is valid. Releasing a reference must use an
acquire-release order to guarantee the read-modify-write operation is
successful.
2018-07-31 09:41:12 +03:00