1085 Commits

Author SHA1 Message Date
Johan Wikman
f14380243b Rename cppdefs.hh to ccdefs.hh
For obvious reasons; the c++ suffix is .cc and not .cpp
2018-08-10 07:50:18 +03:00
Markus Mäkelä
9d30c524e3
MXS-1929: Fix mock testing framework
The testing framework extended the public struct, not the private
one. Also moved the internal Session class inside the mxs namespace to
prevent conflicts with the mock testing Session class.
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ä
710f2d3c79
Unify unit test naming
The tests now all use snake_case naming.
2018-08-06 21:20:29 +03:00
Markus Mäkelä
02b330e4fe
Explicitly include <vector> in cache filter
The filter relied on the session.h including.
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ä
6c59da77fb
Merge branch '2.2' into develop 2018-07-26 11:27:09 +03:00
Markus Mäkelä
21eef8a670
MXS-1985: Kill connections inside workers
The LocalClient micro-client required a reference to the session that was
valid at construction time. This is the reason why the previous
implementation used dcb_foreach to first gather the targets and then
execute queries on them. By replacing this reference with pointers to the
raw data it requires, we lift the requirement of the orignating session
being alive at construction time.

Now that the LocalClient no longer holds a reference to the session, the
killing of the connection does not have to be done on the same thread that
started the process. This prevents the deadlock that occurred when
concurrect dcb_foreach calls were made.

Replaced the unused dcb_foreach_parallel with a version of dcb_foreach
that allows iteration of DCBs local to this worker. The dcb_foreach_local
is the basis upon which all DCB access outside of administrative tasks
should be built on.

This change will introduce a regression in functionality: The client will
no longer receive an error if no connections match the KILL query
criteria. This is done to avoid having to synchronize the workers after
they have performed the killing of their own connections.
2018-07-24 09:51:46 +03:00
Marko
2acf5f545e MXS-1066 Add query hint to route to last used server
Add new hint type and support for it in the readwritesplit router.
2018-07-13 11:11:02 +03:00
Markus Mäkelä
81527894ee
Remove filter options
None of the filters used the options. The filter API version was already
incremented once for 2.3 so there's no need to increment it again.
2018-07-11 14:08:56 +03:00
Markus Mäkelä
77a1417479
Replace TR1 headers with standard headers
Now that the C++11 standard is the default one, we can remove the TR1
headers and classes.
2018-07-11 14:08:46 +03:00
Johan Wikman
e7913cc022 MXS-1624 Update qc_setup() prototype
Now takes a structure that, if present, enables the query
classification caching and specifies the properties of the
cache.

For the time being no actual properties are yet available.
2018-07-06 12:12:31 +03:00
Johan Wikman
d339b89990 MXS-1774 Make rejection of functions optional
It is now possible to prevent the masking filter from rejecting
statements using functions in conjunction with fields to be
masked. So now it is possible to not use the blanket rejection
of the masking filter and replace it with more detailed firewall
rules.
2018-07-06 11:20:31 +03:00
Johan Wikman
43cc6ca3cd MXS-1774 Reject query with masked columns + functions
The masking filter works only on the result-set. However, if
functions are used, the column names will not be available in
the result-set, and hence masking will not take place.

Now, the statement is checked and if functions are used in
conjunction with columns that should be masked, the statement
is rejected. Thus, functions can no longer be used for bypassing
the masking. That was possible earlier as well, but required
manually setting up the firewall filter.
2018-07-06 11:20:31 +03:00
Markus Mäkelä
2e88ce4132
Merge branch '2.2' into develop 2018-07-04 22:01:01 +03:00
Markus Mäkelä
79acbae4e5
Fix cache test build failure
The change in defaults caused the test to fail.
2018-07-04 13:51:09 +03:00
Markus Mäkelä
44ef4912e8
Merge branch '2.2' into develop 2018-07-03 21:13:41 +03:00
Markus Mäkelä
013dfa79aa
Quote whitespace-only default values
Parameters that accept whitespace-only values need to have their default
values quoted if they contain only whitespace characters. In 2.2 the
qlafilter is the only module that did not do this.
2018-07-03 03:09:19 +03:00
Johan Wikman
b0902402b6 MXS-1940 Turn cache filter non-experimental
Also change the following defaults:

- "selects": Was "verify_cacheable", is now "assume_cacheable"
- "cached_data": Was "shared", is now "thread_specific"
2018-07-02 08:44:39 +03:00
Johan Wikman
063e9b9a36 MXS-1939 Remove leak in cache test program 2018-06-25 12:12:20 +03:00
Johan Wikman
f7ca8d1494 MXS-1939 Ensure no leaks when there is an array of rules
In case an array of cache rules is provided, we will only store
references to the objects in the array. Consequently, the counts of
the borrewed references to the objects must be increased, and the
reference count of the array itself decreased.
2018-06-25 12:08:44 +03:00
Johan Wikman
b7451c13bf MXS-1939 Fix leaks in mock-class
The mock-class used in the cache testing leaked memory.
2018-06-25 11:27:53 +03:00
Johan Wikman
cc0299aee6 Update change date of 2.3 2018-06-25 10:07:52 +03:00
Markus Mäkelä
7254a7c525
Make maxutils a standalone library
The only way to cleanly separate the maxutils library from the MaxScale
CMake project is to make it a standalone CMake project. With the help of
ExternalProject, it should be relatively easy to use.
2018-06-22 13:59:57 +03:00
Johan Wikman
47b2036afa Merge branch '2.2' into develop 2018-06-20 12:55:15 +03:00
Johan Wikman
5d4b3bc419 MXS-1887 Prevent gwbuf_copy_data() performance hit
The cache filter walks through the resultset in order to detect
when the resultset ends. That is, it reads each packet header as
they arrive.

In case the resultset is large, the cache will have to read several
packet headers. That it does using gwbuf_copy_data(). However, as that
was done using the first received GWBUF as the starting point, it meant
that in gwbuf_copy_data() the buffer chain was walked over and over
and over again, with a significant performance hit as the result.

Now we separetely store the last buffer received, and the the starting
offset of it. That way there will be no buffer chain walking.

As this is a common problem, GWBUF could cache the offset of the tail,
thus removing the performance penalty if you read from an offset that
happens to be in the tail. However, it's better to do that as a part
of a general overhaul of GWBUF.
2018-06-20 12:45:22 +03:00
Niclas Antti
72bfc73706 Throttle Filter: Properly disconnect the client session.
The client session was not disconnected when the query threashold
was exceeded in a DelayedCall.
2018-06-18 15:27:44 +03:00
Niclas Antti
81deedd857 MXS-1777 use maxbase library
The library directory structure could be simplified for ease of use, but better done with a separate commit.
2018-06-18 15:27:44 +03:00
Marko
f6e01b4434 MXS-591 Fix documentation and change comment parameter type 2018-06-13 20:44:32 +03:00
Marko
de1f95028b MXS-591 Add filter for injecting comments
Comments specified in the cnf file will be injected as a comment before
every sql statement.
2018-06-12 15:31:18 +03:00
Johan Wikman
69b19d1473 Remove unnecessary includes of hashtable.h
And add where necessary.
2018-06-12 11:02:29 +03:00
Marko
880db1353a Merge branch '2.2' into develop 2018-06-07 14:39:16 +03:00
Marko
0dd7448586 MXS-1709 Fix memory leaks in unit tests 2018-06-06 22:59:52 +03:00
Markus Mäkelä
4a3216d483
Merge branch '2.2' into develop 2018-06-04 16:00:19 +03:00
Markus Mäkelä
cddcc6d7d5
MXS-1896: Distinct LOAD DATA LOCAL INFILE from LOAD DATA INFILE
The two operations return different types of results and need to be
treated differently in order for them to be handled correctly in 2.2.

This fixes the unexpected internal state errors that happened in all 2.2
versions due to a wrong assumption made by readwritesplit. This fix is not
necessary for newer versions as the LOAD DATA LOCAL INFILE processing is
done with a simpler, and more robust, method.
2018-06-04 15:17:48 +03:00
Niclas Antti
5d02d8c0ba Merge branch '2.2' into develop 2018-06-01 09:33:04 +03:00
Niclas Antti
89296ed4e4 MXS-1740 Hintfilter leaks memory
Single spot where an existing hint ptr was overwritten. Removed gwbuf_add_hint()
because it was  adding hints at the opposite end compared to functions in hint.h.
Added hint_splice() to replace.
2018-05-31 14:04:22 +03:00
Niclas Antti
55e1a39cc3 MXS 173 Deprecate DBFW rule limit_queries
Replaced by throttle filter
2018-05-25 14:51:36 +03:00
Markus Mäkelä
715b8a6f1d
Fix CentOS 6 build failures
testrules.cc had a signed to unsigned comparison and it used lambda
functions (which are not supported in CentOS 6).

The keywords struct in hintparser.cc needed to be declared static in order
for it to compile.
2018-05-23 13:09:15 +03:00
Markus Mäkelä
643fc825fa
MXS-553: Provide full session to DCB mapping
By storing a link to the backend DCBs in the session object itself, we can
reach all related objects from the session. This removes the need to
iterate over all DCBs to find the set of related DCBs.
2018-05-22 17:46:24 +03:00
Niclas Antti
f88f0ffe47 MXS-173 switched to use maxscale::Worker::delayed_call()
Using delayed_call rather than usleep. This caused a fair amount of changes to
the timing ascpects (or delaying). Also some other small changes; more config
and all durations in milliseconds.
2018-05-18 16:24:45 +03:00
Markus Mäkelä
75eded4b89
Merge branch '2.2' into develop 2018-05-14 11:24:09 +03:00
Johan Wikman
5eb6718b75 MXS-1861 Detect and handle multistatement responses
Multi-statement SELECTs were properly detected and handled,
but e.g. multi-statement UPDATESs were not, with the result
that erronous warnings were logged.

Now the responses are detected and handled properly.
2018-05-14 10:15:36 +03:00
Johan Wikman
aa1c956aa7 MXS-1841 Compile all filters as C++
Minimal changes to make the files compile with a C++ compiler.
2018-05-03 10:04:44 +03:00
Niclas Antti
02b6cd7004 MXS-173 Initial version of throttle filter 2018-04-30 08:51:50 +03:00
Esa Korhonen
5d010ff712 Cleanup SERVER struct
Removed one unused field. Rearranged others, clarified comments.
2018-04-27 10:48:56 +03:00
Johan Wikman
5f7257f432 MXS-1401 Add test cases
Test that an array of rules is parsed and used properly.
2018-04-27 09:22:17 +03:00
Johan Wikman
a3a8b5523e MXS-1401 Support multiple cache rules
The possibility to have multiple cache rules in a cache
configuration file is now handled throughout the cache
filter.

The major difference is that while you earlier directly
queried the Cache whether data should be stored to the
cache and whether data in the cache should be used, you
now query the Cache whether data should be stored to the
cache and, if so, get a CacheRules object from which you
subsequently query whether data from the cache should
be used.
2018-04-27 09:22:17 +03:00
Johan Wikman
605f771518 MXS-1401 Extend rule parsing to handle array of rule objects
It's now possible to have a rules file with an array of rule
objects, e.g.

  [
    {
      store: [ ... ],
      use: [ ... ]
    },
    {
      store: [ ... ],
      use: [ ... ]
    }
  ]

This commit only contains the low-level modifications for
supporting that; the upper-level modifications are made in
another commit.
2018-04-27 09:22:17 +03:00